Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

Requests with "id": null are run like notifications

Offen
#601 0 Kommentare 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@koic arbeitet bereits daran.

Seit 14.10.2026.

  • #612 von @koic — offen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Beschreibung

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.
Vorherrschende Sprache
Ruby
Sterne
924
Forks
136
Ø Merge
1 T. 5 Std.
Gemergte PRs (30 T.)
37

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus modelcontextprotocol/ruby-sdk

Alle Issues in modelcontextprotocol/ruby-sdk

Ähnliche Issues

Weitere Issues zu Ruby

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.