Skip to content

Commit aac2531

Browse files
committed
Address comments in PR review
1 parent 72ad781 commit aac2531

File tree

6 files changed

+40
-17
lines changed

6 files changed

+40
-17
lines changed

docs/concepts/elicitation/elicitation.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ description: Enable interactive AI experiences by requesting user input during t
55
uid: elicitation
66
---
77

8+
## Elicitation
9+
810
The **elicitation** feature allows servers to request additional information from users during interactions. This enables more dynamic and interactive AI experiences, making it easier to gather necessary context before executing tasks.
911

10-
## Server Support for Elicitation
12+
### Server Support for Elicitation
1113

1214
Servers request structured data from users with the [ElicitAsync] extension method on [IMcpServer].
1315
The C# SDK registers an instance of [IMcpServer] with the dependency injection container,
@@ -27,7 +29,7 @@ The following example demonstrates how a server could request a boolean response
2729

2830
[!code-csharp[](samples/server/Tools/InteractiveTools.cs?name=snippet_GuessTheNumber)]
2931

30-
## Client Support for Elicitation
32+
### Client Support for Elicitation
3133

3234
Elicitation is an optional feature so clients declare their support for it in their capabilities as part of the `initialize` request. In the MCP C# SDK, this is done by configuring an [ElicitationHandler] in the [McpClientOptions]:
3335

docs/concepts/logging/logging.md

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ description: How to use the logging feature in the MCP C# SDK.
55
uid: logging
66
---
77

8+
## Logging
9+
810
MCP servers may expose log messages to clients through the [Logging utility].
911

1012
[Logging utility]: https://modelcontextprotocol.io/specification/2025-06-18/server/utilities/logging
@@ -43,10 +45,14 @@ MCP servers that implement the Logging utility must declare this in the capabili
4345

4446
[Initialization]: https://modelcontextprotocol.io/specification/2025-06-18/basic/lifecycle#initialization
4547

46-
Servers built with the C# SDK always declare the logging capability. The C# SDK provides an extension method
47-
[WithSetLoggingLevelHandler] on [IMcpServerBuilder] to allow the server to perform any special logic it wants to perform
48-
when a client sets the logging level. However, the SDK already takes care of setting the [LoggingLevel]
49-
in the [IMcpServer], so most servers will not need to implement this.
48+
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.
51+
52+
The C# SDK provides an extension method [WithSetLoggingLevelHandler] on [IMcpServerBuilder] to allow the
53+
server to perform any special logic it wants to perform when a client sets the logging level. However, the
54+
SDK already takes care of setting the [LoggingLevel] in the [IMcpServer], so most servers will not need to
55+
implement this.
5056

5157
[IMcpServer]: https://modelcontextprotocol.github.io/csharp-sdk/api/ModelContextProtocol.Server.IMcpServer.html
5258
[IMcpServerBuilder]: https://modelcontextprotocol.github.io/csharp-sdk/api/Microsoft.Extensions.DependencyInjection.IMcpServerBuilder.html
@@ -64,24 +70,31 @@ and from that can create an [ILogger] instance for logging messages that should
6470

6571
### Client support for logging
6672

67-
Clients that wish to receive log messages from the server must first check if logging is supported.
68-
This is done by checking the [Logging] property of the [ServerCapabilities] field of [IMcpClient].
73+
When the server indicates that it supports logging, clients should configure
74+
the logging level to specify which messages the server should send to the client.
75+
76+
Clients should check if the server supports logging by checking the [Logging] property of the [ServerCapabilities] field of [IMcpClient].
6977

7078
[IMcpClient]: https://modelcontextprotocol.github.io/csharp-sdk/api/ModelContextProtocol.Client.IMcpClient.html
7179
[ServerCapabilities]: https://modelcontextprotocol.github.io/csharp-sdk/api/ModelContextProtocol.Client.IMcpClient.html#ModelContextProtocol_Client_IMcpClient_ServerCapabilities
7280
[Logging]: https://modelcontextprotocol.github.io/csharp-sdk/api/ModelContextProtocol.Protocol.ServerCapabilities.html#ModelContextProtocol_Protocol_ServerCapabilities_Logging
7381

7482
[!code-csharp[](samples/client/Program.cs?name=snippet_LoggingCapabilities)]
7583

76-
If the server supports logging, the client can set the level of log messages it wishes to receive with
77-
the [SetLoggingLevel] method on [IMcpClient]. The `loggingLevel` specified here is an MCP logging level.
84+
If the server supports logging, the client should set the level of log messages it wishes to receive with
85+
the [SetLoggingLevel] method on [IMcpClient]. If the client does not set a logging level, the server might choose
86+
to send all log messages or none -- this is not specified in the protocol -- so it is important that the client
87+
sets a logging level to ensure it receives the desired log messages and only those messages.
88+
89+
The `loggingLevel` set by the client is an MCP logging level.
7890
See the [Logging Levels](#logging-levels) section above for the mapping between MCP and .NET logging levels.
7991

8092
[SetLoggingLevel]: https://modelcontextprotocol.github.io/csharp-sdk/api/ModelContextProtocol.Client.McpClientExtensions.html#ModelContextProtocol_Client_McpClientExtensions_SetLoggingLevel_ModelContextProtocol_Client_IMcpClient_Microsoft_Extensions_Logging_LogLevel_System_Threading_CancellationToken_
8193

8294
[!code-csharp[](samples/client/Program.cs?name=snippet_LoggingLevel)]
8395

8496
Lastly, the client must configure a notification handler for [NotificationMethods.LoggingMessageNotification] notifications.
97+
The following example simply writes the log messages to the console.
8598

8699
[NotificationMethods.LoggingMessageNotification]: https://modelcontextprotocol.github.io/csharp-sdk/api/ModelContextProtocol.Protocol.NotificationMethods.html#ModelContextProtocol_Protocol_NotificationMethods_LoggingMessageNotification
87100

docs/concepts/logging/samples/client/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
}
4646
}
4747

48-
// </snippet_LoggingHandler>
48+
// <snippet_LoggingHandler>
4949
mcpClient.RegisterNotificationHandler(NotificationMethods.LoggingMessageNotification,
5050
(notification, ct) =>
5151
{

docs/concepts/logging/samples/server/Tools/LoggingTools.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static async Task<string> LoggingTool(
1616
var progressToken = context.Params?.ProgressToken;
1717
var stepDuration = duration / steps;
1818

19-
// <sinppet_LoggingConfiguration >
19+
// <snippet_LoggingConfiguration >
2020
ILoggerProvider loggerProvider = context.Server.AsClientLoggerProvider();
2121
ILogger logger = loggerProvider.CreateLogger("LoggingTools");
2222
// </snippet_LoggingConfiguration>

docs/concepts/progress/progress.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ author: mikekistler
44
description:
55
uid: progress
66
---
7+
8+
## Progress
9+
710
The Model Context Protocol (MCP) supports [progress tracking] for long-running operations through notification messages.
811

912
[progress tracking]: https://modelcontextprotocol.io/specification/2025-06-18/basic/utilities/progress
1013

11-
Typically progress tracking is supported by server tools that perform operations that take a significant amount of time to complete, such as data processing or complex calculations.
14+
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.
1215
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.
1316
This project illustrates the common case of a server tool that performs a long-running operation and sends progress updates to the client.
1417

@@ -24,7 +27,7 @@ The parameters passed to [sendNotificationAsync] should be an instance of [Progr
2427
[IMcpServer]: https://modelcontextprotocol.github.io/csharp-sdk/api/ModelContextProtocol.Server.IMcpServer.html
2528
[ProgressNotificationParams]: https://modelcontextprotocol.github.io/csharp-sdk/api/ModelContextProtocol.Protocol.ProgressNotificationParams.html
2629

27-
The server should verify that the caller provided a `progressToken` in the request and include it in the call to [sendNotificationAsync]. The following example demonstrates how a server can send a progress notification:
30+
The server must verify that the caller provided a `progressToken` in the request and include it in the call to [sendNotificationAsync]. The following example demonstrates how a server can send a progress notification:
2831

2932
[!code-csharp[](samples/server/Tools/LongRunningTools.cs?name=snippet_SendProgress)]
3033

@@ -54,8 +57,13 @@ mcpClient.RegisterNotificationHandler(NotificationMethods.ProgressNotification,
5457
}).ConfigureAwait(false);
5558
```
5659

57-
The second way is to pass a [Progress<T>] instance to the tool method. The MCP C# SDK will automatically handle progress notifications and report them through the [Progress<T>] instance. This notification handler will only receive progress updates for the specific request that was made, rather than all progress notifications from the server.
60+
The second way is to pass a [Progress`<T>`] instance to the tool method. [Progress`<T>`] is a standard .NET type that provides a way to receive progress updates.
61+
For the purposes of MCP progress notifications, `T` should be [ProgressNotificationValue].
62+
The MCP C# SDK will automatically handle progress notifications and report them through the [Progress`<T>`] instance.
63+
This notification handler will only receive progress updates for the specific request that was made,
64+
rather than all progress notifications from the server.
5865

59-
[Progress<T>]: https://learn.microsoft.com/en-us/dotnet/api/system.progress-1
66+
[Progress`<T>`]: https://learn.microsoft.com/en-us/dotnet/api/system.progress-1
67+
[ProgressNotificationValue]: https://modelcontextprotocol.github.io/csharp-sdk/api/ModelContextProtocol.ProgressNotificationValue.html
6068

6169
[!code-csharp[](samples/client/Program.cs?name=snippet_ProgressHandler)]

docs/concepts/progress/samples/server/Tools/LongRunningTools.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static async Task<string> LongRunningTool(
3636
},
3737
});
3838
}
39-
// </snipped_SendProgress >
39+
// </snippet_SendProgress >
4040
}
4141

4242
return $"Long running tool completed. Duration: {duration} seconds. Steps: {steps}.";

0 commit comments

Comments
 (0)