Title: Adding Opentelemetry to MCP SDK · Issue #421 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: Adding Opentelemetry to MCP SDK · Issue #421 · modelcontextprotocol/python-sdk
X Title: Adding Opentelemetry to MCP SDK · Issue #421 · modelcontextprotocol/python-sdk
Description: Is your feature request related to a problem? Please describe. I would like to see Opentelemetry traces and Metrics baked into SDK. E.g. Traces emitted on all Requests from client and server side of MCP SDK. Metrics for tool/prompt/resou...
Open Graph Description: Is your feature request related to a problem? Please describe. I would like to see Opentelemetry traces and Metrics baked into SDK. E.g. Traces emitted on all Requests from client and server side o...
X Description: Is your feature request related to a problem? Please describe. I would like to see Opentelemetry traces and Metrics baked into SDK. E.g. Traces emitted on all Requests from client and server side o...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/issues/421
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Adding Opentelemetry to MCP SDK","articleBody":"**Is your feature request related to a problem? Please describe.**\n\nI would like to see Opentelemetry traces and Metrics baked into SDK. \nE.g. \n1. Traces emitted on all Requests from client and server side of MCP SDK. \n2. Metrics for tool/prompt/resource calls\n\n**Describe the solution you'd like**\n\nI am trying to use Opentelemetry sdk to add traces and metrics features.\n### Steps\n1. Creating session in client and server.\n2. Initialise tracer (Opentelemetry tracer instances) in `BaseSession` (`src/mcp/shared/session.py`).\n3. Binding trace context (`traceparent`) to `_meta` of `RequestParams.Meta` before sending request from client (`send_request` in `src/mcp/shared/session.py`)\n4. In server use the `traceparent` from received request to create new span with incoming span as parent span.\n\n**Describe alternatives you've considered**\n\nI tried to implement the same via traceloop. I was not able to get correct parent - child relationship between spans while doing so.\n\n**Additional context**\n\nI am able to achieve distributed tracing across my Agentic application and MCP server.\n\n\u003cimg width=\"1728\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/2165c7ca-6283-447b-9495-a9e9406fda4f\" /\u003e","author":{"url":"https://github.com/fali007","@type":"Person","name":"fali007"},"datePublished":"2025-04-03T12:02:53.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":19},"url":"https://github.com/421/python-sdk/issues/421"}
| 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:2683ffa8-588a-7033-3ddb-6c7e36ca8495 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DC92:2453EE:1DF19B2:2830D77:6A598A77 |
| html-safe-nonce | 17d1ce13b6d80b3f654f5bb2fcf691c6662fb2c9662273033e6ae471e80342fb |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQzkyOjI0NTNFRToxREYxOUIyOjI4MzBENzc6NkE1OThBNzciLCJ2aXNpdG9yX2lkIjoiNzEzODY2MDg3MDk3MzM5MzUyNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 53825bd66cf534feb030e365c3d3ad29aa7544aa5b4beb92aeb4ed3b5e9e6387 |
| hovercard-subject-tag | issue:2969356115 |
| 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/421/issue_layout |
| twitter:image | https://opengraph.githubassets.com/129c8d686d571e94bf690878493db06de4fcd9add56a968c6ce33ce36f36ab87/modelcontextprotocol/python-sdk/issues/421 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/129c8d686d571e94bf690878493db06de4fcd9add56a968c6ce33ce36f36ab87/modelcontextprotocol/python-sdk/issues/421 |
| og:image:alt | Is your feature request related to a problem? Please describe. I would like to see Opentelemetry traces and Metrics baked into SDK. E.g. Traces emitted on all Requests from client and server side o... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | fali007 |
| hostname | github.com |
| expected-hostname | github.com |
| None | a540949572872b935b393b36db38922db390ae71c859537d741b8f3eb7e545b5 |
| 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 | 624bb50a7497aa346bef8cc3743af408a9ea10ca |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width