Skip to content

Commit 9525a0a

Browse files
committed
feat: add listChanged capability flags
Add capability flags to indicate whether a server supports sending notifications when its list of prompts, resources, or tools changes. This helps clients know whether to expect list_changed notifications.
1 parent 52aa02b commit 9525a0a

File tree

4 files changed

+88
-25
lines changed

4 files changed

+88
-25
lines changed

docs/spec/prompts.md

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,35 @@ Prompts enable servers to provide templated conversations or instructions to cli
99
An example of a prompt as a slash command in the Zed editor:
1010
![Slash Command Example](slash-command.png)
1111

12+
## Capabilities
13+
14+
To indicate support for the Prompts API, servers MUST include a `prompts` capability in their `ServerCapabilities` during initialization. The `prompts` capability SHOULD be an empty object:
15+
16+
```json
17+
{
18+
"capabilities": {
19+
"prompts": {}
20+
}
21+
```
22+
23+
Clients SHOULD check for this capability before using the Prompts API.
24+
25+
Servers MAY support notifications for changes to the prompt list. If a server supports this feature, it SHOULD include a `listChanged` property in its `prompts` capability:
26+
27+
```json
28+
{
29+
"capabilities": {
30+
"prompts": {
31+
"listChanged": true
32+
}
33+
}
34+
}
35+
```
36+
37+
If a server supports this capability, it MAY send `notifications/prompts/list_changed` notifications to inform the client about changes to the available prompts.
38+
39+
## Concepts
40+
1241
### Prompt
1342

1443
A Prompt in the Model Context Protocol (MCP) represents a pre-defined set of messages or instructions that a server can provide to clients. Each Prompt is uniquely identified by a name and may have associated metadata such as a description and required arguments. Prompts can represent various types of interactions, including code reviews, data analysis tasks, or creative writing prompts.
@@ -221,24 +250,29 @@ Example:
221250
}
222251
```
223252

224-
## Error Handling
225-
226-
Clients MUST be prepared to handle cases where listed prompts become unavailable between listing and retrieval attempts. Servers SHOULD provide appropriate error responses in such scenarios.
227-
228-
## Security Considerations
253+
### Prompt List Changed Notification
229254

230-
Implementations MUST carefully consider the security implications of exposing prompts, especially when dealing with sensitive data or customizable templates. Proper authentication and authorization mechanisms SHOULD be in place to prevent unauthorized access to prompts.
255+
If the server supports the `listChanged` capability for prompts, it MAY send a `notifications/prompts/list_changed` notification to inform the client that the list of available prompts has changed.
231256

232-
## Capabilities
257+
#### Notification
233258

234-
To indicate support for the Prompts API, servers MUST include a `prompts` capability in their `ServerCapabilities` during initialization. The `prompts` capability SHOULD be an empty object:
259+
Method: `notifications/prompts/list_changed`
260+
Params: None
235261

262+
Example:
236263
```json
237264
{
238-
"capabilities": {
239-
"prompts": {}
240-
}
265+
"jsonrpc": "2.0",
266+
"method": "notifications/prompts/list_changed"
241267
}
242268
```
243269

244-
Clients SHOULD check for this capability before using the Prompts API.
270+
Upon receiving this notification, clients SHOULD request an updated prompt list using the `prompts/list` method to ensure they have the most up-to-date information about available prompts.
271+
272+
## Error Handling
273+
274+
Clients MUST be prepared to handle cases where listed prompts become unavailable between listing and retrieval attempts. Servers SHOULD provide appropriate error responses in such scenarios.
275+
276+
## Security Considerations
277+
278+
Implementations MUST carefully consider the security implications of exposing prompts, especially when dealing with sensitive data or customizable templates. Proper authentication and authorization mechanisms SHOULD be in place to prevent unauthorized access to prompts.

docs/spec/resources.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ weight: 4
77

88
Resources enable servers to expose arbitrary data to clients in a structured way, specifically for providing context to language models. Clients can discover available resources, read their contents, and optionally subscribe to updates. Users may explicitly attach resources via the client UI, or clients can intelligently select appropriate resources to add to the context. Each resource is uniquely identified by a [URI](https://datatracker.ietf.org/doc/html/rfc3986).
99

10-
## Required Capabilities
10+
## Capabilities
1111

12-
To use resources, the server MUST include the `resources` capability in its `ServerCapabilities` object during the initialization process. The `resources` capability MAY include a `subscribe` field set to `true` if the server supports resource subscriptions.
12+
To use resources, the server MUST include the `resources` capability in its `ServerCapabilities` object during the initialization process. The `resources` capability MAY include a `subscribe` field set to `true` if the server supports resource subscriptions. Additionally, the `resources` capability MAY include a `listChanged` field set to `true` if the server supports notifications for changes to the resource list.
1313

1414
Clients intending to use resources SHOULD check for the presence of the `resources` capability in the server's capabilities before attempting to use any resource-related methods. If the capability is not present, the client MUST NOT attempt to use resource-related methods, as the server does not support them.
1515

@@ -22,19 +22,20 @@ Example of server capabilities with basic resource support:
2222
}
2323
```
2424

25-
Example of server capabilities including resource support:
25+
Example of server capabilities including resource support with subscriptions and list change notifications:
2626

2727
```json
2828
{
2929
"capabilities": {
3030
"resources": {
31-
"subscribe": true
31+
"subscribe": true,
32+
"listChanged": true
3233
}
3334
}
3435
}
3536
```
3637

37-
In this example, the server supports both basic resource operations and subscriptions. If `subscribe` is omitted or set to `false`, the server only supports basic resource operations without subscriptions.
38+
In this example, the server supports basic resource operations, subscriptions, and notifications for resource list changes. If `subscribe` is omitted or set to `false`, the server only supports basic resource operations without subscriptions. Similarly, if `listChanged` is omitted or set to `false`, the server does not support notifications for changes to the resource list.
3839

3940
## Concepts
4041
### Resource
@@ -345,7 +346,9 @@ Servers MUST only send this notification for resources that clients have explici
345346

346347
### Resource List Changed Notification
347348

348-
When the list of available resources has changed, the server MUST send a `notifications/resources/list_changed` notification to the client.
349+
If the server supports the `listChanged` capability for resources, it MAY send a `notifications/resources/list_changed` notification to inform the client that the list of available resources has changed.
350+
351+
#### Notification
349352

350353
Method: `notifications/resources/list_changed`
351354
Params: None
@@ -358,7 +361,7 @@ Example:
358361
}
359362
```
360363

361-
Upon receiving this notification, clients SHOULD request an updated resource list using the `resources/list` method.
364+
Upon receiving this notification, clients SHOULD request an updated resource list using the `resources/list` method to ensure they have the most up-to-date information about available resources.
362365

363366
## Security Considerations
364367

schema/schema.json

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,14 +1326,22 @@
13261326
"type": "object"
13271327
},
13281328
"prompts": {
1329-
"additionalProperties": true,
13301329
"description": "Present if the server offers any prompt templates.",
1331-
"properties": {},
1330+
"properties": {
1331+
"listChanged": {
1332+
"description": "Whether this server supports notifications for changes to the prompt list.",
1333+
"type": "boolean"
1334+
}
1335+
},
13321336
"type": "object"
13331337
},
13341338
"resources": {
13351339
"description": "Present if the server offers any resources to read.",
13361340
"properties": {
1341+
"listChanged": {
1342+
"description": "Whether this server supports notifications for changes to the resource list.",
1343+
"type": "boolean"
1344+
},
13371345
"subscribe": {
13381346
"description": "Whether this server supports subscribing to resource updates.",
13391347
"type": "boolean"
@@ -1342,9 +1350,13 @@
13421350
"type": "object"
13431351
},
13441352
"tools": {
1345-
"additionalProperties": true,
13461353
"description": "Present if the server offers any tools to call.",
1347-
"properties": {},
1354+
"properties": {
1355+
"listChanged": {
1356+
"description": "Whether this server supports notifications for changes to the tool list.",
1357+
"type": "boolean"
1358+
}
1359+
},
13481360
"type": "object"
13491361
}
13501362
},

schema/schema.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,12 @@ export interface ServerCapabilities {
173173
/**
174174
* Present if the server offers any prompt templates.
175175
*/
176-
prompts?: object;
176+
prompts?: {
177+
/**
178+
* Whether this server supports notifications for changes to the prompt list.
179+
*/
180+
listChanged?: boolean;
181+
};
177182
/**
178183
* Present if the server offers any resources to read.
179184
*/
@@ -182,11 +187,20 @@ export interface ServerCapabilities {
182187
* Whether this server supports subscribing to resource updates.
183188
*/
184189
subscribe?: boolean;
190+
/**
191+
* Whether this server supports notifications for changes to the resource list.
192+
*/
193+
listChanged?: boolean;
185194
};
186195
/**
187196
* Present if the server offers any tools to call.
188197
*/
189-
tools?: object;
198+
tools?: {
199+
/**
200+
* Whether this server supports notifications for changes to the tool list.
201+
*/
202+
listChanged?: boolean;
203+
};
190204
}
191205

192206
/**

0 commit comments

Comments
 (0)