René's URL Explorer Experiment


Title: [v2] JSON-RPC error responses leave client OpenTelemetry spans UNSET · Issue #3174 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: [v2] JSON-RPC error responses leave client OpenTelemetry spans UNSET · Issue #3174 · modelcontextprotocol/python-sdk

X Title: [v2] JSON-RPC error responses leave client OpenTelemetry spans UNSET · Issue #3174 · modelcontextprotocol/python-sdk

Description: Initial Checks I confirm that I'm using the latest version of MCP Python SDK I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue Description At current main (11934...

Open Graph Description: Initial Checks I confirm that I'm using the latest version of MCP Python SDK I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this ...

X Description: Initial Checks I confirm that I'm using the latest version of MCP Python SDK I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening t...

Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/issues/3174

X: @github

direct link

Domain: redirect.github.com

IPv4 address: 140.82.114.4


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[v2] JSON-RPC error responses leave client OpenTelemetry spans UNSET","articleBody":"### Initial Checks\n\n- [x] I confirm that I'm using the latest version of MCP Python SDK\n- [x] I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue\n\n### Description\n\nAt current `main` (`11934c90aeff5e1e68aee223edd00c5d1fce1d5c`), JSON-RPC error responses handled by `JSONRPCDispatcher` leave the corresponding client OpenTelemetry span looking like a normal exit:\n\n- span status: `UNSET`\n- `error.type`: absent\n- `rpc.response.status_code`: absent\n- exception events: none\n\nThe request still fails correctly with `MCPError`; this report is limited to client-side telemetry correctness.\n\nThe ordering appears to explain the result: [`send_raw_request()`](https://github.com/modelcontextprotocol/python-sdk/blob/11934c90aeff5e1e68aee223edd00c5d1fce1d5c/src/mcp/shared/jsonrpc_dispatcher.py#L368-L434) receives `outcome` inside the client span, exits the span, and only afterward converts `ErrorData` into `MCPError` at lines 432–433. The span context manager therefore observes no exception.\n\nThis differs from the current [server OTel middleware](https://github.com/modelcontextprotocol/python-sdk/blob/11934c90aeff5e1e68aee223edd00c5d1fce1d5c/src/mcp/server/_otel.py#L35-L60), which records the error attributes and status, and from the design assumption documented in [#2381](https://github.com/modelcontextprotocol/python-sdk/pull/2381) that a propagated `MCPError` would be recorded by the client span.\n\nI ran the same in-memory success/error pair five times. Every run produced:\n\n```text\nMETHOD=resources/list CONTROL=UNSET RED_CODE=-32602 RED_MESSAGE='forced failure' RED_STATUS=UNSET ERROR_TYPE=None RPC_STATUS=None EVENTS=0\n```\n\nExpected: the failed client span should be distinguishable from the successful control and carry the JSON-RPC error code/status consistently with the SDK's server-side instrumentation.\n\nScope and claim boundary: this concerns JSON-RPC/stream-backed dispatcher calls, not direct in-process dispatch generally. The reproducer is entirely in-memory. I have not tested or claimed anything about a deployed transport, collector, or production frequency.\n\nClosest adjacent work found: #2132 targets the removed `BaseSession` architecture and predates the current dispatcher; #2854 adds GenAI attributes but does not handle JSON-RPC errors. I did not find an issue or current PR covering this ordering on the present dispatcher.\n\nDisclosure: I used AI assistance to help reproduce and analyze this issue. I reviewed the source, reran the evidence independently, and take responsibility for the report.\n\n### Example Code\n\n```Python\nfrom opentelemetry import trace\nfrom opentelemetry.sdk.trace import TracerProvider\nfrom opentelemetry.sdk.trace.export import SimpleSpanProcessor\nfrom opentelemetry.sdk.trace.export.in_memory_span_exporter import InMemorySpanExporter\nfrom opentelemetry.trace import SpanKind\n\nexporter = InMemorySpanExporter()\nprovider = TracerProvider()\nprovider.add_span_processor(SimpleSpanProcessor(exporter))\ntrace.set_tracer_provider(provider)\n\nimport anyio\nfrom mcp.client.client import Client\nfrom mcp.server.lowlevel.server import Server\nfrom mcp.shared.exceptions import MCPError\nfrom mcp_types import INVALID_PARAMS, ListResourcesResult\n\nstate = {\"fail\": False}\n\nasync def list_resources(ctx, params):\n    if state[\"fail\"]:\n        raise MCPError(INVALID_PARAMS, \"forced failure\")\n    return ListResourcesResult(resources=[])\n\nasync def main():\n    server = Server(name=\"otel-audit\", version=\"0.0.0\", on_list_resources=list_resources)\n    async with Client(server, mode=\"legacy\", cache=None) as client:\n        state[\"fail\"] = False\n        exporter.clear()\n        await client.session.list_resources()\n        [control] = [s for s in exporter.get_finished_spans() if s.kind == SpanKind.CLIENT]\n\n        state[\"fail\"] = True\n        exporter.clear()\n        try:\n            await client.session.list_resources()\n        except MCPError as exc:\n            assert exc.error.code == INVALID_PARAMS\n        else:\n            raise AssertionError(\"expected MCPError\")\n\n        [failed] = [s for s in exporter.get_finished_spans() if s.kind == SpanKind.CLIENT]\n        print(\n            \"control=\", control.status.status_code.name,\n            \"failed=\", failed.status.status_code.name,\n            \"error.type=\", failed.attributes.get(\"error.type\"),\n            \"rpc.response.status_code=\", failed.attributes.get(\"rpc.response.status_code\"),\n            \"events=\", len(failed.events),\n        )\n        assert control.name == failed.name == \"MCP send resources/list\"\n        assert failed.status.status_code.name == \"UNSET\"\n        assert failed.attributes.get(\"error.type\") is None\n        assert failed.attributes.get(\"rpc.response.status_code\") is None\n        assert len(failed.events) == 0\n\nanyio.run(main)\n```\n\n### Python & MCP Python SDK\n\n```Text\nPython: 3.12.10\nmcp: 2.0.0b2.dev33+11934c90\nopentelemetry-sdk: 1.39.1\nOS: Windows 11\n\nClean checkout command:\nuv run --python 3.12 --frozen --no-default-groups --with opentelemetry-sdk==1.39.1 python repro.py\n```","author":{"url":"https://github.com/HarperZ9","@type":"Person","name":"HarperZ9"},"datePublished":"2026-07-26T04:29:12Z","url":"https://github.com/modelcontextprotocol/python-sdk/issues/3174"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:90466bde-bd44-6057-61fa-ccc4c035eb9b
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idDC90:E6B97:F17239:14BB5E3:6B055D26
html-safe-nonce2164a7a9ae0682fcdfbe04a377d816115e420e88fba43b87dc059b5305f33c6e
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQzkwOkU2Qjk3OkYxNzIzOToxNEJCNUUzOjZCMDU1RDI2IiwidmlzaXRvcl9pZCI6Ijc3MDc0NDMxMjY5ODA2ODI2MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac7e14a3ef52818e673e6c8794f4fd7202a2b9d6be5eedbae88bce225377b02613
hovercard-subject-tagissue:4979103793
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/modelcontextprotocol/python-sdk/3174/issue_layout
twitter:imagehttps://opengraph.githubassets.com/16821d0684c962dd1250f10d01c116ea0c507ff394026e37ad83008efaeb0dfe/modelcontextprotocol/python-sdk/issues/3174
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/16821d0684c962dd1250f10d01c116ea0c507ff394026e37ad83008efaeb0dfe/modelcontextprotocol/python-sdk/issues/3174
og:image:altInitial Checks I confirm that I'm using the latest version of MCP Python SDK I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameHarperZ9
hostnamegithub.com
expected-hostnamegithub.com
None8a6760da3cce5e2d079d07e3b62df71194316c4478db1a5e38050f44fce72c72
turbo-cache-controlno-preview
go-importgithub.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git
octolytics-dimension-user_id182288589
octolytics-dimension-user_loginmodelcontextprotocol
octolytics-dimension-repository_id862584018
octolytics-dimension-repository_nwomodelcontextprotocol/python-sdk
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id862584018
octolytics-dimension-repository_network_root_nwomodelcontextprotocol/python-sdk
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8327739ac0648b9c3c722b5f401f7338553936b8
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://redirect.github.com/modelcontextprotocol/python-sdk/issues/3174#start-of-content
https://redirect.github.com/
Sign inhttps://redirect.github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2F3174
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://redirect.github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2F3174
Sign uphttps://redirect.github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=modelcontextprotocol%2Fpython-sdk
Reloadhttps://redirect.github.com/modelcontextprotocol/python-sdk/issues/3174
Reloadhttps://redirect.github.com/modelcontextprotocol/python-sdk/issues/3174
Reloadhttps://redirect.github.com/modelcontextprotocol/python-sdk/issues/3174
modelcontextprotocolhttps://redirect.github.com/modelcontextprotocol
python-sdkhttps://redirect.github.com/modelcontextprotocol/python-sdk
Codehttps://redirect.github.com/modelcontextprotocol/python-sdk
Issues320 (320)https://redirect.github.com/modelcontextprotocol/python-sdk/issues
Pull requests112 (112)https://redirect.github.com/modelcontextprotocol/python-sdk/pulls
Actionshttps://redirect.github.com/modelcontextprotocol/python-sdk/actions
Projectshttps://redirect.github.com/modelcontextprotocol/python-sdk/projects
Security and quality12 (12)https://redirect.github.com/modelcontextprotocol/python-sdk/security
Insightshttps://redirect.github.com/modelcontextprotocol/python-sdk/insights
https://redirect.github.com/modelcontextprotocol/python-sdk
New issuehttps://redirect.github.com/login?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/3174
New issuehttps://redirect.github.com/login?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/3174
#3629https://github.com/modelcontextprotocol/python-sdk/pull/3629
[v2] JSON-RPC error responses leave client OpenTelemetry spans UNSEThttps://redirect.github.com/modelcontextprotocol/python-sdk/issues/3174#top
#3629https://github.com/modelcontextprotocol/python-sdk/pull/3629
P2https://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22P2%22
bughttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22bug%22
needs confirmationhttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22needs%20confirmation%22
v2https://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v2%22
https://github.com/HarperZ9
HarperZ9https://github.com/HarperZ9
on Jul 26, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3174#issue-4979103793
https://github.com/modelcontextprotocol/python-sdk/issueshttps://github.com/modelcontextprotocol/python-sdk/issues
send_raw_request()https://github.com/modelcontextprotocol/python-sdk/blob/11934c90aeff5e1e68aee223edd00c5d1fce1d5c/src/mcp/shared/jsonrpc_dispatcher.py#L368-L434
server OTel middlewarehttps://github.com/modelcontextprotocol/python-sdk/blob/11934c90aeff5e1e68aee223edd00c5d1fce1d5c/src/mcp/server/_otel.py#L35-L60
#2381https://github.com/modelcontextprotocol/python-sdk/pull/2381
#2132https://github.com/modelcontextprotocol/python-sdk/pull/2132
#2854https://github.com/modelcontextprotocol/python-sdk/pull/2854
https://redirect.github.com/Ranga-Prasath-22
Ranga-Prasath-22https://redirect.github.com/Ranga-Prasath-22
on Jul 26, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3174#issuecomment-5082231607
https://redirect.github.com/chavalasantosh
chavalasantoshhttps://redirect.github.com/chavalasantosh
on Jul 29, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3174#issuecomment-5121705986
https://redirect.github.com/Ecocitizenz
Ecocitizenzhttps://redirect.github.com/Ecocitizenz
on Jul 29, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3174#issuecomment-5122895897
https://redirect.github.com/chavalasantosh
chavalasantoshhttps://redirect.github.com/chavalasantosh
on Jul 29, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3174#issuecomment-5122958294
@Ecocitizenzhttps://github.com/Ecocitizenz
https://redirect.github.com/HarperZ9
HarperZ9https://redirect.github.com/HarperZ9
on Aug 3, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3174#issuecomment-5171195377
@Ranga-Prasath-22https://github.com/Ranga-Prasath-22
https://redirect.github.com/Ecocitizenz
Ecocitizenzhttps://redirect.github.com/Ecocitizenz
on Aug 4, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3174#issuecomment-5182403525
https://redirect.github.com/Ecocitizenz
Ecocitizenzhttps://redirect.github.com/Ecocitizenz
on Aug 4, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3174#issuecomment-5182438243
maxisbeyhttps://redirect.github.com/maxisbey
bughttps://redirect.github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22bug%22
P2https://redirect.github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22P2%22
needs confirmationhttps://redirect.github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22needs%20confirmation%22
v2https://redirect.github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v2%22
on Aug 14, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3174#event-29453936382
https://redirect.github.com/mikemikimike
mikemikimikehttps://redirect.github.com/mikemikimike
on Aug 27, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3174#issuecomment-5434262976
#3401https://github.com/modelcontextprotocol/python-sdk/pull/3401
https://redirect.github.com/mikemikimike
mikemikimikehttps://redirect.github.com/mikemikimike
on Aug 27, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3174#issuecomment-5435083154
#3401https://github.com/modelcontextprotocol/python-sdk/pull/3401
maxisbeyhttps://redirect.github.com/maxisbey
completedhttps://redirect.github.com/modelcontextprotocol/python-sdk/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#3629https://github.com/modelcontextprotocol/python-sdk/pull/3629
on Oct 2, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3174#event-32338808673
https://redirect.github.com/maxisbey
maxisbeyhttps://redirect.github.com/maxisbey
on Oct 2, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3174#issuecomment-5957089973
#3629https://github.com/modelcontextprotocol/python-sdk/pull/3629
AI Disclaimerhttps://gist.github.com/maxisbey/6123d132484e4c533eab519a2800693d
Sign up for freehttps://redirect.github.com/signup?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/3174
Sign in to commenthttps://redirect.github.com/login?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/3174
P2https://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22P2%22
bughttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22bug%22
needs confirmationhttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22needs%20confirmation%22
v2https://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v2%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.