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/elicitation/elicitation.md
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,21 +15,22 @@ Servers request structured data from users with the <xref:ModelContextProtocol.S
15
15
The C# SDK registers an instance of <xref:ModelContextProtocol.Server.McpServer> with the dependency injection container,
16
16
so tools can simply add a parameter of type <xref:ModelContextProtocol.Server.McpServer> to their method signature to access it.
17
17
18
-
The MCP Server must specify the schema of each input value it is requesting from the user.
19
-
Primitive types (string, number, boolean) and enum types are supported for elicitation requests.
20
-
The schema may include a description to help the user understand what is being requested.
18
+
The MCP Server must specify the schema of each input value it's requesting from the user.
19
+
Primitive types (string, number, Boolean) and enum types are supported for elicitation requests.
20
+
The schema might include a description to help the user understand what's being requested.
21
21
22
22
For enum types, the SDK supports several schema formats:
23
-
-**UntitledSingleSelectEnumSchema**: A single-select enum where the enum values serve as both the value and display text
24
-
-**TitledSingleSelectEnumSchema**: A single-select enum with separate display titles for each option (using JSON Schema `oneOf` with `const` and `title`)
25
-
-**UntitledMultiSelectEnumSchema**: A multi-select enum allowing multiple values to be selected
26
-
-**TitledMultiSelectEnumSchema**: A multi-select enum with display titles for each option
27
-
-**LegacyTitledEnumSchema** (deprecated): The legacy enum schema using `enumNames` for backward compatibility
23
+
24
+
-**UntitledSingleSelectEnumSchema**: A single-select enum where the enum values serve as both the value and display text.
25
+
-**TitledSingleSelectEnumSchema**: A single-select enum with separate display titles for each option (using JSON Schema `oneOf` with `const` and `title`).
26
+
-**UntitledMultiSelectEnumSchema**: A multi-select enum allowing multiple values to be selected.
27
+
-**TitledMultiSelectEnumSchema**: A multi-select enum with display titles for each option.
28
+
-**LegacyTitledEnumSchema** (deprecated): The legacy enum schema using `enumNames` for backward compatibility.
28
29
29
30
The server can request a single input or multiple inputs at once.
30
31
To help distinguish multiple inputs, each input has a unique name.
31
32
32
-
The following example demonstrates how a server could request a boolean response from the user.
33
+
The following example demonstrates how a server could request a Boolean response from the user.
@@ -46,7 +47,6 @@ This will be highly dependent on the client application and how it interacts wit
46
47
If the user provides the requested information, the ElicitationHandler should return an <xref:ModelContextProtocol.Protocol.ElicitResult> with the action set to "accept" and the content containing the user's input.
47
48
If the user does not provide the requested information, the ElicitationHandler should return an [<xref:ModelContextProtocol.Protocol.ElicitResult> with the action set to "reject" and no content.
48
49
49
-
Below is an example of how a console application might handle elicitation requests.
50
-
Here's an example implementation:
50
+
Here's an example implementation of how a console application might handle elicitation requests:
@@ -214,22 +218,26 @@ public class RestrictedTools
214
218
The authorization filters work differently for list operations versus individual operations:
215
219
216
220
#### List Operations (ListTools, ListPrompts, ListResources)
221
+
217
222
For list operations, the filters automatically remove unauthorized items from the results. Users only see tools, prompts, or resources they have permission to access.
For individual operations, the filters throw an `McpException` with "Access forbidden" message. These get turned into JSON-RPC errors if uncaught by middleware.
221
227
222
228
### Filter Execution Order and Authorization
223
229
224
230
Authorization filters are applied automatically when you call `AddAuthorizationFilters()`. These filters run at a specific point in the filter pipeline, which means:
225
231
226
232
**Filters added before authorization filters** can see:
227
-
- Unauthorized requests for operations before they are rejected by the authorization filters
228
-
- Complete listings for unauthorized primitives before they are filtered out by the authorization filters
233
+
234
+
- Unauthorized requests for operations before they are rejected by the authorization filters.
235
+
- Complete listings for unauthorized primitives before they are filtered out by the authorization filters.
229
236
230
237
**Filters added after authorization filters** will only see:
231
-
- Authorized requests that passed authorization checks
232
-
- Filtered listings containing only authorized primitives
238
+
239
+
- Authorized requests that passed authorization checks.
240
+
- Filtered listings containing only authorized primitives.
233
241
234
242
This allows you to implement logging, metrics, or other cross-cutting concerns that need to see all requests, while still maintaining proper authorization:
235
243
@@ -312,6 +320,6 @@ You can also create custom authorization filters using the filter methods:
312
320
313
321
Within filters, you have access to:
314
322
315
-
-`context.User` - The current user's `ClaimsPrincipal`
316
-
-`context.Services` - The request's service provider for resolving authorization services
317
-
-`context.MatchedPrimitive` - The matched tool/prompt/resource with its metadata including authorization attributes via `context.MatchedPrimitive.Metadata`
323
+
-`context.User` - The current user's `ClaimsPrincipal`.
324
+
-`context.Services` - The request's service provider for resolving authorization services.
325
+
-`context.MatchedPrimitive` - The matched tool/prompt/resource with its metadata including authorization attributes via `context.MatchedPrimitive.Metadata`.
Copy file name to clipboardExpand all lines: docs/concepts/httpcontext/httpcontext.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,11 +7,11 @@ uid: httpcontext
7
7
8
8
## HTTP Context
9
9
10
-
When using the Streamable HTTP transport, an MCP server may need to access the underlying [HttpContext] for a request.
10
+
When using the Streamable HTTP transport, an MCP server might need to access the underlying [HttpContext] for a request.
11
11
The [HttpContext] contains request metadata such as the HTTP headers, authorization context, and the actual path and query string for the request.
12
12
13
13
To access the [HttpContext], the MCP server should add the [IHttpContextAccessor] service to the application service collection (typically in Program.cs).
14
-
Then any classes, e.g. a class containing MCP tools, should accept an [IHttpContextAccessor] in their constructor and store this for use by its methods.
14
+
Then any classes, for example, a class containing MCP tools, should accept an [IHttpContextAccessor] in their constructor and store this for use by its methods.
15
15
Methods then use the [HttpContext property][IHttpContextAccessor.HttpContext] of the accessor to get the current context.
Servers built with the C# SDK always declare the logging capability. Doing so does not obligate the server
49
-
to send log messages -- only allows it. Note that stateless MCP servers may not be capable of sending log
50
-
messages as there may not be an open connection to the client on which the log messages could be sent.
49
+
to send log messages—only allows it. Note that stateless MCP servers might not be capable of sending log
50
+
messages as there might not be an open connection to the client on which the log messages could be sent.
51
51
52
52
The C# SDK provides an extension method <xref:Microsoft.Extensions.DependencyInjection.McpServerBuilderExtensions.WithSetLoggingLevelHandler*> on <xref:Microsoft.Extensions.DependencyInjection.IMcpServerBuilder> to allow the
53
53
server to perform any special logic it wants to perform when a client sets the logging level. However, the
@@ -70,7 +70,7 @@ Clients should check if the server supports logging by checking the <xref:ModelC
70
70
71
71
If the server supports logging, the client should set the level of log messages it wishes to receive with
72
72
the <xref:ModelContextProtocol.Client.McpClient.SetLoggingLevel*> method on <xref:ModelContextProtocol.Client.McpClient>. If the client does not set a logging level, the server might choose
73
-
to send all log messages or none -- this is not specified in the protocol -- so it is important that the client
73
+
to send all log messages or none—this is not specified in the protocol. So it's important that the client
74
74
sets a logging level to ensure it receives the desired log messages and only those messages.
75
75
76
76
The `loggingLevel` set by the client is an MCP logging level.
Typically progress tracking is supported by server tools that perform operations that take a significant amount of time to complete, such as image generation or complex calculations.
15
-
However, progress tracking is defined in the MCP specification as a general feature that can be implemented for any request that is handled by either a server or a client.
15
+
However, progress tracking is defined in the MCP specification as a general feature that can be implemented for any request that's handled by either a server or a client.
16
16
This project illustrates the common case of a server tool that performs a long-running operation and sends progress updates to the client.
17
17
18
18
### Server Implementation
@@ -30,7 +30,7 @@ The server must verify that the caller provided a `progressToken` in the request
30
30
### Client Implementation
31
31
32
32
Clients request progress updates by including a `progressToken` in the parameters of a request.
33
-
Note that servers are not required to support progress tracking, so clients should not depend on receiving progress updates.
33
+
Note that servers aren't required to support progress tracking, so clients should not depend on receiving progress updates.
34
34
35
35
In the MCP C# SDK, clients can specify a `progressToken` in the request parameters when calling a tool method.
36
36
The client should also provide a notification handler to process "notifications/progress" notifications.
Copy file name to clipboardExpand all lines: docs/index.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ _layout: landing
4
4
5
5
# Overview
6
6
7
-
The official C# SDK for the [Model Context Protocol](https://modelcontextprotocol.io/), enabling .NET applications, services, and libraries to implement and interact with MCP clients and servers. Please visit our [API documentation](https://modelcontextprotocol.github.io/csharp-sdk/api/ModelContextProtocol.html) for more details on available functionality.
7
+
The official C# SDK for the [Model Context Protocol](https://modelcontextprotocol.io/), enabling .NET applications, services, and libraries to implement and interact with MCP clients and servers. For more details on available functionality, please see the [API documentation](https://modelcontextprotocol.github.io/csharp-sdk/api/ModelContextProtocol.html).
8
8
9
9
## About MCP
10
10
@@ -16,11 +16,11 @@ For more information about MCP:
For how-to guides, tutorials, and additional guidance, refer to the [official MCP documentation](https://modelcontextprotocol.io/).
19
+
For how-to guides, tutorials, and additional guidance, see the [official MCP documentation](https://modelcontextprotocol.io/).
20
20
21
21
## Official SDK packages
22
22
23
-
The official C# SDK packages for stable and pre-release versions are published to the [NuGet Gallery](https://www.nuget.org) under the [ModelContextProtocolOfficial](https://www.nuget.org/profiles/ModelContextProtocolOfficial) profile.
23
+
The official C# SDK packages for stable and prerelease versions are published to the [NuGet Gallery](https://www.nuget.org) under the [ModelContextProtocolOfficial](https://www.nuget.org/profiles/ModelContextProtocolOfficial) profile.
24
24
25
25
Continuous integration builds are published to the modelcontextprotocol organization's [GitHub NuGet package registry](https://github.com/orgs/modelcontextprotocol/packages?ecosystem=nuget).
0 commit comments