MCP server instance to instrument
Optionaloptions: McpServerWrapperOptionsOptional configuration for recording inputs and outputs
Instrumented server instance (same reference)
import * as Sentry from '@sentry/core';
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
// Default: inputs/outputs captured based on sendDefaultPii option
const server = Sentry.wrapMcpServerWithSentry(
new McpServer({ name: "my-server", version: "1.0.0" })
);
// Explicitly control input/output capture
const server = Sentry.wrapMcpServerWithSentry(
new McpServer({ name: "my-server", version: "1.0.0" }),
{ recordInputs: true, recordOutputs: false }
);
const transport = new StreamableHTTPServerTransport();
await server.connect(transport);
Wraps a MCP Server instance from the
@modelcontextprotocol/sdkpackage with Sentry instrumentation.Compatible with versions
^1.9.0of the@modelcontextprotocol/sdkpackage. Automatically instruments transport methods and handler functions for comprehensive monitoring.