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/prompts.md
+23-32Lines changed: 23 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,15 +11,19 @@ The Model Context Protocol (MCP) provides a standardized way for servers to expo
11
11
12
12
## User Interaction Model
13
13
14
-
Prompts in MCP are commonly implemented through user-initiated interactions. One recommended implementation pattern is exposing prompts through user-initiated commands in the user interface, which allows users to naturally discover and invoke available prompts. An example of this pattern are slash commands.
14
+
Prompts are designed to be **user-controlled**, meaning they are exposed from servers to clients with the intention of the user being able to explicitly select them for use.
15
+
16
+
Typically, prompts would be triggered through user-initiated commands in the user interface, which allows users to naturally discover and invoke available prompts.
17
+
18
+
For example, as slash commands:
15
19
16
20

17
21
18
-
However, implementors are free to expose prompts through any interface pattern that suits their needs - the protocol itself does not mandate any specific user interaction model.
22
+
However, implementors are free to expose prompts through any interface pattern that suits their needs—the protocol itself does not mandate any specific user interaction model.
19
23
20
24
## Capabilities
21
25
22
-
Servers that support prompts MUST include a`prompts` capability in their `ServerCapabilities` during initialization:
26
+
Servers that support prompts **MUST** declare the`prompts` capability during [initialization]({{< ref "/specification/basic/lifecycle#initialization" >}}):
23
27
```json
24
28
{
25
29
"capabilities": {
@@ -30,23 +34,13 @@ Servers that support prompts MUST include a `prompts` capability in their `Serve
30
34
}
31
35
```
32
36
33
-
To omit change notifications, the server would not include `listChanged`:
34
-
35
-
```json
36
-
{
37
-
"capabilities": {
38
-
"prompts": {}
39
-
}
40
-
}
41
-
```
42
-
43
-
The `listChanged` property indicates that the server supports notifications about changes to the prompt list.
37
+
`listChanged` indicates whether the server will emit notifications when the list of available prompts changes.
44
38
45
39
## Protocol Messages
46
40
47
41
### Listing Prompts
48
42
49
-
To retrieve available prompts, clients send a `prompts/list` request. This operation supports pagination through the standard cursor mechanism.
43
+
To retrieve available prompts, clients send a `prompts/list` request. This operation supports [pagination]({{< ref "/specification/server/utilities/pagination" >}}).
50
44
51
45
**Request:**
52
46
```json
@@ -69,7 +63,7 @@ To retrieve available prompts, clients send a `prompts/list` request. This opera
69
63
"prompts": [
70
64
{
71
65
"name": "code_review",
72
-
"description": "Analyze code quality and suggest improvements",
66
+
"description": "Asks the LLM to analyze code quality and suggest improvements",
73
67
"arguments": [
74
68
{
75
69
"name": "code",
@@ -86,7 +80,7 @@ To retrieve available prompts, clients send a `prompts/list` request. This opera
86
80
87
81
### Getting a Prompt
88
82
89
-
To retrieve a specific prompt, clients send a `prompts/get` request. Arguments support auto-completion through [the completion API]({{< relref "utilities/completion.md" >}}):
83
+
To retrieve a specific prompt, clients send a `prompts/get` request. Arguments may be auto-completed through [the completion API]({{< ref "/specification/server/utilities/completion" >}})):
90
84
91
85
**Request:**
92
86
```json
@@ -115,7 +109,7 @@ To retrieve a specific prompt, clients send a `prompts/get` request. Arguments s
115
109
"role": "user",
116
110
"content": {
117
111
"type": "text",
118
-
"text": "Please review this code..."
112
+
"text": "Please review this Python code:\ndef hello():\n print('world')"
119
113
}
120
114
}
121
115
]
@@ -125,7 +119,7 @@ To retrieve a specific prompt, clients send a `prompts/get` request. Arguments s
125
119
126
120
### List Changed Notification
127
121
128
-
When prompts change, servers that support `listChanged`MAY send a notification:
122
+
When the list of available prompts changes, servers that declared the `listChanged`capability **SHOULD** send a notification:
129
123
130
124
```json
131
125
{
@@ -149,10 +143,12 @@ sequenceDiagram
149
143
Client->>Server: prompts/get
150
144
Server-->>Client: Prompt content
151
145
152
-
Note over Client,Server: Changes
153
-
Server--)Client: prompts/list_changed
154
-
Client->>Server: prompts/list
155
-
Server-->>Client: Updated prompts
146
+
opt listChanged
147
+
Note over Client,Server: Changes
148
+
Server--)Client: prompts/list_changed
149
+
Client->>Server: prompts/list
150
+
Server-->>Client: Updated prompts
151
+
end
156
152
```
157
153
158
154
## Data Types
@@ -223,15 +219,10 @@ Servers SHOULD return standard JSON-RPC errors for common failure cases:
223
219
224
220
## Implementation Considerations
225
221
226
-
1. Servers SHOULD validate prompt arguments before processing
227
-
2. Clients SHOULD handle pagination for large prompt lists
228
-
3. Both parties SHOULD respect capability negotiation
222
+
1. Servers **SHOULD** validate prompt arguments before processing
223
+
2. Clients **SHOULD** handle pagination for large prompt lists
224
+
3. Both parties **SHOULD** respect capability negotiation
229
225
230
226
## Security
231
227
232
-
Implementations MUST carefully validate all prompt inputs and arguments to prevent injection attacks or unauthorized access to resources.
0 commit comments