MCP: Model Context ProtocolBeginnerModule 03 — MCP messages and JSON-RPC

Why does MCP use JSON-RPC 2.0?

Question 19 of 43 · Updated

On this page

Direct answer#

The Model Context Protocol (MCP) uses JSON-RPC 2.0 because it provides a small, standardized, language-independent message framework for invoking named operations, receiving results or errors, and sending notifications. It separates the meaning of a request from the mechanism that carries the message, making it suitable for compatible MCP clients and servers implemented in different programming languages and using supported transports.

MCP extends that general framework with its own method names, parameter and result schemas, lifecycle rules, capability declarations and security requirements. JSON-RPC alone is not MCP: a generic JSON-RPC server cannot automatically serve as a compatible MCP server.

The architectural benefit is a reusable communication contract. Instead of inventing a different message envelope for discovering tools, reading resources, retrieving prompts or requesting supported client capabilities, MCP can express those interactions using a consistent request, response and notification model.

Learning continuity: Module 02 established hosts, clients, servers and downstream integration. This opening lesson of Module 03 explains why a standardized message framework is useful. Q26–29 examine requests, responses, notifications and identifiers separately; subsequent lessons cover errors, validation and concurrency. Q285 compares the full MCP protocol with REST APIs in greater depth. This lesson focuses on architectural rationale rather than repeating those implementation topics.

Verification scope: Prepared under the authorized offline research and changelog exceptions. The historical MCP 2025-06-18 specification is the baseline, not a claim about the latest revision. Official references were not checked live. The Python 3.13.5 standard-library example was syntax-compiled and executed locally: all ten JSON-RPC envelope checks passed. It uses simulated carriers and a deliberately limited dispatcher, not actual MCP transports, a full JSON-RPC implementation or an MCP SDK. The local MCP SDK and Mermaid package were unavailable; live interoperability and Mermaid parsing/frontend rendering were not verified.

1. The problem: JSON by itself is not a communication protocol#

Imagine that a retailer builds an inventory server used by several independent applications. The first developer sends this JSON object:

JSON
{"action":"getStock","product":"A12"}

Another application sends:

JSON
{"command":"stock","args":{"sku":"A12"}}

Both are valid JSON. Yet nothing in JSON itself says that action and command mean the same thing, that product and sku identify the same argument, or how a receiver should indicate an unknown operation.

Suppose the receiver returns:

JSON
{"quantity":7}

This is also valid JSON. However, how does the sender know which outstanding request it answers? How is a failure represented? What happens when the receiver needs to notify the sender of a capability change?

The teams could define a custom envelope, add identifiers, invent error conventions and specify which messages expect replies. But that creates another protocol that each participant must implement and maintain.

JSON-RPC 2.0 already defines a lightweight approach to those basic communication problems. MCP can use that approach and concentrate on its own capability semantics.

LayerWhat it provides
JSONA representation for structured data
JSON-RPC 2.0Conventions for invoking methods, returning results/errors and sending notifications
MCPAI-application capability contracts, lifecycle, supported features and transport requirements
TransportMechanisms for carrying messages between participants
ApplicationBusiness logic, authorization, user workflow and reliable execution

A useful distinction is that JSON is a data format; JSON-RPC is a protocol using that format; MCP is a higher-level protocol using JSON-RPC conventions.

2. Why a remote procedure call model fits MCP#

RPC stands for Remote Procedure Call. Conceptually, a sender requests a named operation from another software participant. The receiver executes the appropriate handler and returns the result or an error. The two participants may be separate processes on the same machine or services communicating over a network.

Many common MCP interactions naturally fit this operation-oriented model:

InteractionExample MCP method
Establish compatible communicationinitialize
Discover available toolstools/list
Invoke a selected tooltools/call
Retrieve identified informationresources/read
Retrieve reusable messagesprompts/get
Test whether the peer respondsping

These names and their semantics belong to MCP, not to the generic JSON-RPC specification. JSON-RPC does not define what a tool, resource or prompt is.

A client can invoke a method using a dictionary or an SDK call. It does not need a language model to understand the message format. This reinforces the distinction from Q13: protocol communication is ordinary software interaction, even when a model helped choose an operation.

The term remote does not guarantee that an invocation behaves like a local function call. A remote operation can encounter timeouts, authorization failures, unavailable dependencies or uncertain side effects. Applications must account for those conditions.

3. A consistent message model#

JSON-RPC distinguishes requests, responses and notifications. This provides a small set of conventions that MCP can reuse across its supported capability types.

For example, an illustrative tool discovery request in the historical MCP baseline is:

JSON
{"jsonrpc":"2.0","id":1,"method":"tools/list"}

A receiver may return a matching response containing a list of tool descriptors. A tool invocation uses the same general request-response mechanism but a different method and appropriate parameters.

For comparison, a supported server notification could indicate a catalog change without requesting a JSON-RPC response.

The key benefit is that the protocol participant can first identify the kind of message, then dispatch it according to MCP's method-specific semantics. It does not need a separate top-level protocol for every capability.

PatternWhat it expressesWhy useful
RequestPerform a named operation and provide a responseDiscovery, invocation, reading information
ResponseReturn a result or protocol errorResolve a pending request
NotificationInform the other participant without a JSON-RPC responseSupported lifecycle and capability events

Notifications do not guarantee delivery or durable event processing. The absence of a JSON-RPC response is not the same as the absence of all transport-level acknowledgment. For example, an applicable HTTP transport can acknowledge receipt without producing a JSON-RPC result.

The next three roadmap lessons examine the exact structures and conditions for these messages.

4. Language independence#

JSON provides a widely supported representation for strings, numbers, arrays, objects, booleans and null. A TypeScript client can therefore communicate with a Python server, or a Java application with a Go server, without requiring all participants to share the same runtime or import the same application library.

Loading diagram…

The sender serializes supported values into JSON. The receiver parses those values, validates the applicable MCP message and invokes its own implementation.

This does not mean every value in one programming language has an exact JSON representation. Examples include arbitrary-precision integers, dates, byte arrays, decimal financial values and language-specific objects. The applicable schema and business contract must define how those values are represented.

For example, a JSON number representing a very large integer may lose precision in a runtime that uses binary floating-point numbers for ordinary numeric values. Choose representations and validation rules deliberately rather than assume that successful JSON serialization guarantees equivalent meaning.

Language independence reduces runtime coupling, but still requires schema compatibility, consistent semantics and independent implementation testing.

5. Transport independence#

JSON-RPC describes the message-level interaction. It does not itself prescribe a TCP connection, HTTP endpoint or subprocess transport.

This separation is useful to MCP because the same conceptual operation can be expressed through different supported transport mechanisms. In the historical 2025-06-18 baseline, MCP specifies stdio and Streamable HTTP. The transport rules determine how those messages are framed, delivered and associated with the relevant interaction.

ConcernMessage layerTransport layer
Operation nametools/list or another supported methodCarries the encoded message
Result correlationJSON-RPC request and response IDsDelivers messages within the appropriate connection context
EncodingJSON message representationApplicable framing, encoding and HTTP content rules
FailureProtocol-level error representationConnection loss, HTTP failure or other delivery problem

For stdio, the historical MCP transport uses newline-delimited JSON messages over process streams. For Streamable HTTP, it defines HTTP interaction and supported streaming behavior. The specific transport rules, session identifiers and lifecycle requirements belong to the relevant MCP specification rather than generic JSON-RPC.

A host can therefore preserve the conceptual capability contract while choosing a supported deployment model. But changing transports is not always a configuration-only operation. Authentication, session behavior, streaming, process ownership and operational constraints may differ.

Do not interpret transport independence as permission to send JSON-RPC messages over an arbitrary channel and claim MCP compatibility. Both sides must implement compatible transport and protocol semantics.

6. Why bidirectional communication matters#

A traditional request-oriented application often sends a request to a service and receives a result. MCP can also support communication initiated by the server. In the historical architecture, clients and servers can send supported requests and notifications in either direction.

For example, an MCP client can send a ping request to a server. A server can also send a ping request to a client. Other server-to-client requests, such as sampling or elicitation in supported revisions, depend on the relevant capabilities, lifecycle and application policy.

Loading diagram…

This is a conceptual exchange after the applicable initialization. The example assumes the server supports the relevant tool and list-change features. The actual transport must support delivery of the corresponding server-initiated messages. It does not imply that every client supports every optional capability.

JSON-RPC provides a reusable message convention for either participant to act as the sender of a request. MCP defines when particular methods are available and how the participants should handle them.

The server cannot acquire unrestricted access to the host simply by initiating a request. It remains subject to the negotiated capabilities, supported methods, authorization and host policy.

7. Correlation identifiers help separate concurrent work#

When a client has more than one outstanding operation, responses may not arrive in the order in which requests were sent. A standardized identifier allows the receiver of a response to associate it with the relevant pending request.

Imagine the host requests inventory information and a policy document. The policy operation may finish first even if it was submitted second. Without a correlation identifier or another reliable association mechanism, the host might mistake one result for the other.

JSON-RPC gives each request expecting a response an identifier that the response uses for correlation. MCP applies its own identifier constraints and message rules on top of the generic protocol.

As established in Q21, identifiers are scoped to their relevant communication relationship. A global map keyed only by a numeric identifier can incorrectly mix independent clients. Detailed identifier rules and concurrent correlation algorithms are reserved for Q29 and Q34.

A request identifier is not a durable business transaction identifier, an authentication token or proof that an action was authorized. Retrying a request after a timeout does not automatically provide exactly-once execution.

8. Standard error representation reduces ambiguity#

Without a common error format, one service might return an error string, another might return a numeric status and another might return an empty object. A client would need to learn those conventions individually before understanding whether a protocol operation failed.

JSON-RPC defines an error object with a code and message, and optional data. It also defines several standard error codes, such as:

CodeMeaning
-32700Parse error
-32600Invalid Request
-32601Method not found
-32602Invalid params
-32603Internal error

The generic JSON-RPC error convention gives protocol implementations a common foundation for reporting failures. MCP specifies further requirements and error semantics for its own methods.

Do not confuse three distinct outcomes:

  1. A transport or connection failure, such as an HTTP connection timing out.
  2. A JSON-RPC protocol error, such as an unsupported method.
  3. A capability result that reports execution failure or a definitive business rejection.

For example, a recognized stock tool may fail to retrieve a record even though the JSON-RPC message is valid. The applicable MCP tool result can represent execution errors using its supported result fields. A valid protocol response is not proof that the underlying business operation succeeded.

Detailed error structures, tool errors and retry policies are covered in Q31 and later reliability lessons.

9. Compare ordinary JSON, JSON-RPC and REST#

These concepts are not interchangeable.

DimensionOrdinary JSONJSON-RPC 2.0REST-oriented HTTP API
Primary purposeRepresent dataInvoke named operations using a standard envelopeExpose resources through an architectural interface
Operation selectionDefined by applicationMethod nameCommonly resource URI and HTTP method
Response correlationNot defined by JSONRequest IDUsually HTTP request/response association
ErrorsApplication-specificStandard error object and codesHTTP status and application response contract
TransportNone specifiedNot tied to one transportCommonly HTTP
NotificationsNo built-in semanticsExplicit notification patternMay use separate event mechanisms

REST is an architectural style, not simply a synonym for JSON over HTTP. RESTful systems can use different representations, and an HTTP API is not necessarily RESTful. JSON-RPC can itself be transported over HTTP.

A conventional HTTP API might expose an order resource using an HTTP GET. An MCP server can expose an order lookup as a tool and internally call that same API. The MCP server adds a capability interface and relevant protocol semantics without replacing the underlying HTTP service.

JSON-RPC is not always superior to REST. A stable resource-oriented web application may be better served by its existing HTTP interface. MCP uses JSON-RPC for its operation and event-oriented communication boundary, while downstream services remain free to use their own contracts.

10. Tested practical example: one message envelope, two simulated carriers#

The following Python program demonstrates the separation between the message envelope and its carrier. It encodes and decodes JSON using two in-memory representations: a newline-terminated string and UTF-8 bytes. The same dispatcher processes both.

The fictional demo/add and demo/event methods are teaching examples of generic JSON-RPC-style messages, not standardized MCP methods. Ping is a real MCP utility method in the historical baseline, but this fixture does not implement the full MCP lifecycle or ping requirements. The sender labels in the tests represent two conceptual directions; they do not create two real peers.

Save as mcp_q25.py:

PYTHON
import json def dispatch(message): # Trusted, decoded fixture messages only. method = message['method'] if 'id' not in message: return None reply = {'jsonrpc': '2.0', 'id': message['id']} if method == 'ping': reply['result'] = {} elif method == 'demo/add': p = message.get('params', {}) if set(p) == {'a', 'b'} and all(type(p[k]) is int for k in p): reply['result'] = {'sum': p['a'] + p['b']} else: reply['error'] = {'code': -32602, 'message': 'Invalid params'} else: reply['error'] = {'code': -32601, 'message': 'Method not found'} return reply def exchange(message, carrier): def transfer(obj): payload = json.dumps(obj, ensure_ascii=False) if carrier == 'line': return json.loads(payload + '\n') if carrier == 'bytes': return json.loads(payload.encode('utf-8')) raise ValueError('Unknown fixture carrier') result = dispatch(transfer(message)) return None if result is None else transfer(result) if __name__ == '__main__': call = {'jsonrpc': '2.0', 'id': 'c1', 'method': 'demo/add', 'params': {'a': 2, 'b': 5}} line = exchange(call, 'line') binary = exchange(call, 'bytes') assert line == binary assert line['result'] == {'sum': 7} assert line['id'] == 'c1' assert line['jsonrpc'] == '2.0' assert exchange({**call, 'method': 'unknown'}, 'line')['error']['code'] == -32601 assert exchange({**call, 'params': {'a': True, 'b': 5}}, 'bytes')['error']['code'] == -32602 assert exchange({'jsonrpc': '2.0', 'method': 'demo/event'}, 'line') is None for sender in ('client', 'server'): ping = {'jsonrpc': '2.0', 'id': sender + '-ping', 'method': 'ping'} assert exchange(ping, 'bytes') == {'jsonrpc': '2.0', 'id': ping['id'], 'result': {}} assert exchange({**call, 'id': 0}, 'line')['id'] == 0 print('10 JSON-RPC envelope checks passed')

Run with Python 3.10 or later:

BASH
python -m py_compile mcp_q25.py python mcp_q25.py

Actual local output using Python 3.13.5:

10 JSON-RPC envelope checks passed

What the ten checks establish#

The first four checks confirm equivalent outcomes across both simulated carriers, the expected sum, the preserved identifier and the JSON-RPC version field. Two checks verify the chosen standardized errors for an unknown method and invalid arguments. One checks that the demonstration notification receives no response. Two ping fixtures represent the two possible sender roles. The last check confirms that the numeric identifier zero is not mistaken for the absence of an identifier.

The dispatch function concentrates on message semantics, while transfer concentrates on JSON encoding and decoding. Keeping these separate illustrates why a standardized envelope can remain conceptually stable when the carrier changes.

The code is deliberately minimal. It accepts only trusted fixture messages and does not validate full JSON-RPC envelopes, handle malformed JSON, implement real notification handlers, manage pending requests, implement batching or enforce the MCP lifecycle and capability rules. It does not provide authentication, authorization, network I/O, actual stdio framing, HTTP handling or secure error sanitization. It ignores notifications rather than implementing their side effects. The two ping cases demonstrate equivalent envelope handling with distinct sender labels, not verified bidirectional network communication.

Do not use this fixture as a production JSON-RPC or MCP implementation. Use a compatible official SDK for real MCP communication. The next lessons examine the message schema and error rules separately.

11. What JSON-RPC does not solve#

Choosing a lightweight standard does not eliminate the need for other protocol and application layers.

LimitationRequired complementary responsibility
No MCP-specific method definitions in generic JSON-RPCMCP specification and schemas
No universal transport implementationCompatible MCP transport adapter
No built-in business authorizationTrusted identity and resource policy
No guarantee of successful external executionAuthoritative business validation and outcomes
No automatic exactly-once behaviorApplication idempotency and reconciliation
No automatic compatibility across revisionsNegotiation and integration tests
No inherent confidentialityAppropriate transport and deployment security
No automatic backpressure or deadlinesBounded runtime and reliability controls

JSON-RPC is also not a universal binary streaming format. JSON serialization is readable and broadly supported, but payload size, encoding cost and large result processing can become relevant at scale. Measure actual workloads rather than assume that the protocol envelope dominates end-to-end latency.

In particular, MCP is not necessarily a full superset of every generic JSON-RPC feature. The historical MCP 2025-06-18 revision removed JSON-RPC batching support. Implementations must follow the selected MCP revision rather than assume generic JSON-RPC batch requests are supported. This is an example of why a shared base protocol does not make all higher-level implementations compatible.

The general JSON-RPC version marker 2.0 also does not identify the MCP specification revision. Two peers can both understand JSON-RPC 2.0 but disagree on available MCP methods, lifecycle rules or capability schemas.

12. A practical engineering perspective#

Imagine an organization implementing an inventory MCP server in Python and a developer host in TypeScript. Both teams need to agree on more than valid JSON. They must use compatible MCP schemas and transport behavior, preserve the server's capability semantics, and test message exchanges and failure cases.

A useful testing progression is to validate message parsing and dispatch, exercise supported requests and notifications across real SDK implementations, then test authentication, authorization and business outcomes using controlled data. Record the supported protocol revision and SDK versions. Verify failures without exposing private payloads.

The shared envelope helps each team understand whether a message is asking for an operation, reporting its result or communicating an event. The higher-level MCP contract establishes which operation it is and whether it is supported.

Use this mental model when debugging: if a message cannot be parsed, investigate encoding and framing. If a method is unsupported, investigate lifecycle, negotiated capabilities and method names. If the method executes but the user receives incorrect information, investigate the business result and host interpretation. The message standard helps separate those failure boundaries; it cannot fix them by itself.

Interview-ready answer#

MCP uses JSON-RPC 2.0 because it supplies a standardized, lightweight request-response and notification model that is independent of a particular programming language and transport. Named methods fit capability discovery and invocation, correlation identifiers associate responses with outstanding requests, and standardized errors make protocol failures easier to interpret. The message model also supports requests and notifications initiated by either participant where MCP permits them. MCP adds its own schemas, lifecycle, capability and transport rules, so ordinary JSON or a generic JSON-RPC implementation alone is not sufficient. Security, business correctness, retries and distributed transactions still require appropriate application and service controls.

Next lesson: Q26 examines how an MCP request message is structured, moving from the architectural rationale to its exact fields and validation requirements.

References

  1. 1.
  2. 2.
  3. 3.
  4. 4.
    MCP base protocolmodelcontextprotocol.io
  5. 5.
    MCP transportsmodelcontextprotocol.io
  6. 6.
    MCP lifecyclemodelcontextprotocol.io
  7. 7.
    MCP pingmodelcontextprotocol.io
  8. 8.
    MCP changelog (2025-06-18)modelcontextprotocol.io
  9. 9.
  10. 10.

Related questions

Explore other topics:Forward Deployed EngineeringAI AgentsLarge Language ModelsRetrieval-Augmented Generation