Skip to content

Fix stdio server newline translation on Windows#2757

Open
yyzquwu wants to merge 1 commit into
modelcontextprotocol:mainfrom
yyzquwu:codex/windows-stdio-lf
Open

Fix stdio server newline translation on Windows#2757
yyzquwu wants to merge 1 commit into
modelcontextprotocol:mainfrom
yyzquwu:codex/windows-stdio-lf

Conversation

@yyzquwu
Copy link
Copy Markdown

@yyzquwu yyzquwu commented Jun 1, 2026

Summary

  • Disable Windows CRLF translation in stdio_server() by setting newline="" on the default stdio wrappers.
  • Add a regression test for the default stdout path so JSON-RPC frames stay LF-only.

Fixes #2433.

Verification

Windows 11, Python 3.13.13:

tests/server/test_stdio.py::test_stdio_server PASSED
tests/server/test_stdio.py::test_stdio_server_uses_lf_newlines_with_default_stdout PASSED
tests/server/test_stdio.py::test_stdio_server_invalid_utf8 PASSED
3 passed

b'{"jsonrpc":"2.0","id":3,"method":"ping"}\n'

Branch coverage for tests/server/test_stdio.py: 100.00%.

Codex review passed before commit.

@yyzquwu yyzquwu force-pushed the codex/windows-stdio-lf branch from b8992b8 to 86176c5 Compare June 1, 2026 21:32
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.

Windows: TextIOWrapper in stdio_server() emits CRLF instead of LF, corrupting newline-delimited JSON messages

1 participant