pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/modelcontextprotocol/python-sdk/pull/2680

sets/actions-9111c292f95f2fb0.css" /> fix(stdio): drain responses after stdin EOF by Epochex · Pull Request #2680 · modelcontextprotocol/python-sdk · GitHub
Skip to content

fix(stdio): drain responses after stdin EOF#2680

Open
Epochex wants to merge 4 commits into
modelcontextprotocol:mainfrom
Epochex:fix/2678-stdio-drain-writes
Open

fix(stdio): drain responses after stdin EOF#2680
Epochex wants to merge 4 commits into
modelcontextprotocol:mainfrom
Epochex:fix/2678-stdio-drain-writes

Conversation

@Epochex
Copy link
Copy Markdown

@Epochex Epochex commented May 25, 2026

Fixes #2678.

When stdin hits EOF (e.g. python server.py < payload.jsonl > response.jsonl), the client is done sending requests but is still reading stdout for results. On main, BaseSession._receive_loop() closes the write stream as soon as the read stream ends, and Server.run() cancels the handler task group on transport close. That combination can cancel in-flight tool handlers before they respond, dropping the last ools/call responses.

This change lets ServerSession keep the write stream open when the read side closes, so Server.run() can drain already-started handlers and flush their responses before shutdown.

Tests:

  • uv run --frozen pytest tests/server/test_cancel_handling.py tests/server/test_stdio.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FastMCP/stdio: in-flight tool responses dropped on stdin EOF when input is bash-redirected from a file

1 participant

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy