Inferensys

Glossary

JSON-RPC

JSON-RPC is a stateless, lightweight remote procedure call (RPC) protocol that uses JSON (JavaScript Object Notation) as its message format for requests, responses, and notifications between a client and a server.
Stylish WeWork-like workspace with hot desks and document wall, professional searching through enterprise knowledge base on a mounted ultrawide display, warm industrial pendants overhead.
API PROTOCOL

What is JSON-RPC?

JSON-RPC is the foundational wire protocol used by the Model Context Protocol (MCP) for all structured communication between AI clients and external servers.

JSON-RPC (JavaScript Object Notation Remote Procedure Call) is a stateless, lightweight remote procedure call (RPC) protocol encoded in JSON. It defines a simple specification for a client to request the execution of a method on a remote server and for the server to return a result or error. Its core components are a method name to invoke, params for arguments, and an id for correlating requests with responses, enabling structured, language-agnostic interoperability between processes.

Within the Model Context Protocol (MCP), JSON-RPC serves as the standardized message format for all interactions, including capability negotiation, resource requests, tool invocations, and notifications. MCP layers its own semantics—defining specific methods like tools/list or resources/read—on top of the JSON-RPC 2.0 specification. This design allows AI clients and servers to communicate reliably over various transports like stdio or Server-Sent Events (SSE), ensuring deterministic parsing and validation of all exchanged data.

PROTOCOL FUNDAMENTALS

Key Features of JSON-RPC

JSON-RPC is a stateless, lightweight remote procedure call protocol that uses JSON for data serialization. It defines a simple request-response mechanism for invoking methods on a remote server.

01

JSON Serialization

The protocol's core is its use of JavaScript Object Notation (JSON) for all message encoding. This provides a human-readable, language-agnostic, and widely supported data format. Every request, response, and notification is a single, self-contained JSON object. This simplicity enables easy debugging and interoperability across diverse programming environments, from Python and JavaScript to Go and Rust. The MCP (Model Context Protocol) adopts this format for its messages, ensuring compatibility with a vast ecosystem of tools and libraries.

02

Request-Response Model

JSON-RPC operates on a fundamental request-response pattern. A client sends a request object to a server, which processes it and returns a corresponding response object.

  • Request Object: Must contain jsonrpc (version), method (name of procedure), params (arguments), and id (unique identifier for the call).
  • Response Object: Contains jsonrpc, id (matching the request), and either a result field for success or an error field for failure.
  • Statelessness: Each request is independent; the server maintains no client state between calls, aligning with RESTful principles and simplifying server design.
03

Structured Error Handling

Errors are not signaled via HTTP status codes but through a standardized error object within the JSON-RPC response. This object provides precise, machine-readable failure information.

Key components of the error object:

  • code: A predefined integer indicating the error type (e.g., -32700 for Parse error, -32601 for Method not found).
  • message: A short, human-readable description of the error.
  • data: An optional field containing additional, structured information about the error, such as stack traces or validation details.

This structured approach allows clients, like MCP clients, to programmatically detect and handle different failure modes (network, validation, server logic) without parsing ambiguous text messages.

04

Notification Messages

JSON-RPC supports notifications, which are requests that do not require a response from the server. A notification is a request object that omits the id member. The server processes the method but sends nothing back to the client. This is critical for one-way communication patterns, such as:

  • Logging events or telemetry.
  • Pushing asynchronous updates from server to client.
  • Issuing commands where an acknowledgment is unnecessary.

In the context of MCP transports like SSE (Server-Sent Events), notifications enable servers to push real-time updates (e.g., new resource availability) to connected clients without the overhead of a request cycle.

05

Batch Requests

To optimize network performance, JSON-RPC allows clients to send an array of request objects as a single batch. The server processes each request (potentially in any order) and returns an array of response objects, preserving the order of the responses. The responses in the array correspond to the requests that warranted a reply (notifications within the batch do not generate a response). This feature is essential for reducing latency in scenarios where an AI agent needs to invoke multiple tools or fetch several resources from an MCP server in rapid succession, minimizing round-trip communication overhead.

06

Versioning and Extensibility

The protocol is explicitly versioned via the jsonrpc member in every message, with "2.0" being the dominant and recommended version. This clear versioning prevents ambiguity. While the core specification is minimal, it is designed for extensibility. Implementations can introduce:

  • Custom Error Codes: Beyond the reserved range (-32000 to -32099) for application-specific errors.
  • Extended params Structures: To pass complex, nested data.
  • Metadata in Messages: Non-standard fields that compliant peers should ignore.

This balance of a strict core with room for extension makes it ideal for frameworks like MCP, which builds its entire model of resources, tools, and prompts atop the stable JSON-RPC 2.0 foundation.

PROTOCOL MECHANICS

How JSON-RPC Works

JSON-RPC is the foundational message-passing protocol used by the Model Context Protocol (MCP) for all communication between clients and servers.

JSON-RPC (JavaScript Object Notation Remote Procedure Call) is a stateless, lightweight protocol that encodes remote procedure calls and their responses in JSON format. It defines a simple set of structures for requests, responses, and notifications, enabling a client to invoke a method on a server and receive a structured result. As the core wire format for MCP, it standardizes how clients call tools, fetch resources, and handle errors across diverse transports like stdio and SSE.

The protocol operates through message pairs: a client sends a request object containing a method name, params, and a unique id for correlation. The server processes the call and returns a response object with the same id, containing either a result or an error. Notifications are special requests without an id, used for one-way messages. This simple, transport-agnostic design allows MCP to provide a uniform interface for AI agents to interact with external systems, with built-in support for batch calls and strict schema validation of parameters.

JSON-RPC

Frequently Asked Questions

JSON-RPC is the foundational message format for the Model Context Protocol (MCP). These questions address its core mechanics, role in AI tool-calling, and practical implementation details.

JSON-RPC is a stateless, lightweight remote procedure call (RPC) protocol that uses JSON (JavaScript Object Notation) for data serialization. It defines a simple specification for a client to request the execution of a method on a remote server and for the server to return a response or an error. A JSON-RPC request contains mandatory jsonrpc, method, and id members, along with an optional params member for arguments. The server processes the request and sends back a response object with the same id, containing either a result or an error member. This request-response pattern, transmitted over a transport like stdio or SSE, forms the backbone of communication in protocols like the Model Context Protocol (MCP).

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.