Takaro - v0.6.0
    Preparing search index...

    Function wrapMcpServerWithSentry

    • Wraps a MCP Server instance from the @modelcontextprotocol/sdk package with Sentry instrumentation.

      Compatible with versions ^1.9.0 of the @modelcontextprotocol/sdk package. Automatically instruments transport methods and handler functions for comprehensive monitoring.

      Type Parameters

      • S extends object

      Parameters

      • mcpServerInstance: S

        MCP server instance to instrument

      • Optionaloptions: McpServerWrapperOptions

        Optional configuration for recording inputs and outputs

      Returns S

      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);