Title: OTel client spans: add `server.address` (and other semconv client attributes) so tool calls can be attributed to a server · Issue #3836 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: OTel client spans: add `server.address` (and other semconv client attributes) so tool calls can be attributed to a server · Issue #3836 · modelcontextprotocol/python-sdk
X Title: OTel client spans: add `server.address` (and other semconv client attributes) so tool calls can be attributed to a server · Issue #3836 · modelcontextprotocol/python-sdk
Description: Description The MCP send
Open Graph Description: Description The MCP send
X Description: Description The MCP send <method> [<target>] CLIENT span created in JSONRPCDispatcher.send_raw_request only carries mcp.method.name and jsonrpc.request.id: # src/mcp/shared/jsonrpc_disp...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/issues/3836
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"OTel client spans: add `server.address` (and other semconv client attributes) so tool calls can be attributed to a server","articleBody":"### Description\n\nThe `MCP send \u003cmethod> [\u003ctarget>]` CLIENT span created in `JSONRPCDispatcher.send_raw_request` only carries `mcp.method.name` and `jsonrpc.request.id`:\n\n```python\n# src/mcp/shared/jsonrpc_dispatcher.py (v2.3.0 / main)\nwith otel_span(\n span_name,\n kind=SpanKind.CLIENT,\n attributes={\"mcp.method.name\": method, \"jsonrpc.request.id\": str(request_id)},\n) as span:\n```\n\nA client connected to several MCP servers therefore can't tell from its own telemetry which server a call went to. The span name includes the tool name, but tool names aren't unique across servers, and when the server doesn't emit traces (third-party hosted servers, servers without OTel) the client span is the only record of the call.\n\n**Use case.** I run Open WebUI with three MCP servers (a Playwright-based fetch server, a smart-home server, and a hosted third-party server). Tempo's span-metrics processor turns the `MCP send tools/call \u003ctool>` spans into per-tool call counts and latency in Grafana. I'd like to group/filter those by server, but the only option today is guessing from tool-name patterns. Only one of the three servers emits its own SERVER spans, so following child spans doesn't help for the others.\n\n**What the semantic conventions say.** The GenAI MCP semantic conventions define these on MCP client spans, none of which are currently set:\n\n- `server.address` / `server.port` (`Recommended`; for client spans, the address of the server behind any intermediaries, if known)\n- `network.transport` (`Recommended`; `tcp` for HTTP, `pipe` for stdio), `network.protocol.name` / `network.protocol.version` (`Recommended` where applicable)\n- `mcp.session.id`, `mcp.protocol.version` (`Recommended`)\n- `gen_ai.tool.name` (`Conditionally Required` when the operation relates to a specific tool, i.e. every `tools/call`) and `gen_ai.operation.name` (`Recommended`). Both were added to the server-side `OpenTelemetryMiddleware` in #2970 but are still missing on the client span.\n\n`server.address` / `server.port` are the important ones here: with them, a span-metrics or service-graph processor can break tool calls down by server with no client-side changes.\n\n**Implementation note.** I realise the dispatcher is transport-agnostic and doesn't know the URL. The TODO right there (`move the otel span + inject into an outbound middleware once that seam exists`) and #3715 point in the same direction. Some options:\n\n- The transport could expose connection metadata (address, port, transport kind) to the session/dispatcher when it's created, and the dispatcher adds it to every outbound span. For Streamable HTTP this comes from the URL; for stdio, `server.address` doesn't apply but `network.transport=pipe` (and perhaps the command name) does.\n- Or this lands as part of the client-side outbound seam proposed in #3715.\n\nA smaller stopgap that would also help: an optional, user-supplied set of extra span attributes on `Client` / `ClientSession` (e.g. `Client(..., otel_attributes={\"server.address\": ...})`), so applications like Open WebUI can tag spans with the connection they already know about.\n\n### References\n\n- GenAI MCP semantic conventions, client span attributes: https://github.com/open-telemetry/semantic-conventions-genai/blob/main/docs/gen-ai/mcp.md\n- #2387: open PR adding `rpc.*`, `mcp.resource.uri`, `mcp.session.id` to client/server spans (related, but no server identity)\n- #2970: merged, GenAI semconv attributes on the server-side middleware only\n- #3715: client outbound request seam, the natural home for transport-aware span enrichment\n- #1233: middleware support\n","author":{"url":"https://github.com/mihai-dinculescu","@type":"Person","name":"mihai-dinculescu"},"datePublished":"2026-11-08T11:15:38Z","url":"https://github.com/modelcontextprotocol/python-sdk/issues/3836"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:533a23ba-f204-217e-5de9-febea3b5dd1b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D16C:248DA8:2B5475B:3900AB1:6B0568AB |
| html-safe-nonce | 171e18974eab02369d0e05932dba1742e83af33b3ad01d32b04668db96eff618 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMTZDOjI0OERBODoyQjU0NzVCOjM5MDBBQjE6NkIwNTY4QUIiLCJ2aXNpdG9yX2lkIjoiNzg4MTY4NDgzOTE2ODM0OTg3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | b4deea6df6e678f281ae5fd6f138a7875ec97274202287654eb49086b33c8de5 |
| hovercard-subject-tag | issue:6270343655 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/modelcontextprotocol/python-sdk/3836/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a40e0e16cda927b9112d99e0e96e8620e9697776e80d6744bfdb9e1a19aa0b18/modelcontextprotocol/python-sdk/issues/3836 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a40e0e16cda927b9112d99e0e96e8620e9697776e80d6744bfdb9e1a19aa0b18/modelcontextprotocol/python-sdk/issues/3836 |
| og:image:alt | Description The MCP send |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mihai-dinculescu |
| hostname | github.com |
| expected-hostname | github.com |
| None | 1be5cc09efdd4833c24a4ffa71d698e3999fa09071e159fe14c2c08e41c98331 |
| turbo-cache-control | no-preview |
| go-import | github.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git |
| octolytics-dimension-user_id | 182288589 |
| octolytics-dimension-user_login | modelcontextprotocol |
| octolytics-dimension-repository_id | 862584018 |
| octolytics-dimension-repository_nwo | modelcontextprotocol/python-sdk |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 862584018 |
| octolytics-dimension-repository_network_root_nwo | modelcontextprotocol/python-sdk |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f6d69234e682c947a48074340e69d45d5901de31 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width