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