Title: FastMCP.run(transport="stdio") produces noisy traceback on KeyboardInterrupt instead of clean exit · Issue #2663 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: FastMCP.run(transport="stdio") produces noisy traceback on KeyboardInterrupt instead of clean exit · Issue #2663 · modelcontextprotocol/python-sdk
X Title: FastMCP.run(transport="stdio") produces noisy traceback on KeyboardInterrupt instead of clean exit · Issue #2663 · 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 Running a FastMCP stdi...
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/2663
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"FastMCP.run(transport=\"stdio\") produces noisy traceback on KeyboardInterrupt instead of clean exit","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\nRunning a FastMCP stdio server from the terminal and interrupting with Ctrl-C produces a multi-frame traceback through anyio.run() → asyncio.runners → mcp.server.lowlevel.server.run → anyio.streams.memory.receive. The server is correctly waiting on stdin in an async loop; the trace surfaces because anyio/asyncio don't suppress the cancellation chain. Suggested fix: catch KeyboardInterrupt (or asyncio.CancelledError at the outer boundary) inside FastMCP.run and exit cleanly. Cosmetic but reduces user confusion when testing MCP servers from the terminal.\n\n### Example Code\n\n```Python\n\n```\n\n### Python \u0026 MCP Python SDK\n\n```Text\nPython 3.13.5\nMCP Python SDK 1.27.1\n```","author":{"url":"https://github.com/MikeNjoroge","@type":"Person","name":"MikeNjoroge"},"datePublished":"2026-05-22T12:00:19.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/2663/python-sdk/issues/2663"}
| 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:a6c6dc3b-3c02-a072-0903-6c79749266aa |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B6C2:1F919D:96ADBF:D905D1:6A59F646 |
| html-safe-nonce | 684cedafd983fb8b8c4bb60fe86583e48ec2f5c9f24864261377911e83a0a47c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNkMyOjFGOTE5RDo5NkFEQkY6RDkwNUQxOjZBNTlGNjQ2IiwidmlzaXRvcl9pZCI6IjQxOTMxODM3MTk2OTQ2NjExOTAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 9e9c0a276aecea34bc500737a321a645d5d2f7d2c9ce1b5c74ec49c410cf1597 |
| hovercard-subject-tag | issue:4502422516 |
| 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/2663/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7cf656b87991a8f06b96c29afa39a870c10df489ae311351c617d4635d9f6a2f/modelcontextprotocol/python-sdk/issues/2663 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7cf656b87991a8f06b96c29afa39a870c10df489ae311351c617d4635d9f6a2f/modelcontextprotocol/python-sdk/issues/2663 |
| og:image:alt | 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 ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | MikeNjoroge |
| hostname | github.com |
| expected-hostname | github.com |
| None | ba3976babb66479b1c943a8edc0777d96157da48fadc0161f9ddb219deee8353 |
| 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 | 24801cf86623a319252348d1fd69122ad974b842 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width