Skip to content

fix: add newline="" to stdio TextIOWrapper to prevent CRLF on Windows#2440

Open
Christian-Sidak wants to merge 1 commit intomodelcontextprotocol:mainfrom
Christian-Sidak:fix/stdio-crlf-windows
Open

fix: add newline="" to stdio TextIOWrapper to prevent CRLF on Windows#2440
Christian-Sidak wants to merge 1 commit intomodelcontextprotocol:mainfrom
Christian-Sidak:fix/stdio-crlf-windows

Conversation

@Christian-Sidak
Copy link
Copy Markdown

Summary

  • Adds newline="" to both TextIOWrapper instances in stdio_server() to disable platform-dependent newline translation
  • On Windows, Python's default newline=None translates \n to \r\n on write, corrupting NDJSON messages
  • newline="" is a no-op on Linux/macOS, so this is safe cross-platform
  • Adds test verifying raw output bytes use LF not CRLF

Closes #2433

Test plan

  • New test asserts raw stdio output ends with \n, not \r\n
  • Verify on Windows that JSON-RPC messages are no longer corrupted

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