Skip to content

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:

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:

  1. Simplicity - Easy to implement correctly
  2. Extensibility - Add features without breaking compatibility
  3. Security - Secure by default
  4. Performance - Efficient for real-world use
  5. Interoperability - Work across platforms and languages

Reading the Specification

For implementers:

  1. Start with the Protocol Overview
  2. Understand Message Types
  3. Review the Security Model
  4. 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