Skip to content

Fix #1933: Using transport="stdio" closes real stdio, causing ValueError after se#2538

Open
sherlock-488 wants to merge 3 commits intomodelcontextprotocol:mainfrom
sherlock-488:deep-pr-forge/1933-using-transport-stdio-closes-real-stdio-caus
Open

Fix #1933: Using transport="stdio" closes real stdio, causing ValueError after se#2538
sherlock-488 wants to merge 3 commits intomodelcontextprotocol:mainfrom
sherlock-488:deep-pr-forge/1933-using-transport-stdio-closes-real-stdio-caus

Conversation

@sherlock-488
Copy link
Copy Markdown

Fixes #1933

Stdio_server() wraps sys.stdin.buffer/sys.stdout.buffer directly, causing the real stdio file descriptors to be closed when the context manager exits, making subsequent I/O raise ValueError.

I also updated the relevant tests for this path.

Tests:

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

I used an AI assistant while preparing the patch, and manually reviewed the diff and test results before opening this PR.

sherlock-488 and others added 3 commits May 4, 2026 04:06
…extprotocol#2366)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Max Isbey <224885523+maxisbey@users.noreply.github.com>
…extprotocol#2366)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Max Isbey <224885523+maxisbey@users.noreply.github.com>
@sherlock-488 sherlock-488 marked this pull request as ready for review May 3, 2026 20:39
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.

Using transport="stdio" closes real stdio, causing ValueError after server exits

1 participant