M

Model Context Protocol

Trace MCP client and server requests across stdio and Streamable HTTP. See tool calls, prompts, resources, latency, errors, and distributed context in one trace.

Built by

telemetry.dev

Language

TypeScript

Packages

@telemetry-dev/mcp

Category

Protocols

About the Model Context Protocol integration

@telemetry-dev/mcp instruments transports from the official TypeScript MCP SDK v2. It records client and server request spans, correlates JSON-RPC responses, and carries W3C trace context through MCP params._meta, including across stdio process boundaries.

Key features

  • End-to-end MCP traces: Client and server spans share one trace even when MCP runs over stdio.
  • Protocol details: Inspect methods, request IDs, protocol versions, sessions, tools, prompts, resources, latency, and errors.
  • Tool-aware spans: tools/call requests appear as standard execute_tool spans with the tool name.
  • Correct error classification: JSON-RPC errors, tool failures, transport failures, and connection closure are recorded without treating caller mistakes as server faults.
  • Private by default: Tool arguments, results, and OpenTelemetry baggage stay local unless you enable their respective capture or propagation options.

Get started

Set TELEMETRY_DEV_API_KEY, initialize telemetry.dev, then instrument the transport before connecting it:

import { Client } from "@modelcontextprotocol/client";
import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";
import { instrumentMcpTransport } from "@telemetry-dev/mcp";
import { init } from "@telemetry-dev/sdk";

init({ serviceName: "mcp-client" });

const client = new Client({ name: "research-agent", version: "1.0.0" });
const transport = instrumentMcpTransport(
  new StdioClientTransport({ command: "research-mcp-server" }),
);

await client.connect(transport);

Use the same instrumentMcpTransport() call with a server transport before server.connect(). Pass { capturePayloads: true } only when tool arguments and successful results may be collected under your project's privacy policy.

The package supports MCP SDK v2. MCP v1 and MCP-specific metrics are not currently instrumented.