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
Copy file name to clipboardExpand all lines: docs/spec/_index.md
+30Lines changed: 30 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,6 +50,36 @@ In addition to basic primitives, MCP offers a set of control flow messages.
50
50
***Logging:** Anything related to how the server processes logs.
51
51
***Completion**: Supports completion of server arguments on the client side. See
52
52
53
+
## Error Codes
54
+
55
+
MCP uses standard JSON-RPC error codes as well as protocol-specific codes:
56
+
57
+
Standard JSON-RPC error codes:
58
+
-`-32700`: Parse error
59
+
-`-32600`: Invalid request
60
+
-`-32601`: Method not found
61
+
-`-32602`: Invalid params
62
+
-`-32603`: Internal error
63
+
64
+
All error responses MUST include:
65
+
- A numeric error code
66
+
- A human-readable message
67
+
- Optional additional error data
68
+
69
+
Example error response:
70
+
```json
71
+
{
72
+
"jsonrpc": "2.0",
73
+
"id": 1,
74
+
"error": {
75
+
"code": -32602,
76
+
"message": "Required parameter missing",
77
+
"data": {
78
+
"parameter": "uri"
79
+
}
80
+
}
81
+
}
82
+
```
53
83
# Use cases
54
84
Most use cases are around enabling people to build their own specific workflows and integrations. MCP enables engineers and teams to **tailor AI to their needs.**
Copy file name to clipboardExpand all lines: docs/spec/jsonrpc.md
+89Lines changed: 89 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,71 @@ HTTP with Server-Sent Events (SSE)
26
26
27
27
### Message Format
28
28
29
+
### Progress Notifications
30
+
31
+
MCP supports progress tracking for long-running operations through out-of-band notifications. Progress notifications allow the sender of a request to provide updates about the operation's progress.
32
+
33
+
To request progress notifications, include a `progressToken` in the request metadata:
34
+
35
+
```json
36
+
{
37
+
"jsonrpc": "2.0",
38
+
"id": 1,
39
+
"method": "some_method",
40
+
"params": {
41
+
"_meta": {
42
+
"progressToken": "abc123"
43
+
}
44
+
}
45
+
}
46
+
```
47
+
48
+
The receiver MAY then send progress notifications using the same token:
49
+
50
+
```json
51
+
{
52
+
"jsonrpc": "2.0",
53
+
"method": "notifications/progress",
54
+
"params": {
55
+
"progressToken": "abc123",
56
+
"progress": 50,
57
+
"total": 100
58
+
}
59
+
}
60
+
```
61
+
62
+
### Pagination
63
+
64
+
Many list operations in MCP support pagination using cursors. The server response will include a `nextCursor` if more results are available:
65
+
66
+
```json
67
+
{
68
+
"jsonrpc": "2.0",
69
+
"id": 1,
70
+
"result": {
71
+
"resources": [...],
72
+
"nextCursor": "next_page_token"
73
+
}
74
+
}
75
+
```
76
+
77
+
Clients can include a `cursor` parameter containing the opaque token from the server,
78
+
to obtain the next page starting from the cursor:
79
+
80
+
```json
81
+
{
82
+
"jsonrpc": "2.0",
83
+
"id": 1,
84
+
"method": "resources/list",
85
+
"params": {
86
+
"cursor": "some_opaque_token"
87
+
}
88
+
}
89
+
```
90
+
91
+
92
+
Clients should continue making requests with the provided cursor until no `nextCursor` is returned.
93
+
29
94
All messages in MCP **MUST** follow the [JSON-RPC 2.0](https://www.jsonrpc.org/specification) specification. The protocol defines three types of messages:
30
95
31
96
1. Requests
@@ -73,6 +138,30 @@ Authentication mechanisms are not part of the core MCP specification. Implementa
73
138
74
139
The MCP version is declared in the `initialize` request and response. Clients and servers **MUST** agree on a compatible protocol version to proceed with communication.
75
140
141
+
### Ping Messages
142
+
143
+
Either party can send ping messages to check if the other is still alive and responsive:
144
+
145
+
```json
146
+
{
147
+
"jsonrpc": "2.0",
148
+
"id": 1,
149
+
"method": "ping"
150
+
}
151
+
```
152
+
153
+
The receiver MUST respond promptly with an empty result:
154
+
155
+
```json
156
+
{
157
+
"jsonrpc": "2.0",
158
+
"id": 1,
159
+
"result": {}
160
+
}
161
+
```
162
+
163
+
If the receiver fails to respond in a timely manner, the sender MAY disconnect.
164
+
76
165
## Specification
77
166
78
167
The conical specification can be found at [Model Context Protocol](http://github.com/modelcontextprotocol/spec/tree/main/spec/schema.ts). The specification of the data format
Copy file name to clipboardExpand all lines: docs/spec/resources.md
+31-1Lines changed: 31 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,6 +43,36 @@ In this example, the server supports basic resource operations, subscriptions, a
43
43
A Resource in the Model Context Protocol (MCP) represents a discrete unit of data that a server can provide to clients. Each Resource is uniquely identified by a URI and may have associated metadata such as a name and MIME type. Resources can represent various types of data, including files, database records, or application-specific information.
44
44
45
45
### Resource Templates
46
+
To retrieve available resource templates from the server, the client MUST send a `resources/templates/list` request:
47
+
48
+
```json
49
+
{
50
+
"jsonrpc": "2.0",
51
+
"id": 1,
52
+
"method": "resources/templates/list"
53
+
}
54
+
```
55
+
56
+
The server MUST respond with a list of resource templates:
57
+
58
+
```json
59
+
{
60
+
"jsonrpc": "2.0",
61
+
"id": 1,
62
+
"result": {
63
+
"resourceTemplates": [
64
+
{
65
+
"uriTemplate": "file:///{path}",
66
+
"name": "Local File",
67
+
"description": "Access local files",
68
+
"mimeType": "application/octet-stream"
69
+
}
70
+
]
71
+
}
72
+
}
73
+
```
74
+
75
+
Resource templates use URI templates as defined in [RFC 6570](https://datatracker.ietf.org/doc/html/rfc6570) to specify parameterized resource URIs.
46
76
47
77
Resource Templates are URI patterns that describe a class of resources that can be dynamically generated or accessed. They use URI templates as defined in [RFC 6570](https://datatracker.ietf.org/doc/html/rfc6570) to specify how clients can construct valid resource URIs. Templates allow servers to expose a potentially large or dynamic set of resources without explicitly listing each one. Clients can use these templates to generate specific resource URIs as needed.
0 commit comments