Protocols
Detailed technical specifications and communication formats for the Model Context Protocol
MCP uses JSON-RPC 2.0 as its communication protocol. This allows for structured messages between clients and servers, with support for requests, responses, and notifications.
Protocol Layer
The protocol layer handles message framing, request/response linking, and high-level communication patterns.
Message Structure
JSON-RPC 2.0 Format
All messages follow the JSON-RPC 2.0 specification:
Notice that requests and responses have an "id" field to link them together, while notifications don't have this field.
Protocol Features
Required Methods
MCP requires certain methods to be implemented:
Method | Description |
---|---|
initialize | First message sent by client to establish connection |
initialized | Notification sent by client after initialization |
shutdown | Request to terminate the connection |
exit | Notification to indicate connection is closed |
Capability Negotiation
During initialization, clients and servers exchange their capabilities:
Transport Mechanisms
MCP supports multiple transport mechanisms:
Standard I/O (stdio)
- Uses process standard input/output
- Suitable for local processes
- Messages are delimited by specific headers
HTTP with Server-Sent Events (SSE)
- Uses HTTP POST for client-to-server messages
- Uses Server-Sent Events for server-to-client messages
- Suitable for network communication
Schema Validation
MCP uses JSON Schema to validate messages:
- Each message type has a defined schema
- Messages are validated against their schema
- Invalid messages result in error responses
This ensures all communications follow the expected format and contain required fields.
How is this guide?