fix(server): prevent stdio transport from closing original stdio handles#2424
fix(server): prevent stdio transport from closing original stdio handles#2424goingforstudying-ctrl wants to merge 1 commit intomodelcontextprotocol:mainfrom
Conversation
|
Hi @jspahrsummers, just checking in on this PR. Please let me know if any changes are needed. Happy to address any feedback! |
|
Hi @maintainer, just checking in on this PR. Please let me know if any changes are needed. Happy to address any feedback! |
1 similar comment
|
Hi @maintainer, just checking in on this PR. Please let me know if any changes are needed. Happy to address any feedback! |
|
Hi @jspahrsummers and team, Just checking in on this PR again. It's been a few days since the last ping. The fix prevents stdio transport from closing original stdio handles, which could cause issues for consumers that need to continue using stdin/stdout after the MCP client/server shuts down. Please let me know if:
Happy to address any feedback. Thanks! |
|
Fixed! Added the missing to — the exception was referenced but wasn't imported. This should resolve the pre-commit / test failures. Please let me know if anything else is needed. |
|
Fixed! Added the missing |
|
Fixed the import order issue — wanted before (isort rule). The pre-commit failure was just a formatting fix, not a logic error. All tests pass. Ready for another look when you have a moment! |
Signed-off-by: goingforstudying-ctrl <goingforstudying-ctrl@users.noreply.github.com>
1d7ee27 to
f776256
Compare
Description
When using , the context manager wraps and in . When these wrappers are closed (either explicitly or when exiting the context), they also close the underlying buffers, causing subsequent stdio operations to fail with .
Changes
This PR duplicates the file descriptors before wrapping them using , so that the original stdin/stdout remain open after the transport is closed.
Before (problem):
After (fixed):
Technical Details
Fixes #1933
/cc @maintainers