Sistava

What is JSON-RPC?

Also called JSON-RPC 2.0.

JSON-RPC is a lightweight remote procedure call protocol in which requests and responses are JSON objects. A request names a method, supplies parameters, and usually carries an identifier that the matching response echoes. Version 2.0 is transport agnostic, running over HTTP, WebSocket, standard input and output, or any other message channel.

The message shapes are deliberately minimal. A request object contains the protocol version, a method name, optional parameters as an array or object, and an id. A response contains the version, the same id, and either a result or an error object with a code and message. A request sent without an id is a notification, meaning no response is expected.

Because the specification says nothing about transport, the same messages work over very different channels. This is why JSON-RPC appears both in browser facing services over WebSocket and in local process communication over standard streams, and why it was chosen as the message format for the Model Context Protocol.

Error codes are partly standardized. Reserved ranges cover parse errors, invalid requests, unknown methods, invalid parameters, and internal errors, while applications define their own codes outside the reserved range. Having a predictable error envelope makes generic client handling straightforward compared with parsing free form failure bodies.

The protocol's simplicity is also its boundary. There is no built in authentication, no schema language, no versioning scheme, and no discovery mechanism, so anything beyond message framing is left to the layer above. Batching is supported by sending an array of request objects, with an array of responses returned for those that carry identifiers.

Key points

In practice

A client sends a JSON object with jsonrpc set to 2.0, method set to tools/call, a params object naming the tool and its arguments, and id 7. The server performs the work and replies with jsonrpc 2.0, id 7, and a result object holding the tool output. Had the tool name been unknown, the reply would instead carry an error object with the reserved method not found code.

Related terms

Back to the AI Glossary