Overview
MCP messages define the communication format between clients and servers. This reference documents all message types, their structure, and usage patterns.MCP follows a request-response pattern similar to JSON-RPC 2.0 with extensions for streaming and bidirectional communication.
Protocol Transport Architecture
The MCP protocol supports multiple transport layers for communication between clients and servers. The diagram below illustrates how messages flow through the system:Transport Options
Standard I/O (stdio)
Standard I/O (stdio)
Process-based communication using stdin/stdout. Best for local CLI integrations.
Server-Sent Events (SSE)
Server-Sent Events (SSE)
HTTP-based one-way streaming from server to client. Ideal for web applications.
WebSocket
WebSocket
Full-duplex bidirectional communication. Best for real-time interactive applications.
Message Structure
All MCP messages follow this base structure:string
required
Protocol version, always
"2.0"string | number
required
Unique request identifier for matching responses
string
required
The method to invoke (e.g.,
"tools/call", "resources/read")object
Method-specific parameters
Response Messages
Success Response
Error Response
Error Codes
Message Types
Initialize
Request:Tools/List
Request:Tools/Call
Request:Resources/List
Request:Resources/Read
Request:Prompts/List
Request:Prompts/Get
Request:Content Types
Text Content
Image Content
Resource Content
Notifications
Notifications are messages sent without expecting a response (noid field):
Tools/ListChanged
Resources/ListChanged
Resources/Updated
Streaming Messages
For streaming responses, the server sends multiple messages:Content Start
Content Delta
Content End
Progress Updates
For long-running operations:Example Flows
Complete Chat Interaction
Batch Requests
Send multiple requests in a single HTTP call:Validation
Request Validation
All requests must:- Include
jsonrpc: "2.0" - Have a unique
id(except notifications) - Specify a valid
method - Provide required
paramsfor the method
Response Validation
Clients should validate:- Response
idmatches requestid - Either
resultorerroris present (not both) - Content types match expected formats
Best Practices
Use Unique IDs
Use Unique IDs
Always use unique IDs for requests to prevent confusion:
Handle Errors Gracefully
Handle Errors Gracefully
Always check for error responses:
Implement Timeouts
Implement Timeouts
Set reasonable timeouts for requests:
Use Batch Requests
Use Batch Requests
Combine multiple requests to reduce latency:
Next Steps
MCP Endpoints
Available endpoints
MCP Tools
Tool reference
MCP Resources
Resource types
Authentication
Get auth tokens
MCP Messages: Standardized communication protocol for AI applications!