Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Requests with "id": null are run like notifications

クローズ
#601 コメント 0 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@koic がすでに取り組んでいます。

2026年10月14日 から。

  • #612 @koic による — マージ済み

評価

この issue はまだ評価されていません。

説明

bug

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": null is 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

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

modelcontextprotocol/ruby-sdk のほかの issue

modelcontextprotocol/ruby-sdk の issue をすべて見る

似ている issue

Ruby の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。