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/specification/server/resources.md
+40-33Lines changed: 40 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,15 +12,20 @@ The Model Context Protocol (MCP) provides a standardized way for servers to expo
12
12
13
13
## User Interaction Model
14
14
15
-
Resources in MCP are designed to be application-driven, with clients determining how to incorporate context based on their needs. Applications can expose resources through UI elements for explicit selection, while implementing intelligent features for automatic context inclusion, searching and filtering. A recommended pattern is a context picker showing resources in a tree/list view that combines manual selection with automated context handling.
15
+
Resources in MCP are designed to be **application-driven**, with clients determining how to incorporate context based on their needs.
16
+
17
+
For example, applications could:
18
+
* Expose resources through UI elements for explicit selection, in a tree or list view
19
+
* Allow the user to search through and filter available resources
20
+
* Implement automatic context inclusion, based on heuristics or the AI model's selection
16
21
17
22

18
23
19
-
However, implementations are free to expose resources through any interface pattern that suits their needs - the protocol itself does not mandate any specific user interaction model.
24
+
However, implementations are free to expose resources through any interface pattern that suits their needs—the protocol itself does not mandate any specific user interaction model.
20
25
21
26
## Capabilities
22
27
23
-
Servers that support resources MUST include a`resources` capability in their `ServerCapabilities` during initialization. The capability object can specify optional features:
28
+
Servers that support resources **MUST** declare the`resources` capability:
24
29
25
30
```json
26
31
{
@@ -33,7 +38,11 @@ Servers that support resources MUST include a `resources` capability in their `S
33
38
}
34
39
```
35
40
36
-
Both `subscribe` and `listChanged` are optional - servers can support neither, either, or both:
41
+
The capability supports two optional features:
42
+
-`subscribe`: whether the client can subscribe to be notified of changes to individual resources.
43
+
-`listChanged`: whether the server will emit notifications when the list of available resources changes.
44
+
45
+
Both `subscribe` and `listChanged` are optional—servers can support neither, either, or both:
37
46
38
47
```json
39
48
{
@@ -63,15 +72,11 @@ Both `subscribe` and `listChanged` are optional - servers can support neither, e
63
72
}
64
73
```
65
74
66
-
The capability supports two optional features:
67
-
-`subscribe`: Server supports subscribing to resource updates
68
-
-`listChanged`: Server supports notifications about changes to the resource list
69
-
70
75
## Protocol Messages
71
76
72
77
### Listing Resources
73
78
74
-
To discover available resources, clients send a `resources/list` request. This operation supports pagination through the standard cursor mechanism.
79
+
To discover available resources, clients send a `resources/list` request. This operation supports [pagination]({{< ref "/specification/server/utilities/pagination" >}}).
75
80
76
81
**Request:**
77
82
```json
@@ -94,7 +99,7 @@ To discover available resources, clients send a `resources/list` request. This o
94
99
"resources": [
95
100
{
96
101
"uri": "file:///project/src/main.rs",
97
-
"name": "Main source file",
102
+
"name": "main.rs",
98
103
"description": "Primary application entry point",
99
104
"mimeType": "text/x-rust"
100
105
}
@@ -139,7 +144,7 @@ To retrieve resource contents, clients send a `resources/read` request:
139
144
140
145
### Resource Templates
141
146
142
-
Resource templates allow servers to expose parameterized resources using URI templates ([RFC 6570](https://datatracker.ietf.org/doc/html/rfc6570)):
147
+
Resource templates allow servers to expose parameterized resources using [URI templates](https://datatracker.ietf.org/doc/html/rfc6570):
143
148
144
149
**Request:**
145
150
```json
@@ -255,22 +260,31 @@ Resources can contain either text or binary data:
255
260
256
261
## Common URI Schemes
257
262
258
-
The protocol defines several standard URI schemes:
263
+
The protocol defines several standard URI schemes. This list not exhaustive—implementations are always free to use additional, custom URI schemes.
264
+
265
+
### https://
266
+
267
+
Used to represent a resource available on the web.
268
+
269
+
Servers **SHOULD** use this scheme only when the client is able to fetch and load the resource directly from the web on its own—that is, it doesn’t need to read the resource via the MCP server.
| git:// | Git repositories | For version control integration |
266
-
| data: | Inline data | For small embedded resources |
271
+
For other use cases, servers **SHOULD** prefer to use another URI scheme, or define a custom one, even if the server will itself be downloading resource contents over the internet.
272
+
273
+
### file://
274
+
275
+
Used to identify resources that behave like a filesystem. However, the resources do not need to map to an actual physical filesystem.
276
+
277
+
MCP servers **MAY** identify file:// resources with an [XDG MIME type](https://specifications.freedesktop.org/shared-mime-info-spec/0.14/ar01s02.html#id-1.3.14), like `inode/directory`, to represent non-regular files (such as directories) that don’t otherwise have a standard MIME type.
278
+
279
+
### git://
280
+
281
+
Git version control integration.
267
282
268
283
## Error Handling
269
284
270
285
Servers SHOULD return standard JSON-RPC errors for common failure cases:
271
286
272
-
- Resource not found: `-32001`
273
-
- Permission denied: `-32002`
287
+
- Resource not found: `-32002`
274
288
- Internal errors: `-32603`
275
289
276
290
Example error:
@@ -279,7 +293,7 @@ Example error:
279
293
"jsonrpc": "2.0",
280
294
"id": 5,
281
295
"error": {
282
-
"code": -32001,
296
+
"code": -32002,
283
297
"message": "Resource not found",
284
298
"data": {
285
299
"uri": "file:///nonexistent.txt"
@@ -290,14 +304,7 @@ Example error:
290
304
291
305
## Security Considerations
292
306
293
-
1. Servers MUST validate all resource URIs
294
-
2. Access controls SHOULD be implemented for sensitive resources
295
-
3. Binary data MUST be properly encoded
296
-
4. Resource permissions SHOULD be checked before operations
0 commit comments