Architecture
MCPcat’s SDK runs inside your MCP server, intercepting MCP protocol messages to capture analytics before passing them through to your tools. Your server works exactly as before. MCPcat just observes.Agent Intent Capture
The magic of MCPcat lies in understanding why agents call your tools, not just what they call. When you install the SDK, MCPcat automatically injects acontext parameter into your tool schemas. When AI assistants (like Claude Code or Cursor) call your tools, they see this additional parameter, they use it to explain their reasoning for making that tool call.
- What users are trying to accomplish
- How tools fit into larger workflows
- Common patterns and use cases
- Missing functionality users need
Request Tracing
MCPcat intercepts all MCP protocol messages by wrapping your server’s handlers:- Event type (tool call, resource access, prompt execution)
- Timing data (start time, duration)
- Request parameters and response data
- Error states and messages
- Client information (which AI tool made the request)
How it Works Under the Hood
1. Schema Enhancement
When MCPcat wraps your server, it modifies tool schemas to include the context parameter: Before MCPcat:2. Transparent Interception
MCPcat intercepts requests without affecting your tool’s functionality:- Client calls tool with arguments + context
- MCPcat extracts the context parameter
- Your tool receives original arguments (without context)
- Tool executes normally
- MCPcat captures the response
- Event is queued for analytics
3. Asynchronous Processing
Events are processed asynchronously to ensure zero performance impact:- Thread-safe queue holds events (default: 10,000 capacity)
- Worker threads send events to MCPcat API
- Automatic retries with exponential backoff
- Graceful shutdown ensures no data loss
4. Privacy & Control
MCPcat is designed with privacy in mind:- Redaction functions let you scrub sensitive data before sending
- All data encrypted at rest
- You control what events are tracked
- No PII required - user identification is optional
Sessions
Every interaction with your MCP server happens within a session. A session begins when a client connects and persists throughout their entire interaction, automatically assigned a unique identifier that tracks all activities within that connection.- Initialization: A new session starts when a client initializes a connection to your MCP server
- Activity: All tool invocations and interactions are associated with the session
- Inactivity: Sessions remain active as long as the client maintains the connection
- Termination: Sessions end when the client disconnects or after a period of inactivity (usually 30 minutes)
Session Construction
Sessions are constructed in two phases — first by the SDK on the client, then refined by the server.Client-Side (SDK)
The SDK intercepts your MCP server’s transport layer and automatically captures every interaction without requiring any code changes to your tools. When a client connects, the SDK:- Generates a unique session ID and associates all subsequent events with it
- Captures metadata about the connection, like client name and version, server name and version, and SDK language and version
- Records each interaction as a structured event with tool calls, resource reads, prompt requests, along with timing data, parameters, and responses
- Streams events asynchronously to MCPcat’s ingestion pipeline so there is zero impact on your server’s response times
Server-Side Processing
Once events arrive, MCPcat’s server reconstructs and enriches each session through several processing stages:- Session assembly: Events are matched to their session using atomic, concurrent-safe operations. If a session doesn’t exist yet, it’s created on the first event. Metadata fields are progressively backfilled: if the first event is missing client info, later events in the same session can fill in the gaps.
- Session consolidation: Some MCP clients (like Claude Desktop) reset session identifiers mid-conversation. MCPcat detects these inconsistencies and automatically merges fragmented sessions back together, so you see one continuous interaction instead of several broken ones.
- Counter denormalization: As events arrive, session-level metrics (total events, tool calls, errors, missing tool indicators) are updated atomically. This means your dashboard queries are fast even across thousands of sessions, without needing to re-aggregate raw events on every page load.
- Error grouping: When an error occurs during a tool call, MCPcat parses the error, computes a fingerprint, and groups it with similar errors across sessions. This surfaces recurring issues automatically rather than burying them in individual session logs.
- Goal categorization: After a session becomes inactive, MCPcat analyzes the sessions contents to classify an agent goal, giving you insight into what users were trying to accomplish, not just what tools they called. For more information, see Agent Goals
Projects
Projects are the top-level organizational unit for your analytics. Each project represents a distinct MCP server or deployment, identified by a unique project ID (likeproj_abc123xyz) that you use when initializing MCPcat tracking.
Organize your projects to match your needs:
- By server type: Separate projects for different MCP servers (database tools, file system tools, API integrations)
- By environment: Keep development, staging, and production data isolated
- By customer or team: Track usage across different customer deployments or internal teams
What Gets Tracked
MCPcat tracks all MCP protocol events:- Tool Operations:
tools/list,tools/call - Resource Operations:
resources/list,resources/read - Prompt Operations:
prompts/list,prompts/get - Completions:
completion/complete - Server Lifecycle:
initialize,initialized - Custom Events: Your own analytics events