Requests with "id": null are run like notifications
メンテナーはふだん 1 日以内に返信
評価
この issue はまだ評価されていません。
説明
I'm wiring the SDK into a Rails app (stateless Streamable HTTP, JSON responses) and noticed that a request with "id": null isn't rejected. The server treats it like a notification: the method runs, but no response is produced, so over HTTP the client gets a 202 Accepted with an empty body.
For a tool that changes data, that's a write the client never hears about. The spec rules null ids out for requests:
- Requests MUST include a string or integer ID.
- Unlike base JSON-RPC, the ID MUST NOT be
null.
(Basic Protocol, Requests, same wording in 2026-07-28)
Repro with 1.7.0 (main at 9d12f51 behaves the same):
require "mcp"
calls = 0
echo = MCP::Tool.define(
name: "echo",
description: "Echoes the text back",
input_schema: { properties: { text: { type: "string" } }, required: ["text"] },
) do |text:, server_context: nil|
calls += 1
MCP::Tool::Response.new([{ type: "text", text: text }])
end
server = MCP::Server.new(name: "repro", version: "1.0.0", tools: [echo], capabilities: { tools: {} })
server.handle_json('{"jsonrpc":"2.0","id":null,"method":"tools/call","params":{"name":"echo","arguments":{"text":"hi"}}}')
# => nil
server.handle_json('{"jsonrpc":"2.0","method":"tools/call","params":{"name":"echo","arguments":{"text":"hi"}}}')
# => nil
calls # => 2
JsonRpcHandler.valid_id? accepts nil on purpose (the error message says "or be an integer or null"), which fits plain JSON-RPC but not MCP.
The second call, without any id, is a notification by JSON-RPC rules, so it's a slightly different case. But tools/call isn't a notification in MCP, and the Streamable HTTP transport allows a server to answer a notification it can't accept with an HTTP error (e.g. 400). Running it silently seems like the riskiest option.
What I'd expect:
"id": nullis answered with Invalid Request (-32600) and the method doesn't run.- A request method sent without an id is refused, or at least not executed.
- 主要言語
- Ruby
- スター
- 924
- フォーク
- 136
- 平均マージ
- 1日 9時間
- マージ済み PR(30日)
- 38
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
modelcontextprotocol/ruby-sdk のほかの issue
-
Empty members in the Accept header cause a 500対応中かも @koic が 3 日前に担当しました。 オープン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 日以内に返信
-
Error responses carry "id": null, which the MCP schema does not allow対応中かも @koic が 3 日前に担当しました。 オープンbug
難易度 3/5 半日 初心者へのやさしさ 45/100
modelcontextprotocol/ruby-sdk#606 ·
メンテナーはふだん 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 が 7 日前に担当しました。 オープンenhancement
modelcontextprotocol/ruby-sdk#594 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
modelcontextprotocol/ruby-sdk の issue をすべて見る
似ている issue
-
Windows: packaged_agent_ruby? never matches 'Puppet Labs\Puppet', so the openvox gem is not foundオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
temporalio/sdk-ruby#625 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 94/100
zerocracy/judges-action#2803 ·
メンテナーはふだん 5 日以内に返信
-
empty tone.rbオープン
難易度 1/5 1時間未満 初心者へのやさしさ 78/100