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/concepts/resources.mdx
+70-51Lines changed: 70 additions & 51 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ Each resource is identified by a unique URI and can contain either text or binar
24
24
Resources are identified using URIs that follow this format:
25
25
26
26
```
27
-
[protocol]://[path]
27
+
[protocol]://[host]/[path]
28
28
```
29
29
30
30
For example:
@@ -42,7 +42,7 @@ Resources can contain two types of content:
42
42
43
43
Text resources contain UTF-8 encoded text data. These are suitable for:
44
44
- Source code
45
-
- Configuration files
45
+
- Configuration files
46
46
- Log files
47
47
- JSON/XML data
48
48
- Plain text
@@ -66,37 +66,39 @@ Servers expose a list of concrete resources via the `resources/list` endpoint. E
66
66
67
67
```typescript
68
68
{
69
-
uri: string; // Unique identifier for the resource
70
-
name: string; // Human-readable name
69
+
uri: string; // Unique identifier for the resource
70
+
name: string; // Human-readable name
71
71
description?:string; // Optional description
72
-
mimeType?:string; // Optional MIME type
72
+
mimeType?:string; // Optional MIME type
73
73
}
74
74
```
75
75
76
-
### Resource templates
76
+
### Resource templates
77
77
78
-
For dynamic resources, servers can expose URI templates that clients can use to construct valid resource URIs:
78
+
For dynamic resources, servers can expose [URI templates](https://datatracker.ietf.org/doc/html/rfc6570) that clients can use to construct valid resource URIs:
79
79
80
80
```typescript
81
81
{
82
82
uriTemplate: string; // URI template following RFC 6570
83
83
name: string; // Human-readable name for this type
84
84
description?:string; // Optional description
85
-
mimeType?:string; // Optional MIME type for all matching resources
85
+
mimeType?:string; // Optional MIME type for all matching resources
86
86
}
87
87
```
88
88
89
89
## Reading resources
90
90
91
-
To read a resource, clients make a `resources/read` request with the resource URI. The server responds with:
91
+
To read a resource, clients make a `resources/read` request with the resource URI.
92
+
93
+
The server responds with a list of resource contents:
92
94
93
95
```typescript
94
96
{
95
97
contents: [
96
98
{
97
-
uri: string; // The requested URI
99
+
uri: string; // The URI of the resource
98
100
mimeType?:string; // Optional MIME type
99
-
101
+
100
102
// One of:
101
103
text?:string; // For text resources
102
104
blob?:string; // For binary resources (base64 encoded)
@@ -105,6 +107,10 @@ To read a resource, clients make a `resources/read` request with the resource UR
105
107
}
106
108
```
107
109
110
+
<Tip>
111
+
Servers may return multiple resources in response to one `resources/read` request. This could be used, for example, to return a list of files inside a directory when the directory is read.
112
+
</Tip>
113
+
108
114
## Resource updates
109
115
110
116
MCP supports real-time updates for resources through two mechanisms:
@@ -113,7 +119,7 @@ MCP supports real-time updates for resources through two mechanisms:
113
119
114
120
Servers can notify clients when their list of available resources changes via the `notifications/resources/list_changed` notification.
115
121
116
-
### Content changes
122
+
### Content changes
117
123
118
124
Clients can subscribe to updates for specific resources:
119
125
@@ -126,45 +132,58 @@ Clients can subscribe to updates for specific resources:
126
132
127
133
Here's a simple example of implementing resource support in an MCP server:
0 commit comments