|
| 1 | +# Overview |
| 2 | + |
| 3 | +<div id="enable-section-numbers" /> |
| 4 | + |
| 5 | +<Info>**Protocol Revision**: 2025-06-18</Info> |
| 6 | + |
| 7 | +The Model Context Protocol consists of several key components that work together: |
| 8 | + |
| 9 | +* **Base Protocol**: Core JSON-RPC message types |
| 10 | +* **Lifecycle Management**: Connection initialization, capability negotiation, and |
| 11 | + session control |
| 12 | +* **Authorization**: Authentication and authorization framework for HTTP-based transports |
| 13 | +* **Server Features**: Resources, prompts, and tools exposed by servers |
| 14 | +* **Client Features**: Sampling and root directory lists provided by clients |
| 15 | +* **Utilities**: Cross-cutting concerns like logging and argument completion |
| 16 | + |
| 17 | +All implementations **MUST** support the base protocol and lifecycle management |
| 18 | +components. Other components **MAY** be implemented based on the specific needs of the |
| 19 | +application. |
| 20 | + |
| 21 | +These protocol layers establish clear separation of concerns while enabling rich |
| 22 | +interactions between clients and servers. The modular design allows implementations to |
| 23 | +support exactly the features they need. |
| 24 | + |
| 25 | +## Messages |
| 26 | + |
| 27 | +All messages between MCP clients and servers **MUST** follow the |
| 28 | +[JSON-RPC 2.0](https://www.jsonrpc.org/specification) specification. The protocol defines |
| 29 | +these types of messages: |
| 30 | + |
| 31 | +### Requests |
| 32 | + |
| 33 | +Requests are sent from the client to the server or vice versa, to initiate an operation. |
| 34 | + |
| 35 | +```typescript theme={null} |
| 36 | +{ |
| 37 | + jsonrpc: "2.0"; |
| 38 | + id: string | number; |
| 39 | + method: string; |
| 40 | + params?: { |
| 41 | + [key: string]: unknown; |
| 42 | + }; |
| 43 | +} |
| 44 | +``` |
| 45 | + |
| 46 | +* Requests **MUST** include a string or integer ID. |
| 47 | +* Unlike base JSON-RPC, the ID **MUST NOT** be `null`. |
| 48 | +* The request ID **MUST NOT** have been previously used by the requestor within the same |
| 49 | + session. |
| 50 | + |
| 51 | +### Responses |
| 52 | + |
| 53 | +Responses are sent in reply to requests, containing the result or error of the operation. |
| 54 | + |
| 55 | +```typescript theme={null} |
| 56 | +{ |
| 57 | + jsonrpc: "2.0"; |
| 58 | + id: string | number; |
| 59 | + result?: { |
| 60 | + [key: string]: unknown; |
| 61 | + } |
| 62 | + error?: { |
| 63 | + code: number; |
| 64 | + message: string; |
| 65 | + data?: unknown; |
| 66 | + } |
| 67 | +} |
| 68 | +``` |
| 69 | + |
| 70 | +* Responses **MUST** include the same ID as the request they correspond to. |
| 71 | +* **Responses** are further sub-categorized as either **successful results** or |
| 72 | + **errors**. Either a `result` or an `error` **MUST** be set. A response **MUST NOT** |
| 73 | + set both. |
| 74 | +* Results **MAY** follow any JSON object structure, while errors **MUST** include an |
| 75 | + error code and message at minimum. |
| 76 | +* Error codes **MUST** be integers. |
| 77 | + |
| 78 | +### Notifications |
| 79 | + |
| 80 | +Notifications are sent from the client to the server or vice versa, as a one-way message. |
| 81 | +The receiver **MUST NOT** send a response. |
| 82 | + |
| 83 | +```typescript theme={null} |
| 84 | +{ |
| 85 | + jsonrpc: "2.0"; |
| 86 | + method: string; |
| 87 | + params?: { |
| 88 | + [key: string]: unknown; |
| 89 | + }; |
| 90 | +} |
| 91 | +``` |
| 92 | + |
| 93 | +* Notifications **MUST NOT** include an ID. |
| 94 | + |
| 95 | +## Auth |
| 96 | + |
| 97 | +MCP provides an [Authorization](/specification/2025-06-18/basic/authorization) framework for use with HTTP. |
| 98 | +Implementations using an HTTP-based transport **SHOULD** conform to this specification, |
| 99 | +whereas implementations using STDIO transport **SHOULD NOT** follow this specification, |
| 100 | +and instead retrieve credentials from the environment. |
| 101 | + |
| 102 | +Additionally, clients and servers **MAY** negotiate their own custom authentication and |
| 103 | +authorization strategies. |
| 104 | + |
| 105 | +For further discussions and contributions to the evolution of MCP’s auth mechanisms, join |
| 106 | +us in |
| 107 | +[GitHub Discussions](https://github.com/modelcontextprotocol/specification/discussions) |
| 108 | +to help shape the future of the protocol! |
| 109 | + |
| 110 | +## Schema |
| 111 | + |
| 112 | +The full specification of the protocol is defined as a |
| 113 | +[TypeScript schema](https://github.com/modelcontextprotocol/specification/blob/main/schema/2025-06-18/schema.ts). |
| 114 | +This is the source of truth for all protocol messages and structures. |
| 115 | + |
| 116 | +There is also a |
| 117 | +[JSON Schema](https://github.com/modelcontextprotocol/specification/blob/main/schema/2025-06-18/schema.json), |
| 118 | +which is automatically generated from the TypeScript source of truth, for use with |
| 119 | +various automated tooling. |
| 120 | + |
| 121 | +### General fields |
| 122 | + |
| 123 | +#### `_meta` |
| 124 | + |
| 125 | +The `_meta` property/parameter is reserved by MCP to allow clients and servers |
| 126 | +to attach additional metadata to their interactions. |
| 127 | + |
| 128 | +Certain key names are reserved by MCP for protocol-level metadata, as specified below; |
| 129 | +implementations MUST NOT make assumptions about values at these keys. |
| 130 | + |
| 131 | +Additionally, definitions in the [schema](https://github.com/modelcontextprotocol/specification/blob/main/schema/2025-06-18/schema.ts) |
| 132 | +may reserve particular names for purpose-specific metadata, as declared in those definitions. |
| 133 | + |
| 134 | +**Key name format:** valid `_meta` key names have two segments: an optional **prefix**, and a **name**. |
| 135 | + |
| 136 | +**Prefix:** |
| 137 | + |
| 138 | +* If specified, MUST be a series of labels separated by dots (`.`), followed by a slash (`/`). |
| 139 | + * Labels MUST start with a letter and end with a letter or digit; interior characters can be letters, digits, or hyphens (`-`). |
| 140 | +* Any prefix beginning with zero or more valid labels, followed by `modelcontextprotocol` or `mcp`, followed by any valid label, |
| 141 | + is **reserved** for MCP use. |
| 142 | + * For example: `modelcontextprotocol.io/`, `mcp.dev/`, `api.modelcontextprotocol.org/`, and `tools.mcp.com/` are all reserved. |
| 143 | + |
| 144 | +**Name:** |
| 145 | + |
| 146 | +* Unless empty, MUST begin and end with an alphanumeric character (`[a-z0-9A-Z]`). |
| 147 | +* MAY contain hyphens (`-`), underscores (`_`), dots (`.`), and alphanumerics in between. |
0 commit comments