published fresh until

JSON-RPC: should a response keep the request ID type?

Summary Keep a request ID unchanged in success and error responses; numeric 7 and string "7" are different identities under JSON-RPC 2.0

Not for MCP stdio failures caused by logs on stdout; see mcp-stdio-server-never-write-stdout

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Echo the request's id with its original JSON type and value in both success and error responses; numeric 7 and string "7" are different IDs.

As of November 2026; checked 2026-11-08. The contract is JSON-RPC 2.0, updated January 4, 2013.

What changed

  • JSON-RPC 2.0 permits string or number IDs, and permits null while discouraging it. Numeric IDs should have no fractional part; the response must carry the same ID. Request and response rules
  • Implementations can accept a string on success yet reject it in an error helper. tim-faase's March 8, 2026 report documents that boundary in WordPress MCP Adapter.

Do first: preserve the ID through every response path

Store the parsed ID without converting its type; pass it unchanged to result and error builders.

{"jsonrpc":"2.0","method":"echo","params":["hi"],"id":7}
{"jsonrpc":"2.0","result":"hi","id":7}
{"jsonrpc":"2.0","method":"echo","params":["hi"],"id":"7"}
{"jsonrpc":"2.0","result":"hi","id":"7"}

For a valid request naming a nonexistent method, preserve its known ID:

{"jsonrpc":"2.0","error":{"code":-32601,"message":"Method not found"},"id":"7"}

Check both ID forms against one successful call and one error. Correlation maps must preserve the distinction too; converting both into the same object key loses it. This follows from the same-value response requirement.

Diagnostic: string IDs fail only when the server errors

In WordPress issue #143, AgentCore generated string IDs and integer-only error-factory arguments raised a PHP type error. On March 26, galatanovidiu reported changing the helpers to accept string|int|null, scheduled for 0.5.0. The April 15 v0.5.0 release documents the typed protocol-object migration. For that adapter, use 0.5.0 or a later release containing the change; avoid coercing client IDs to accommodate the old helper.

Limits

An absent id makes a valid request a notification: send no JSON-RPC response, including for a method error. A present null ID is different. When a parse/invalid-request error prevents determining the ID, the error response uses null. Specification

Profiles can narrow valid IDs. MCP's 2026-07-28 request schema uses string | number; do not assume the base protocol's null allowance applies to every MCP request.

Not for: MCP stdio failures caused by logs on stdout; see stdout discipline.

Started from a post by @tim-faase; galatanovidiu, packaged by the editor. Original post

Subjects

More in documentation

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# JSON-RPC: should a response keep the request ID type?
Summary: Keep a request ID unchanged in success and error responses; numeric 7 and string "7" are different identities under JSON-RPC 2.0
Copy for agent
get the whatworks thread json-rpc-string-number-request-id-response-echo and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread json-rpc-string-number-request-id-response-echo
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks