diff --git a/docs/integrations/(frameworks)/mcp.mdx b/docs/integrations/(frameworks)/mcp.mdx index d91dab1..d0cd26f 100644 --- a/docs/integrations/(frameworks)/mcp.mdx +++ b/docs/integrations/(frameworks)/mcp.mdx @@ -1,7 +1,7 @@ --- title: Model Context Protocol description: Trace requests across official TypeScript MCP SDK v2 client and server transports. -lastModified: 2026-10-18 +lastModified: 2026-11-10 seo: title: "Model Context Protocol (MCP) Tracing" description: "Trace Model Context Protocol requests across client and server transports of the official TypeScript MCP SDK v2, with tool names, errors, and trace context." @@ -97,6 +97,7 @@ Each JSON-RPC request makes a client span on the side that sends it and a server - The protocol version, and the session ID when the transport has one - The tool name for `tools/call`, the prompt name for `prompts/get`, and the resource URI for `resources/read`, `resources/subscribe`, and `resources/unsubscribe` - Errors: JSON-RPC error responses and tool results marked `isError` +- The tool arguments and the tool result of `tools/call`, from version 0.3.0 (see [Control payload capture](#control-payload-capture)) Both spans record the JSON-RPC error code. The client span is always marked as an error. The server span is not marked as an error when the code means the caller sent a bad request, such as a parse error, an unknown method, or invalid params. @@ -108,21 +109,26 @@ Trace context travels in MCP request metadata by default, so the server span con - Notifications. They do not produce spans. - Metrics. The integration does not emit any. -- Tool arguments and results, unless you turn on payload capture. ## Control payload capture -Tool arguments and successful tool results are not captured by default. Turn them on for a transport only when that content is safe to send: +From version 0.3.0, `tools/call` spans record the tool arguments and the tool result. This includes a result marked `isError`, whose content usually says why the tool failed. Earlier versions record them only with `capturePayloads: true`, and never record the content of a failed result. + +The core SDK's settings decide what reaches the span: + +- `captureInput: false` drops the arguments. +- `captureOutput: false` drops the result. +- `mask` and `maxAttributeLength` apply to both. + +To keep tool content out of one transport while the SDK captures other content, turn payload capture off: ```ts const transport = instrumentMcpTransport(mcpTransport, { - capturePayloads: true, + capturePayloads: false, }); ``` -The core SDK's `captureInput`, `captureOutput`, `mask`, and `maxAttributeLength` settings still apply. `capturePayloads` lets tool content reach those controls; it does not override them. A failed tool result is marked as an error, but its content is not captured as output. - -With payload capture off, method names, tool and prompt names, resource URIs, request and session IDs, and error details are still recorded. Keep secrets out of those fields. +Error codes and the JSON-RPC error message are recorded with every setting, and `captureOutput: false` and `mask` do not apply to them. Method names, tool and prompt names, resource URIs, and request and session IDs are also recorded with every setting. Keep secrets out of those fields. ## Options @@ -130,7 +136,7 @@ With payload capture off, method names, tool and prompt names, resource URIs, re | Option | Type | Default | Description | | --- | --- | --- | --- | -| `capturePayloads` | `boolean` | `false` | Capture tool arguments and successful tool results | +| `capturePayloads` | `boolean` | `true` (`false` before 0.3.0) | Capture tool arguments and tool results | | `propagateBaggage` | `boolean` | `false` | Send and accept OpenTelemetry baggage in MCP request metadata | Configure the API key, service name, environment, and content controls with [`init()` options](/sdk/typescript#configure-init).