Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions docs/integrations/(frameworks)/mcp.mdx
Original file line number Diff line number Diff line change
@@ -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."
Expand Down Expand Up @@ -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.

Expand All @@ -108,29 +109,34 @@ 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

`instrumentMcpTransport(transport, options)` accepts:

| 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).
Expand Down