Protocol Specification¶
The formal specification for the Model Context Protocol, defining message formats, behavior requirements, and implementation guidelines.
Specification Overview¶
The MCP specification is organized into modular components:
📋 Protocol Overview
Core protocol architecture, design principles, and module organization.
📨 Message Types
Complete reference for all request, response, and notification formats.
🔒 Security Model
Authentication, authorization, and transport security requirements.
📊 Version History
Protocol evolution, version compatibility, and migration guides.
✅ Conformance Tests
Test suite to verify protocol compliance and implementation correctness.
Quick Reference¶
Message Format¶
All MCP messages follow JSON-RPC 2.0:
{
"jsonrpc": "2.0",
"id": "unique-id",
"method": "namespace/operation",
"params": {
// Method-specific parameters
}
}
Core Namespaces¶
Namespace | Purpose | Example Methods |
---|---|---|
initialize | Session setup | initialize |
tools | Tool operations | tools/list , tools/call |
resources | Resource access | resources/list , resources/read |
prompts | Prompt templates | prompts/list , prompts/get |
completion | AI completions | completion/complete |
Transport Requirements¶
MCP supports multiple transports:
- stdio: Local process communication
- HTTP/HTTPS: Network API access
- WebSocket: Real-time bidirectional
Implementation Guidelines¶
1. Version Negotiation¶
Always start with capability negotiation:
{
"method": "initialize",
"params": {
"protocolVersion": "1.0",
"capabilities": {
"tools": true,
"resources": true
}
}
}
2. Error Handling¶
Use standard JSON-RPC error codes:
{
"error": {
"code": -32602,
"message": "Invalid params",
"data": {
"param": "toolName",
"issue": "Tool not found"
}
}
}
3. Schema Validation¶
All parameters must validate against JSON Schema:
{
"inputSchema": {
"type": "object",
"properties": {
"query": {
"type": "string",
"minLength": 1
}
},
"required": ["query"]
}
}
Compliance Levels¶
Basic Compliance¶
- ✅ JSON-RPC 2.0 message format
- ✅ Initialize handshake
- ✅ At least one of: tools, resources, or prompts
- ✅ Standard error codes
Full Compliance¶
- ✅ All basic requirements
- ✅ Complete capability negotiation
- ✅ Schema validation
- ✅ Batch request support
- ✅ Proper lifecycle management
Extended Features¶
- ✅ Streaming responses
- ✅ Resource subscriptions
- ✅ Dynamic capability updates
- ✅ Custom extensions
Design Principles¶
The MCP specification follows these core principles:
- Simplicity - Easy to implement correctly
- Extensibility - Add features without breaking compatibility
- Security - Secure by default
- Performance - Efficient for real-world use
- Interoperability - Work across platforms and languages
Reading the Specification¶
For implementers:
- Start with the Protocol Overview
- Understand Message Types
- Review the Security Model
- Test with Conformance Tests
Specification Status
The MCP specification is actively maintained. Check Version History for the latest updates and planned changes.
Contributing to the Spec¶
Found an issue or have a suggestion? The specification is developed openly:
- Review process on GitHub
- Request for Comments (RFC) system
- Regular community reviews
- Backward compatibility commitment