Error responses carry "id": null, which the MCP schema does not allow
维护者通常 1 天内回复
评估
调研方向
Start with the error builders json_rpc_error_response and invalid_request_response, then JsonRpcHandler.error_response, and trace where handle_json and StreamableHTTPTransport#handle_request produce "id": null. Run the repro in the issue, then the tests that assert id: null on purpose. Done means error responses omit id when the request id cannot be read, those tests are updated, and the output validates against the MCP JSONRPCErrorResponse schema.
由索引模型根据 Issue 内容生成。
描述
When the server can't read a request's id, its error response has "id": null. Plain JSON-RPC 2.0 asks for that, and the tests say it's on purpose. MCP narrows it, though: the id of an error response is optional and, if present, a string or an integer.
- Error responses MUST include the same ID as the request they correspond to (except in error cases where the ID could not be read due a malformed request).
The shape right above it is id?: string | number (Basic Protocol, Error Responses, same in 2026-07-28), and JSONRPCErrorResponse in schema.json has id as an optional RequestId. So these responses don't validate against the schema.
With 1.7.0 (main at 9d12f51 is the same):
server = MCP::Server.new(name: "repro", version: "1.0.0", tools: [], capabilities: { tools: {} })
server.handle_json('{"jsonrpc":"2.0","id":true,"method":"tools/list"}')
# => {"jsonrpc":"2.0","id":null,"error":{"code":-32600,"message":"Invalid Request","data":"Request ID must match validation pattern, or be an integer or null"}}
transport = MCP::Server::Transports::StreamableHTTPTransport.new(server, stateless: true, enable_json_response: true)
env = Rack::MockRequest.env_for("/mcp", method: "POST", input: '{"jsonrpc":"2.0","id":1,"method":"tools/list"}', "CONTENT_TYPE" => "text/plain", "HTTP_ACCEPT" => "application/json")
transport.handle_request(Rack::Request.new(env)).last.first
# => {"jsonrpc":"2.0","id":null,"error":{"code":-32600,"message":"Unsupported Media Type: Content-Type must be application/json"}}
The other HTTP-level errors (406, 405, a body that isn't an object, ...) go through the same json_rpc_error_response and invalid_request_response. The refusal in #605 would follow too, since it goes through JsonRpcHandler.error_response.
Leaving id out when it's unknown would match the schema. The TypeScript SDK sends id: null in the same places, so it's a question of which spec wins; I'd go with the MCP schema, since that's what implementations get checked against (the conformance suite's wire-schema-valid check, for example). I'll open a PR with the change.
- 主要语言
- Ruby
- 星标
- 924
- 派生
- 136
- 平均合并
- 1 天 9 小时
- 30 天内合并 PR
- 38
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
modelcontextprotocol/ruby-sdk 的其他 Issue
-
Empty members in the Accept header cause a 500可能已有人在做 @koic 于 4 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 82/100
modelcontextprotocol/ruby-sdk#609 ·
维护者通常 1 天内回复
-
Default capabilities advertise listChanged, prompts, resources and logging on a tools-only stateless server可能已有人在做 @koic 于 2 天前认领。 未关闭bug
难度 3/5 1-2 天 新手友好度 56/100
modelcontextprotocol/ruby-sdk#619 ·
维护者通常 1 天内回复
-
String request ids are limited to letters, digits, "_" and "-"可能已有人在做 @koic 于 4 天前认领。 未关闭bug
modelcontextprotocol/ruby-sdk#603 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Support modelcontextprotocol/experimental-ext-triggers-events可能已有人在做 @koic 于 8 天前认领。 未关闭enhancement
modelcontextprotocol/ruby-sdk#594 · 已指派 1 人 ·
维护者通常 1 天内回复
-
SEP-2640: Skills Extension可能已有人在做 @koic 于 26 天前认领。 未关闭enhancement
modelcontextprotocol/ruby-sdk#568 · 1 条评论 · 2 个 reaction · 已指派 1 人 ·
维护者通常 1 天内回复
查看 modelcontextprotocol/ruby-sdk 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 61/100
hitobito/hitobito_pfadi_de#164 ·
维护者通常 5 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 7 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 2 天内回复
-
Windows: packaged_agent_ruby? never matches 'Puppet Labs\Puppet', so the openvox gem is not found未关闭
难度 2/5 1-3 小时 新手友好度 85/100
-
难度 1/5 1 小时以内 新手友好度 68/100
维护者通常 17 天内回复