This integration wraps MCP Server instances from the
@modelcontextprotocol/sdk package (version ^1.9.0).Installation
Basic Usage
Once wrapped, all MCP operations are automatically tracked:Configuration
Default Behavior
By default, inputs and outputs are only captured ifsendDefaultPii is enabled:
Explicit Control
Override the default behavior:Integration Options
boolean
default:"sendDefaultPii"
Capture tool/resource/prompt inputs
boolean
default:"sendDefaultPii"
Capture handler outputs and responses
What Gets Instrumented
The integration automatically wraps:Transport Methods
transport.send(): Outgoing messagestransport.onMessage(): Incoming message handlerstransport.onClose(): Connection close handlerstransport.onError(): Error handlers
Handler Functions
- Tool Handlers: Functions registered via
server.tool() - Resource Handlers: Functions registered via
server.resource() - Prompt Handlers: Functions registered via
server.prompt()
Captured Data
- Method names and types
- Request/response payloads (when recording enabled)
- Execution times
- Errors and exceptions
- Transport correlation IDs
Practical Examples
Simple MCP Server
File System Resource Server
Prompt Template Server
Database Query Tool
Error Handling
Errors in handlers are automatically captured:Custom Error Context
Performance Monitoring
View MCP operations in Sentry:Span Attributes
Captured span attributes include:Source Code
The MCP Server integration is implemented in:packages/core/src/integrations/mcp-server/index.ts:45
Best Practices
1. Secure Sensitive Data
2. Add Custom Context
3. Handle Errors Gracefully
Troubleshooting
Server Not Instrumented
Ensure you’re wrapping the server before callingconnect():