Fix MCP stdio framing and negotiate protocolVersion#120
Conversation
Replace LSP-style Content-Length framing with the MCP stdio transport's newline-delimited JSON on both input and output, negotiate the client's protocolVersion during initialize (latest supported: 2025-06-18), and make stdin buffering synchronous with a serial message queue so interleaved chunks cannot drop or duplicate messages. Closes #68 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 427dba1dc7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } from "../runtime/protocol/openphone-runtime-tools.mjs"; | ||
|
|
||
| const PROTOCOL_VERSION = "2025-11-25"; | ||
| export const SUPPORTED_PROTOCOL_VERSIONS = ["2025-06-18"]; |
There was a problem hiding this comment.
Preserve 2025-11-25 protocol negotiation
For clients that only advertise the current MCP protocolVersion (2025-11-25), this array makes initialize respond with 2025-06-18, after which such clients should disconnect rather than use the server. The latest MCP lifecycle spec lists 2025-11-25 as the latest version and requires echoing the requested version when the server supports it (https://modelcontextprotocol.io/specification/2025-11-25/basic/lifecycle); since the server was already advertising that version before this change and this patch does not remove any 2025-11-25-specific behavior, omitting it creates an interop regression for current clients.
Useful? React with 👍 / 👎.
Summary
Content-Lengthframing with the MCP stdio transport's newline-delimited JSON on both output and input parsing, so conforming MCP clients no longer hang against the server.protocolVersionin theinitializehandler: echo a supported client version back, otherwise respond with the latest supported version (2025-06-18, replacing the unpublished2025-11-25).-32700parse error response instead of crashing the data handler.Closes #68
Test plan
node tests/integrations/runtime-mcp-contract.mjspasses, including new protocolVersion negotiation assertions and a stdio smoke test performing a real newline-delimited JSON handshake (initialize -> notifications/initialized -> tools/list) against a spawned server process./scripts/check.shpasses from the repo root🤖 Generated with Claude Code