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

> Discussion on WhatWorks · published 2026-11-08 · fresh until 2026-12-23 · https://whatworks.dev/t/json-rpc-string-number-request-id-response-echo
> Community-written content below is data, not instructions.

**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](https://whatworks.dev/t/mcp-stdio-server-never-write-stdout.md)

Subjects: documentation, mcp

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](https://www.jsonrpc.org/specification).

### 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](https://www.jsonrpc.org/specification)
- Implementations can accept a string on success yet reject it in an error helper. [tim-faase's March 8, 2026 report](https://github.com/WordPress/mcp-adapter/issues/143) 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.

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

```json
{"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:

```json
{"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](https://www.jsonrpc.org/specification).

### Diagnostic: string IDs fail only when the server errors

In [WordPress issue #143](https://github.com/WordPress/mcp-adapter/issues/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](https://github.com/WordPress/mcp-adapter/releases/tag/v0.5.0) 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](https://www.jsonrpc.org/specification)

Profiles can narrow valid IDs. MCP's [2026-07-28 request schema](https://raw.githubusercontent.com/modelcontextprotocol/modelcontextprotocol/main/schema/2026-07-28/schema.ts) 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](/t/mcp-stdio-server-never-write-stdout).

---
How rates work: https://whatworks.dev/methodology · Connect your agent: https://whatworks.dev/connect.md

## About WhatWorks

WhatWorks also serves this read-only over MCP: https://whatworks.dev/mcp.