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/cancellation/cancellation.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,18 +7,18 @@ uid: cancellation
7
7
8
8
## Cancellation
9
9
10
-
MCP supports [cancellation] of in-flight requests. Either side can cancel a previously issued request, and `CancellationToken` parameters on MCP methods are wired to send and receive `notifications/cancelled` notifications over the protocol.
10
+
MCP supports [cancellation] of in-flight requests. Either side can cancel a previously issued request, and <xref:System.Threading.CancellationToken> parameters on MCP methods are wired to send and receive `notifications/cancelled` notifications over the protocol.
When a `CancellationToken` passed to a client method (such as <xref:ModelContextProtocol.Client.McpClient.CallToolAsync*>) is cancelled, a `notifications/cancelled` notification is sent to the server with the request ID. On the server side, the `CancellationToken` provided to the tool method is then triggered, allowing the handler to stop work gracefully. This same mechanism works in reverse for server-to-client requests.
17
+
When a <xref:System.Threading.CancellationToken> passed to a client method (such as <xref:ModelContextProtocol.Client.McpClient.CallToolAsync*>) is cancelled, a `notifications/cancelled` notification is sent to the server with the request ID. On the server side, the <xref:System.Threading.CancellationToken> provided to the tool method is then triggered, allowing the handler to stop work gracefully. This same mechanism works in reverse for server-to-client requests.
18
18
19
19
### Server-side cancellation handling
20
20
21
-
Server tool methods receive a `CancellationToken` that is triggered when the client sends a cancellation notification. Pass this token through to any async operations so they stop promptly:
21
+
Server tool methods receive a <xref:System.Threading.CancellationToken> that is triggered when the client sends a cancellation notification. Pass this token through to any async operations so they stop promptly:
@@ -35,7 +35,7 @@ public static async Task<string> LongComputation(
35
35
}
36
36
```
37
37
38
-
When the client sends a cancellation notification, the `OperationCanceledException` propagates back to the client as a cancellation response.
38
+
When the client sends a cancellation notification, the <xref:System.OperationCanceledException> propagates back to the client as a cancellation response.
Server capabilities are automatically inferred from the configured features. For example, registering tools with `.WithTools<T>()` automatically declares the tools capability.
@@ -63,24 +63,24 @@ Server capabilities are automatically inferred from the configured features. For
63
63
64
64
Before using an optional feature, check whether the other side declared the corresponding capability.
if (client.ServerCapabilities.Completionsisnotnull)
102
102
{
103
103
varcompletions=awaitclient.CompleteAsync(
@@ -112,10 +112,10 @@ if (client.ServerCapabilities.Completions is not null)
112
112
During connection setup, the client and server negotiate a mutually supported MCP protocol version. After initialization, the negotiated version is available on both sides:
Copy file name to clipboardExpand all lines: docs/concepts/completions/completions.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,8 +15,8 @@ MCP [completions] allow servers to provide argument auto-completion suggestions
15
15
16
16
Completions work with two types of references:
17
17
18
-
-**Prompt argument completions**: Suggest values for prompt parameters (e.g., language names, style options)
19
-
-**Resource template argument completions**: Suggest values for URI template parameters (e.g., file paths, resource IDs)
18
+
-**Prompt argument completions**: Suggest values for prompt parameters (for example, language names and style options).
19
+
-**Resource template argument completions**: Suggest values for URI template parameters (for example, file paths and resource IDs).
20
20
21
21
The server returns a <xref:ModelContextProtocol.Protocol.Completion> object containing a list of suggested values, an optional total count, and a flag indicating if more values are available.
22
22
@@ -36,7 +36,7 @@ builder.Services.AddMcpServer()
36
36
37
37
varargument=@params.Argument;
38
38
39
-
// Handle prompt argument completions
39
+
// Handle prompt argument completions.
40
40
if (@params.RefisPromptReferencepromptRef)
41
41
{
42
42
varsuggestions=argument.Nameswitch
@@ -46,7 +46,7 @@ builder.Services.AddMcpServer()
46
46
_=>Array.Empty<string>()
47
47
};
48
48
49
-
// Filter suggestions based on what the user has typed so far
49
+
// Filter suggestions based on what the user has typed so far.
### Automatic completions with AllowedValuesAttribute
85
85
86
-
For parameters with a known set of valid values, you can use `System.ComponentModel.DataAnnotations.AllowedValuesAttribute` on `string` parameters of prompts or resource templates. The server will automatically surface those values as completions without needing a custom completion handler.
86
+
For parameters with a known set of valid values, you can use <xref:System.ComponentModel.DataAnnotations.AllowedValuesAttribute> on `string` parameters of prompts or resource templates. The server will automatically surface those values as completions without needing a custom completion handler.
87
87
88
88
#### Prompt parameters
89
89
@@ -124,13 +124,13 @@ Clients request completions using <xref:ModelContextProtocol.Client.McpClient.Co
0 commit comments