René's URL Explorer Experiment


Title: FastMCP/stdio: in-flight tool responses dropped on stdin EOF when input is bash-redirected from a file · Issue #2678 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: FastMCP/stdio: in-flight tool responses dropped on stdin EOF when input is bash-redirected from a file · Issue #2678 · modelcontextprotocol/python-sdk

X Title: FastMCP/stdio: in-flight tool responses dropped on stdin EOF when input is bash-redirected from a file · Issue #2678 · modelcontextprotocol/python-sdk

Description: 1. Initial Checks I have searched the issue tracker for similar bugs (closest existing: #1933, but that's about premature close of real stdio during shutdown — different failure layer) I am using a supported MCP SDK version (pinned mcp>=...

Open Graph Description: 1. Initial Checks I have searched the issue tracker for similar bugs (closest existing: #1933, but that's about premature close of real stdio during shutdown — different failure layer) I am using a...

X Description: 1. Initial Checks I have searched the issue tracker for similar bugs (closest existing: #1933, but that's about premature close of real stdio during shutdown — different failure layer) I am usi...

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

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.114.3


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"FastMCP/stdio: in-flight tool responses dropped on stdin EOF when input is bash-redirected from a file","articleBody":"**1. Initial Checks**\n- [x] I have searched the issue tracker for similar bugs (closest existing: #1933, but that's about premature close of *real* stdio during shutdown — different failure layer)\n- [x] I am using a supported MCP SDK version (pinned `mcp>=1.27,\u003c2`)\n\n**2. Description**\n\n*Triage note: checked `jlowin/fastmcp` (now PrefectHQ fork) — FastMCP's server-side stdio delegates to `mcp.server.stdio` via a transport mixin, so the bug belongs here in the SDK rather than in the FastMCP wrapper.*\n\nWhen driving a FastMCP stdio server with a file-redirected stdin (e.g. `python -m my_server \u003c payload.jsonl > response.jsonl`), in-flight tool-call responses can be dropped if their response writer hasn't been scheduled when stdin EOF arrives.\n\nThe stdio read loop appears to treat stdin EOF as an immediate-shutdown signal, cancelling pending writer tasks before they flush their JSON-RPC responses to stdout. The failure is silent — no traceback, no log line, the response is simply absent from stdout.\n\n**Expected:** All responses for processed requests appear on stdout before the server exits.\n**Actual:** Responses for the last-issued requests can be missing entirely.\n\n**3. Example Code (minimal reproducible)**\n\n```python\n# server.py\nfrom mcp.server.fastmcp import FastMCP\nimport asyncio\n\nmcp = FastMCP(\"repro\")\n\n@mcp.tool()\nasync def slow_echo(text: str) -> str:\n    await asyncio.sleep(0.05)  # guaranteed yield point so writer scheduling is observable\n    return text\n\nif __name__ == \"__main__\":\n    mcp.run(transport=\"stdio\")\n```\n\n```jsonl\n# payload.jsonl\n{\"jsonrpc\":\"2.0\",\"id\":0,\"method\":\"initialize\",\"params\":{\"protocolVersion\":\"2024-11-05\",\"capabilities\":{},\"clientInfo\":{\"name\":\"repro\",\"version\":\"0.1\"}}}\n{\"jsonrpc\":\"2.0\",\"method\":\"notifications/initialized\",\"params\":{}}\n{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/call\",\"params\":{\"name\":\"slow_echo\",\"arguments\":{\"text\":\"first\"}}}\n{\"jsonrpc\":\"2.0\",\"id\":2,\"method\":\"tools/call\",\"params\":{\"name\":\"slow_echo\",\"arguments\":{\"text\":\"second\"}}}\n```\n\n```bash\npython server.py \u003c payload.jsonl > response.jsonl\n# Observed: response.jsonl contains id=0 + id=1 results, id=2 is absent.\n```\n\n*The race is timing-sensitive; if id=2 surfaces on the first run, increase the `asyncio.sleep` delay or run repeatedly. We saw it deterministically in production where the tool body did a real HTTP call (~50-200ms).*\n\n**Diagnostic fingerprint:** the difference between this transport race and a quality bug in the tool itself is *absence-of-response* vs *response-with-empty-result*. If you ever see `id=N` missing entirely (not `{\"id\":N,\"result\":[]}`), suspect this race.\n\n**4. Python and MCP Python SDK**\n\n- Python: 3.12 (`python:3.12-slim` Docker base)\n- MCP SDK: 1.27.x (`mcp>=1.27,\u003c2`)\n- OS: Linux (Debian Bookworm; reproduced on Synology DSM 7.2 host)\n- Transport: stdio via `mcp.run(transport=\"stdio\")`\n\n**Workaround we shipped (in case it helps the fix design):** wrote a Python driver that owns both pipes via `subprocess.Popen(stdin=PIPE, stdout=PIPE)` and refuses to close stdin until the response for the last-issued id is observed on stdout. ~140 lines stdlib-only.\n\n**Suggested fix:** before exiting on stdin EOF, await any pending writer tasks (with a small timeout) so their JSON-RPC responses reach stdout before the process terminates.\n","author":{"url":"https://github.com/theone139344","@type":"Person","name":"theone139344"},"datePublished":"2026-05-25T14:25:01Z","url":"https://github.com/modelcontextprotocol/python-sdk/issues/2678"}

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:29c45e51-92a8-e676-8973-5b6df901ae4f
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA22A:1514D:59F4F7:7BB62A:6B04749C
html-safe-nonce6309eb19bb792350c48c04994b7191df0e3cfac1ea693f12482d20bb57119303
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMjJBOjE1MTREOjU5RjRGNzo3QkI2MkE6NkIwNDc0OUMiLCJ2aXNpdG9yX2lkIjoiNTYwMzkwODAzNzc5OTg2NzU0OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac852fd55822d7b2ac4ea37ecc820a14ca8b159a0937b2513b09e8d4f3e9edf1a3
hovercard-subject-tagissue:4517587555
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/2678/issue_layout
twitter:imagehttps://opengraph.githubassets.com/b8da3d3b668333e6d437b1b1c23d168c2c1b73da9f4b916fcf03d8f1dd94ccf0/modelcontextprotocol/python-sdk/issues/2678
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/b8da3d3b668333e6d437b1b1c23d168c2c1b73da9f4b916fcf03d8f1dd94ccf0/modelcontextprotocol/python-sdk/issues/2678
og:image:alt1. Initial Checks I have searched the issue tracker for similar bugs (closest existing: #1933, but that's about premature close of real stdio during shutdown — different failure layer) I am using a...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernametheone139344
hostnamegithub.com
expected-hostnamegithub.com
None9c099f1b85def81ca352464c276510dfef32deaf3c305404e65b8d270284a58b
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
releasecf73f57448d52b3a7b619195e182b33d3b3454ca
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/modelcontextprotocol/python-sdk/issues/2678#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2F2678
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://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2F2678
Sign uphttps://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://github.com/modelcontextprotocol/python-sdk/issues/2678
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/2678
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/2678
modelcontextprotocolhttps://github.com/modelcontextprotocol
python-sdkhttps://github.com/modelcontextprotocol/python-sdk
Codehttps://github.com/modelcontextprotocol/python-sdk
Issues320 (320)https://github.com/modelcontextprotocol/python-sdk/issues
Pull requests112 (112)https://github.com/modelcontextprotocol/python-sdk/pulls
Actionshttps://github.com/modelcontextprotocol/python-sdk/actions
Projectshttps://github.com/modelcontextprotocol/python-sdk/projects
Security and quality12 (12)https://github.com/modelcontextprotocol/python-sdk/security
Insightshttps://github.com/modelcontextprotocol/python-sdk/insights
https://github.com/modelcontextprotocol/python-sdk
New issuehttps://github.com/login?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/2678
New issuehttps://github.com/login?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/2678
#2680https://github.com/modelcontextprotocol/python-sdk/pull/2680
FastMCP/stdio: in-flight tool responses dropped on stdin EOF when input is bash-redirected from a filehttps://github.com/modelcontextprotocol/python-sdk/issues/2678#top
#2680https://github.com/modelcontextprotocol/python-sdk/pull/2680
P2Moderate issues affecting some users, edge cases, potentially valuable featurehttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22P2%22
bugSomething isn't workinghttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22bug%22
ready for workEnough information for someone to start working onhttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22ready%20for%20work%22
https://github.com/theone139344
theone139344https://github.com/theone139344
on May 25, 2026https://github.com/modelcontextprotocol/python-sdk/issues/2678#issue-4517587555
Using transport="stdio" closes real stdio, causing ValueError after server exits #1933https://github.com/modelcontextprotocol/python-sdk/issues/1933
https://github.com/Asti1982
Asti1982https://github.com/Asti1982
on May 26, 2026https://github.com/modelcontextprotocol/python-sdk/issues/2678#issuecomment-4539819332
maxisbeyhttps://github.com/maxisbey
triageQueued for automated analysis — bot will process and remove this labelhttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22triage%22
on May 31, 2026https://github.com/modelcontextprotocol/python-sdk/issues/2678#event-26153492900
bugSomething isn't workinghttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22bug%22
on Jun 1, 2026https://github.com/modelcontextprotocol/python-sdk/issues/2678#event-26184196522
ready for workEnough information for someone to start working onhttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22ready%20for%20work%22
on Jun 1, 2026https://github.com/modelcontextprotocol/python-sdk/issues/2678#event-26184196552
P2Moderate issues affecting some users, edge cases, potentially valuable featurehttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22P2%22
on Jun 1, 2026https://github.com/modelcontextprotocol/python-sdk/issues/2678#event-26184196579
triageQueued for automated analysis — bot will process and remove this labelhttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22triage%22
on Jun 1, 2026https://github.com/modelcontextprotocol/python-sdk/issues/2678#event-26184197805
https://github.com/norika1207-lab
norika1207-labhttps://github.com/norika1207-lab
on Jun 2, 2026https://github.com/modelcontextprotocol/python-sdk/issues/2678#issuecomment-4598500572
https://github.com/TimeToBuildBob
TimeToBuildBobhttps://github.com/TimeToBuildBob
on Jul 10, 2026https://github.com/modelcontextprotocol/python-sdk/issues/2678#issuecomment-4931930973
https://github.com/rudidev08
rudidev08https://github.com/rudidev08
on Aug 10, 2026https://github.com/modelcontextprotocol/python-sdk/issues/2678#issuecomment-5244138811
https://github.com/ace-trump-tech
ace-trump-techhttps://github.com/ace-trump-tech
on Aug 31, 2026https://github.com/modelcontextprotocol/python-sdk/issues/2678#issuecomment-5476198626
Using transport="stdio" closes real stdio, causing ValueError after server exits #1933https://github.com/modelcontextprotocol/python-sdk/issues/1933
https://github.com/BoltyBolterson
BoltyBoltersonhttps://github.com/BoltyBolterson
on Sep 11, 2026https://github.com/modelcontextprotocol/python-sdk/issues/2678#issuecomment-5640743300
https://github.com/sairam0424
sairam0424https://github.com/sairam0424
on Sep 14, 2026https://github.com/modelcontextprotocol/python-sdk/issues/2678#issuecomment-5668791978
#2680https://github.com/modelcontextprotocol/python-sdk/pull/2680
#2682https://github.com/modelcontextprotocol/python-sdk/pull/2682
#2815https://github.com/modelcontextprotocol/python-sdk/pull/2815
#2821https://github.com/modelcontextprotocol/python-sdk/pull/2821
#3026https://github.com/modelcontextprotocol/python-sdk/pull/3026
#3421https://github.com/modelcontextprotocol/python-sdk/pull/3421
sairam0424https://github.com/sairam0424
on Sep 14, 2026https://github.com/modelcontextprotocol/python-sdk/issues/2678#event-31122129944
docs: note the mcp SDK stdin-EOF known limitation (#37)https://github.com/mcpsmiths/cost-guard-mcp/commit/a73500ed574146c24a6679a0e10c26bcac30338b
#37https://github.com/mcpsmiths/cost-guard-mcp/pull/37
a73500ehttps://github.com/mcpsmiths/cost-guard-mcp/commit/a73500ed574146c24a6679a0e10c26bcac30338b
Zac-HDhttps://github.com/Zac-HD
on Sep 17, 2026https://github.com/modelcontextprotocol/python-sdk/issues/2678#event-31347658998
stdio: answer every request read before stdin EOF, stop at once when …https://github.com/Zac-HD/python-sdk/commit/4611fa727b73c6cd42b7a642a7fcd523cc6fbde7
4611fa7https://github.com/Zac-HD/python-sdk/commit/4611fa727b73c6cd42b7a642a7fcd523cc6fbde7
https://github.com/Rishankgupta08
Rishankgupta08https://github.com/Rishankgupta08
on Nov 15, 2026https://github.com/modelcontextprotocol/python-sdk/issues/2678#issuecomment-6888482035
Sign up for freehttps://github.com/signup?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/2678
Sign in to commenthttps://github.com/login?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/2678
P2Moderate issues affecting some users, edge cases, potentially valuable featurehttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22P2%22
bugSomething isn't workinghttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22bug%22
ready for workEnough information for someone to start working onhttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22ready%20for%20work%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.