You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Model Context Protocol (MCP) is an open protocol that enables seamless integration between LLM applications and external data sources and tools. Whether you're building an AI-powered IDE, enhancing a chat interface, or creating custom AI workflows, MCP provides a standardized way to connect LLMs with the context they need. This specification defines the authoritative protocol requirements based on the TypeScript schema in [schema.ts](https://github.com/modelcontextprotocol/specification/blob/main/schema/schema.ts). For implementation guides and examples, visit [modelcontextprotocol.io](https://modelcontextprotocol.io).
13
+
[Model Context Protocol](https://modelcontextprotocol.io) (MCP) is an open protocol that enables seamless integration between LLM applications and external data sources and tools. Whether you're building an AI-powered IDE, enhancing a chat interface, or creating custom AI workflows, MCP provides a standardized way to connect LLMs with the context they need.
14
+
15
+
This specification defines the authoritative protocol requirements, based on the TypeScript schema in [schema.ts](https://github.com/modelcontextprotocol/specification/blob/main/schema/schema.ts).
16
+
17
+
For implementation guides and examples, visit [modelcontextprotocol.io](https://modelcontextprotocol.io).
14
18
15
19
## Overview
16
20
@@ -20,32 +24,79 @@ MCP provides a standardized way for applications to:
20
24
- Expose tools and capabilities to AI systems
21
25
- Build composable integrations and workflows
22
26
23
-
The protocol uses JSON-RPC 2.0 messages to establish communication between:
27
+
The protocol uses [JSON-RPC](https://www.jsonrpc.org/) 2.0 messages to establish communication between:
24
28
25
-
-**Clients**: Applications that integrate with language models
29
+
-**Hosts**: LLM applications that initiate connections
30
+
-**Clients**: Connectors within the host application
26
31
-**Servers**: Services that provide context and capabilities
27
-
-**Hosts**: Processes that manage client connections
28
32
29
-
## Core Protocol Features
33
+
MCP takes some inspiration from the [Language Server Protocol](https://microsoft.github.io/language-server-protocol/), which standardizes how to add support for programming languages across a whole ecosystem of development tools. In a similar way, MCP standardizes how to integrate additional context and tools into the ecosystem of AI applications.
30
34
31
-
MCP defines several key components:
35
+
## Key Details
32
36
33
37
### Base Protocol
34
-
- JSON-RPC message format
35
-
- Capability negotiation
36
-
- Session lifecycle management
38
+
-[JSON-RPC](https://www.jsonrpc.org/) message format
39
+
- Stateful connections
40
+
- Server and client capability negotiation
41
+
42
+
### Features
43
+
44
+
Servers offer any of the following features to clients:
45
+
46
+
-**Resources**: Context and data, for the user or the AI model to use
47
+
-**Prompts**: Templated messages and workflows for users
48
+
-**Tools**: Functions for the AI model to execute
37
49
38
-
### Context Primitives
39
-
-**Resources**: Data exposed via URIs
40
-
-**Prompts**: Template-based interactions
41
-
-**Tools**: Executable functions
42
-
-**Sampling**: LLM generation control
50
+
Clients may offer the following feature to servers:
43
51
44
-
### Cross-Cutting Concerns
52
+
-**Sampling**: Server-initiated agentic behaviors and recursive LLM interactions
53
+
54
+
### Additional Utilities
55
+
56
+
- Configuration
45
57
- Progress tracking
46
-
- Error handling
47
-
- Security boundaries
48
-
- Backwards compatibility
58
+
- Cancellation
59
+
- Error reporting
60
+
- Logging
61
+
62
+
## Security and Trust & Safety
63
+
64
+
The Model Context Protocol enables powerful capabilities through arbitrary data access and code execution paths. With this power comes important security and trust considerations that all implementors must carefully address.
65
+
66
+
### Key Principles
67
+
68
+
1.**User Consent and Control**
69
+
- Users must explicitly consent to and understand all data access and operations
70
+
- Users must retain control over what data is shared and what actions are taken
71
+
- Implementors should provide clear UIs for reviewing and authorizing activities
72
+
73
+
2.**Data Privacy**
74
+
- Hosts must obtain explicit user consent before exposing user data to servers
75
+
- Hosts must not transmit resource data elsewhere without user consent
76
+
- User data should be protected with appropriate access controls
77
+
78
+
3.**Tool Safety**
79
+
- Tools represent arbitrary code execution and must be treated with appropriate caution
80
+
- Hosts must obtain explicit user consent before invoking any tool
81
+
- Users should understand what each tool does before authorizing its use
82
+
83
+
4.**LLM Sampling Controls**
84
+
- Users must explicitly approve any LLM sampling requests
85
+
- Users should control:
86
+
- Whether sampling occurs at all
87
+
- The actual prompt that will be sent
88
+
- What results the server can see
89
+
- The protocol intentionally limits server visibility into prompts
90
+
91
+
### Implementation Guidelines
92
+
93
+
While MCP itself cannot enforce these security principles at the protocol level, implementors **SHOULD**:
94
+
95
+
1. Build robust consent and authorization flows into their applications
96
+
2. Provide clear documentation of security implications
97
+
3. Implement appropriate access controls and data protections
98
+
4. Follow security best practices in their integrations
99
+
5. Consider privacy implications in their feature designs
Copy file name to clipboardExpand all lines: docs/specification/architecture/_index.md
+48-55Lines changed: 48 additions & 55 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ The Model Context Protocol (MCP) follows a client-host-server architecture where
10
10
## Core Components
11
11
12
12
```mermaid
13
-
graph TB
13
+
graph LR
14
14
subgraph "Application Host Process"
15
15
H[Host]
16
16
C1[Client 1]
@@ -20,21 +20,26 @@ graph TB
20
20
H --> C2
21
21
H --> C3
22
22
end
23
-
S1[Server 1<br>Files & Git]
24
-
S2[Server 2<br>Database]
25
-
S3[Server 3<br>External APIs]
26
23
27
-
R1[("Local<br>Resource A")]
28
-
R2[("Local<br>Resource B")]
29
-
R3[("Local<br>Resource C")]
24
+
subgraph "Local machine"
25
+
S1[Server 1<br>Files & Git]
26
+
S2[Server 2<br>Database]
27
+
R1[("Local<br>Resource A")]
28
+
R2[("Local<br>Resource B")]
30
29
31
-
C1 --> S1
32
-
C2 --> S2
33
-
C3 --> S3
30
+
C1 --> S1
31
+
C2 --> S2
32
+
S1 <--> R1
33
+
S2 <--> R2
34
+
end
35
+
36
+
subgraph "Internet"
37
+
S3[Server 3<br>External APIs]
38
+
R3[("Remote<br>Resource C")]
34
39
35
-
S1 <--> R1
36
-
S2 <--> R2
37
-
S3 <--> R3
40
+
C3 --> S3
41
+
S3 <--> R3
42
+
end
38
43
```
39
44
40
45
### Host
@@ -62,76 +67,64 @@ Servers provide specialized context and capabilities:
62
67
- Must respect security constraints
63
68
- Can be local processes or remote services
64
69
65
-
## Protocol Capabilities and Flow
70
+
## Message Types
71
+
MCP defines three core message types based on [JSON-RPC 2.0](https://www.jsonrpc.org/specification):
72
+
73
+
-**Requests**: Bidirectional messages with method and parameters expecting a response
74
+
-**Responses**: Successful results or errors matching specific request IDs
75
+
-**Notifications**: One-way messages requiring no response
76
+
77
+
Each message type follows the JSON-RPC 2.0 specification for structure and delivery semantics.
78
+
79
+
## Capability Negotiation
66
80
67
81
The Model Context Protocol uses a capability-based negotiation system where clients and servers explicitly declare their supported features during initialization. Capabilities determine which protocol features and primitives are available during a session.
68
82
69
83
- Servers declare capabilities like resource subscriptions, tool support, and prompt templates
70
84
- Clients declare capabilities like sampling support and notification handling
71
85
- Both parties must respect declared capabilities throughout the session
72
-
- Additional capabilities can be negotiated through protocol extensions
86
+
- Additional capabilities can be negotiated through extensions to the protocol
73
87
74
88
```mermaid
75
89
sequenceDiagram
76
90
participant Host
77
91
participant Client
78
92
participant Server
79
93
80
-
Host->>Client: Initialize client
81
-
Client->>Server: Initialize session with capabilities
Client->>+Server: Initialize session with capabilities
96
+
Server-->>Client: Respond with supported capabilities
83
97
84
98
Note over Host,Server: Active Session with Negotiated Features
85
99
86
-
alt Server Request (if sampling capable)
100
+
loop Client Requests
101
+
Host->>Client: User- or model-initiated action
102
+
Client->>Server: Request (tools/resources)
103
+
Server-->>Client: Response
104
+
Client-->>Host: Update UI or respond to model
105
+
end
106
+
107
+
loop Server Requests
87
108
Server->>Client: Request (sampling)
88
109
Client->>Host: Forward to AI
89
110
Host-->>Client: AI response
90
111
Client-->>Server: Response
91
-
else Client Request (based on server caps)
92
-
Client->>Server: Request (tools/resources)
93
-
Server-->>Client: Response
94
-
else Notifications (if supported)
112
+
end
113
+
114
+
loop Notifications
95
115
Server--)Client: Resource updates
96
116
Client--)Server: Status changes
97
117
end
98
118
99
119
Host->>Client: Terminate
100
-
Client->>Server: End session
120
+
Client->>-Server: End session
121
+
deactivate Server
101
122
```
102
123
103
124
Each capability unlocks specific protocol features for use during the session. For example:
104
-
- Resource subscriptions require the server to declare subscription support
125
+
- Implemented [server features]({{< ref "/specification/server" >}}) must be advertised in the server's capabilities
126
+
- Emitting resource subscription notifications requires the server to declare subscription support
105
127
- Tool invocation requires the server to declare tool capabilities
106
-
- Samplingrequires the client to declare sampling support
128
+
-[Sampling]({{< ref "/specification/client" >}}) requires the client to declare support in its capabilities
107
129
108
130
This capability negotiation ensures clients and servers have a clear understanding of supported functionality while maintaining protocol extensibility.
109
-
110
-
### Message Types
111
-
MCP defines three core message types based on [JSON-RPC 2.0](https://www.jsonrpc.org/specification):
112
-
113
-
-**Requests**: Bidirectional messages with method and parameters expecting a response
114
-
-**Responses**: Results or errors matching specific request IDs
115
-
-**Notifications**: One-way messages requiring no response
116
-
117
-
Each message type follows the JSON-RPC 2.0 specification for structure and delivery semantics.
118
-
119
-
## Protocol Features
120
-
121
-
### Server Features
122
-
Servers implement several foundational features that provide context and capabilities to clients:
123
-
124
-
-**Resources**: Structured data or content exposed via URIs that can be read and optionally subscribed to for updates
125
-
-**Prompts**: Pre-defined templates or instructions that guide language model interactions
126
-
-**Tools**: Executable functions that allow models to perform actions or retrieve information
127
-
-**Utilities**: Helper features for logging, argument completion, and other ancillary functions
128
-
129
-
The server features focus on exposing data and functionality in a controlled way while maintaining security boundaries.
130
-
131
-
### Client Features
132
-
Clients provide core features for interacting with servers and coordinating with hosts:
133
-
134
-
-**Sampling**: Ability to request and control language model interactions
135
-
-**Root Directory Access**: Controlled exposure of filesystem locations to servers
136
-
137
-
The client features emphasize safe integration of server capabilities while protecting user privacy and security.
Copy file name to clipboardExpand all lines: docs/specification/basic/_index.md
+30-24Lines changed: 30 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,47 +5,53 @@ cascade:
5
5
weight: 2
6
6
---
7
7
8
-
The Model Context Protocol (MCP) defines a set of JSON-RPC methods for communication between clients and servers in AI-assisted applications. MCP uses [JSON-RPC 2.0](https://www.jsonrpc.org/specification) as its base protocol.
All messages in MCP **MUST** follow the [JSON-RPC 2.0](https://www.jsonrpc.org/specification) specification. The protocol defines three fundamental types of messages:
12
+
All messages between MCP clients and servers**MUST** follow the [JSON-RPC 2.0](https://www.jsonrpc.org/specification) specification. The protocol defines three fundamental types of messages:
|`Requests`| Messages sent to initiate an operation | Must include unique ID and method name|
17
+
|`Responses`| Messages sent in reply to requests | Must include same ID as request |
18
+
|`Notifications`| One-way messages with no reply | Must not include an ID |
17
19
18
-
The Model Context Protocol consists of several key components that work together:
20
+
**Responses** are further sub-categorized as either **successful results** or **errors**. Results can follow any JSON object structure, while errors must include an error code and message at minimum.
21
+
22
+
## Protocol Layers
19
23
20
-
**Protocol Layers:**
24
+
The Model Context Protocol consists of several key components that work together:
21
25
22
-
-**Base Protocol**: Core JSON-RPC message types and fundamental operations such as capability exchange
26
+
-**Base Protocol**: Core JSON-RPC message types
23
27
-**Lifecycle Management**: Connection initialization, capability negotiation, and session control
24
28
-**Server Features**: Resources, prompts, and tools exposed by servers
25
-
-**Client Features**: Sampling and root directory capabilities
29
+
-**Client Features**: Sampling and root directory lists provided by clients
26
30
-**Utilities**: Cross-cutting concerns like logging and argument completion
27
31
28
32
All implementations **MUST** support the base protocol and lifecycle management components. Other components **MAY** be implemented based on the specific needs of the application.
29
33
30
34
These protocol layers establish clear separation of concerns while enabling rich interactions between clients and servers. The modular design allows implementations to support exactly the features they need.
31
35
32
-
### Model Context Protocol specific methods
33
-
34
-
MCP defines methods based on JSON-RPC that clients and servers implement:
36
+
See the following pages for more details on the different components:
Authentication and authorization are not currently part of the core MCP specification, but we are considering ways to introduce them in future. Join us in [GitHub Discussions](https://github.com/modelcontextprotocol/specification/discussions) to help shape the future of the protocol!
50
+
51
+
Clients and servers **MAY** negotiate their own custom authentication and authorization strategies.
46
52
47
-
Authentication mechanisms are not part of the core MCP specification. Implementations **MAY** provide authentication based on the transport they use.
53
+
## Schema
48
54
49
-
## Specification
55
+
The full specification of the protocol is defined as a [TypeScript schema](http://github.com/modelcontextprotocol/specification/tree/main/schema/schema.ts). This is the source of truth for all protocol messages and structures.
50
56
51
-
The official specification can be found in [TypeScript source](http://github.com/modelcontextprotocol/specification/tree/main/schema/schema.ts) and [JSON Schema](http://github.com/modelcontextprotocol/specification/tree/main/schema/schema.json) formats. The TypeScript version serves as the source of truth, while the JSON Schema version is generated from it.
57
+
There is also a [JSON Schema](http://github.com/modelcontextprotocol/specification/tree/main/schema/schema.json), which is automatically generated from the TypeScript source of truth, for use with various automated tooling.
0 commit comments