part…
Building governance for MCP?
The gateway applies what the guide teaches: policies on discovery, invocation and authorisation.
The gateway applies what the guide teaches: policies on discovery, invocation and authorisation.
MCP is, in essence, JSON-RPC 2.0 with restrictions. The JSON-RPC 2.0 specification (jsonrpc.org, 2010) is not an IETF RFC, but it is the only normative document for the message format. It is worth mastering in full, because a gateway has to parse and reserialise messages without altering their semantics.
{ "jsonrpc": "2.0", "id": 1, "method": "subtract", "params": { "minuend": 42, "subtrahend": 23 } }
jsonrpc: must be exactly "2.0".method: string. Names beginning with rpc. are reserved for internal JSON-RPC extensions.params: optional; by position (array) or by name (object).id: string, number or null. If absent, the message is a Notification. JSON-RPC discourages fractional numbers and allows null (with caveats).A Request without id. The server must not respond, not even with an error. Useful for events; of no use if you need confirmation.
{ "jsonrpc": "2.0", "id": 1, "result": 19 }
{ "jsonrpc": "2.0", "id": 1, "error": { "code": -32601, "message": "Method not found" } }
result or error.id must be that of the Request; if it could not be determined (parse error, invalid request), it is null.error.code is an integer, error.message a short string, error.data any optional value.| Code | Meaning |
|---|---|
-32700 |
Parse error: invalid JSON. |
-32600 |
Invalid Request: the JSON is not a valid Request object. |
-32601 |
Method not found. |
-32602 |
Invalid params. |
-32603 |
Internal error. |
-32000 to -32099 |
Reserved for server implementation-defined errors. |
The whole range -32768 to -32000 is reserved by JSON-RPC for present and future predefined errors.
JSON-RPC allows sending an array of Requests and receiving an array of Responses (in any order). MCP adopted it in 2025-03-26 and removed it in 2025-06-18. In current MCP an array is an invalid request (-32600).
params: by position or by nameIn pure JSON-RPC 2.0, params can take two forms and the server decides which one it accepts:
{ "jsonrpc": "2.0", "id": 1, "method": "subtract", "params": [42, 23] }
{ "jsonrpc": "2.0", "id": 1, "method": "subtract", "params": { "minuend": 42, "subtrahend": 23 } }
In MCP params is always an object with keys, never an array, for two reasons:
name, arguments, uri, cursor…) and schema.ts types them as objects._meta has to fit inside params. Since 2026-07-28 every request must carry params._meta with the protocol version and the client capabilities. In an array there is no room for a key called _meta, so the positional form is impossible by construction.Correct request in MCP:
{ "jsonrpc": "2.0", "id": 1, "method": "tools/call",
"params": {
"name": "get_weather",
"arguments": { "location": "Madrid" },
"_meta": {
"io.modelcontextprotocol/protocolVersion": "2026-07-28",
"io.modelcontextprotocol/clientCapabilities": {}
}
} }
Request that an MCP server must reject with -32602 (Invalid params), even though it is valid JSON-RPC:
{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": ["get_weather", { "location": "Madrid" }] }
Consequence for the gateway: the validator can reject outright any params that is not an object, even before looking at the method.
| JSON-RPC 2.0 | MCP |
|---|---|
id may be null. |
id MUST NOT be null; string or integer. |
| A client may reuse ids. | The id MUST NOT be repeated across in-flight requests from the same sender. |
params by position (array) or by name. |
Always an object by name (required for _meta). |
result may be any JSON value. |
result is always an object with resultType. |
| Batch allowed. | Forbidden since 2025-06-18. |
| No character-encoding rule. | UTF-8 mandatory. |
Range -32000..-32099 free for the server. |
Partitioned: -32000..-32019 legacy, -32020..-32099 reserved for the spec. |
| Anyone may send Requests. | In 2026-07-28 only the client sends Requests. |
{"jsonrpc":"2.0","method":"foo"}? Nothing: it is a notification.{"jsonrpc":"2.0","id":5,"method":"foo"}? -32601 with id: 5.{"jsonrpc":"2.0","id":5,"method":"tools/list","params":[]} in MCP? -32602: params must be an object and, besides, the mandatory _meta fields are missing._meta, resultType, no batch). Error messages must say which of the two layers failed.id. Over SSE and over stdio, responses may be interleaved with notifications.id (string vs number) when forwarding: "1" and 1 are different ids.1. What distinguishes a Notification from a Request in JSON-RPC 2.0?
The absence of id turns the message into a notification and the receiver must not respond.
2. Which range does JSON-RPC reserve for server-defined errors?
MCP later partitions it into legacy (-32000..-32019) and reserved for the spec (-32020..-32099).
3. What form must params take in an MCP request?
JSON-RPC admits both; MCP requires an object because _meta travels inside params and the methods define named parameters.
4. How does current MCP treat a JSON-RPC array (batch)?
Batching was removed in 2025-06-18.