Title: In-process callback failures break tool calls and notification sends · Issue #3434 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: In-process callback failures break tool calls and notification sends · Issue #3434 · modelcontextprotocol/python-sdk
X Title: In-process callback failures break tool calls and notification sends · Issue #3434 · modelcontextprotocol/python-sdk
Description: Initial Checks I confirm that I am using the newest release of the 2.x line. I confirm that I searched the issue tracker before opening this issue. Release line 2.x (current stable) Description Client(server) uses DirectDispatcher. If a ...
Open Graph Description: Initial Checks I confirm that I am using the newest release of the 2.x line. I confirm that I searched the issue tracker before opening this issue. Release line 2.x (current stable) Description Cli...
X Description: Initial Checks I confirm that I am using the newest release of the 2.x line. I confirm that I searched the issue tracker before opening this issue. Release line 2.x (current stable) Description Cli...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/issues/3434
X: @github
Domain: redirect.github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"In-process callback failures break tool calls and notification sends","articleBody":"## Initial Checks\n\n- [x] I confirm that I am using the newest release of the 2.x line.\n- [x] I confirm that I searched the issue tracker before opening this issue.\n\n## Release line\n\n2.x (current stable)\n\n## Description\n\n`Client(server)` uses `DirectDispatcher`. If a progress callback raises, that exception crosses back into server tool execution, so a tool that otherwise returns successfully fails with `UnexpectedToolError`. `DirectDispatcher` also lets an inbound notification handler exception escape back to the sender's `notify()` call.\n\nThe stream-backed `JSONRPCDispatcher` logs and contains both callback failures. I expected the in-process path to keep the same boundary: log the callback failure, but let the protocol operation continue.\n\nI have a small patch and regression tests for both paths and would like to fix this if maintainers want an outside pull request.\n\nI used GitHub Copilot CLI to inspect the dispatcher paths, write the patch, and draft this report. I verified the reproduction and tests.\n\n## Example Code\n\n```python\nimport anyio\n\nfrom mcp import Client\nfrom mcp.server.mcpserver import Context, MCPServer\n\nserver = MCPServer(\"callback-repro\")\n\n\n@server.tool()\nasync def work(context: Context) -> str:\n await context.report_progress(1, 1)\n return \"done\"\n\n\nasync def broken_progress(progress: float, total: float | None, message: str | None) -> None:\n raise RuntimeError(\"consumer failed\")\n\n\nasync def main() -> None:\n async with Client(server, mode=\"2026-07-28\") as client:\n result = await client.call_tool(\"work\", progress_callback=broken_progress)\n print(result.content[0].text)\n\n\nanyio.run(main)\n```\n\nCurrent `main` ends with:\n\n```text\nUnexpectedToolError: Error executing tool work\n```\n\nThe tool should print `done`. The callback failure should still be logged.\n\n## Verification\n\nWith only the regression tests applied to clean `main`:\n\n```console\nuv run --frozen pytest tests/shared/test_dispatcher.py \\\n -k 'progress_callback_exception_does_not_fail_request or notification_handler_exception_does_not_reach_sender' -q\n# 2 failed, 2 passed. Both DirectDispatcher cases failed.\n```\n\nWith the two callback guards applied:\n\n```console\nuv run --frozen pytest tests/shared/test_dispatcher.py \\\n -k 'progress_callback_exception_does_not_fail_request or notification_handler_exception_does_not_reach_sender' -q\n# 4 passed\n```\n\n## Python & MCP Python SDK\n\n```text\nPython 3.12.13\nmcp 2.1.1\nmcp 2.1.2.dev4+d060b36e at d060b36e1d095ef6e93e07ba5d59bb69b2ad449a\nmacOS\n```\n","author":{"url":"https://github.com/1fanwang","@type":"Person","name":"1fanwang"},"datePublished":"2026-09-03T07:11:40Z","url":"https://github.com/modelcontextprotocol/python-sdk/issues/3434"}
| 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:cb51fc71-84a3-9c50-40f7-38cd61e8e40c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9302:3F9CD1:2901A17:35CA71A:6B055D27 |
| html-safe-nonce | af5f96396213f2cb4dc5624c64c344dc52065f3ab608896c20fe8dae5f70bba5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MzAyOjNGOUNEMToyOTAxQTE3OjM1Q0E3MUE6NkIwNTVEMjciLCJ2aXNpdG9yX2lkIjoiMzUxNjcwMjAwOTUzMTM5MTI3MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 085feba96034d5fb343d924cbae08521cbd4ac841d468de52b845882d2a8fb32 |
| hovercard-subject-tag | issue:5333502826 |
| 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/3434/issue_layout |
| twitter:image | https://opengraph.githubassets.com/93f06bb58fd0c1d2d1f5950d4c3f4a3b816dc4a1a52b757fd3b255547f432ea2/modelcontextprotocol/python-sdk/issues/3434 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/93f06bb58fd0c1d2d1f5950d4c3f4a3b816dc4a1a52b757fd3b255547f432ea2/modelcontextprotocol/python-sdk/issues/3434 |
| og:image:alt | Initial Checks I confirm that I am using the newest release of the 2.x line. I confirm that I searched the issue tracker before opening this issue. Release line 2.x (current stable) Description Cli... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | 1fanwang |
| hostname | github.com |
| expected-hostname | github.com |
| None | 8a6760da3cce5e2d079d07e3b62df71194316c4478db1a5e38050f44fce72c72 |
| 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 | 8327739ac0648b9c3c722b5f401f7338553936b8 |
| 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