Fix markdown links in docs and add docfx CI validation (#862)
* Initial plan * Replace obsolete API references with xref tags in markdown docs Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com> * Add documentation guidelines for xref syntax Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com> * Fix: Only update link URLs, preserve document structure Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com> * Add --warningsAsErrors flag to docfx command in Makefile Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com> * Add CI validation for document generation * Fix broken link * Fix invalid xref cross-references in documentation Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com> * Apply suggestion from @eiriktsarpalis * Fix Progress link syntax and remove docs/README.md Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com> * Separate build & test targets * Apply suggestion from @eiriktsarpalis * tweak Makefile * Fix test results upload path * Add emojis to CI workflow step names Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com> * perform manual cleanups --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com> Co-authored-by: Eirik Tsarpalis <eirik.tsarpalis@gmail.com>
This commit is contained in:
parent
c40effebc4
commit
b40f06c043
1 changed files with 54 additions and 91 deletions
|
|
@ -17,17 +17,13 @@ This project illustrates the common case of a server tool that performs a long-r
|
|||
|
||||
### Server Implementation
|
||||
|
||||
When processing a request, the server can use the [sendNotificationAsync] extension method of [IMcpServer] to send progress updates,
|
||||
When processing a request, the server can use the <xref:ModelContextProtocol.McpSession.SendNotificationAsync*> extension method of <xref:ModelContextProtocol.Server.McpServer> to send progress updates,
|
||||
specifying `"notifications/progress"` as the notification method name.
|
||||
The C# SDK registers an instance of [IMcpServer] with the dependency injection container,
|
||||
so tools can simply add a parameter of type [IMcpServer] to their method signature to access it.
|
||||
The parameters passed to [sendNotificationAsync] should be an instance of [ProgressNotificationParams], which includes the current progress, total steps, and an optional message.
|
||||
The C# SDK registers an instance of <xref:ModelContextProtocol.Server.McpServer> with the dependency injection container,
|
||||
so tools can simply add a parameter of type <xref:ModelContextProtocol.Server.McpServer> to their method signature to access it.
|
||||
The parameters passed to <xref:ModelContextProtocol.McpSession.SendNotificationAsync*> should be an instance of <xref:ModelContextProtocol.Protocol.ProgressNotificationParams>, which includes the current progress, total steps, and an optional message.
|
||||
|
||||
[sendNotificationAsync]: https://modelcontextprotocol.github.io/csharp-sdk/api/ModelContextProtocol.McpEndpointExtensions.html#ModelContextProtocol_McpEndpointExtensions_SendNotificationAsync_ModelContextProtocol_IMcpEndpoint_System_String_System_Threading_CancellationToken_
|
||||
[IMcpServer]: https://modelcontextprotocol.github.io/csharp-sdk/api/ModelContextProtocol.Server.IMcpServer.html
|
||||
[ProgressNotificationParams]: https://modelcontextprotocol.github.io/csharp-sdk/api/ModelContextProtocol.Protocol.ProgressNotificationParams.html
|
||||
|
||||
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:
|
||||
The server must verify that the caller provided a `progressToken` in the request and include it in the call to <xref:ModelContextProtocol.McpSession.SendNotificationAsync*>. The following example demonstrates how a server can send a progress notification:
|
||||
|
||||
[!code-csharp[](samples/server/Tools/LongRunningTools.cs?name=snippet_SendProgress)]
|
||||
|
||||
|
|
@ -38,10 +34,7 @@ Note that servers are not required to support progress tracking, so clients shou
|
|||
|
||||
In the MCP C# SDK, clients can specify a `progressToken` in the request parameters when calling a tool method.
|
||||
The client should also provide a notification handler to process "notifications/progress" notifications.
|
||||
There are two way to do this. The first is to register a notification handler using the [RegisterNotificationHandler] method on the [IMcpClient] instance. A handler registered this way will receive all progress notifications sent by the server.
|
||||
|
||||
[IMcpClient]: https://modelcontextprotocol.github.io/csharp-sdk/api/ModelContextProtocol.Client.IMcpClient.html
|
||||
[RegisterNotificationHandler]: https://modelcontextprotocol.github.io/csharp-sdk/api/ModelContextProtocol.IMcpEndpoint.html#ModelContextProtocol_IMcpEndpoint_RegisterNotificationHandler_System_String_System_Func_ModelContextProtocol_Protocol_JsonRpcNotification_System_Threading_CancellationToken_System_Threading_Tasks_ValueTask__
|
||||
There are two way to do this. The first is to register a notification handler using the <xref:ModelContextProtocol.McpSession.RegisterNotificationHandler*> method on the <xref:ModelContextProtocol.Client.McpClient> instance. A handler registered this way will receive all progress notifications sent by the server.
|
||||
|
||||
```csharp
|
||||
mcpClient.RegisterNotificationHandler(NotificationMethods.ProgressNotification,
|
||||
|
|
@ -57,13 +50,10 @@ mcpClient.RegisterNotificationHandler(NotificationMethods.ProgressNotification,
|
|||
}).ConfigureAwait(false);
|
||||
```
|
||||
|
||||
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.
|
||||
For the purposes of MCP progress notifications, `T` should be [ProgressNotificationValue].
|
||||
The MCP C# SDK will automatically handle progress notifications and report them through the [Progress`<T>`] instance.
|
||||
The second way is to pass a [`Progress<T>`](https://learn.microsoft.com/dotnet/api/system.progress-1) instance to the tool method. `Progress<T>` is a standard .NET type that provides a way to receive progress updates.
|
||||
For the purposes of MCP progress notifications, `T` should be <xref:ModelContextProtocol.ProgressNotificationValue>.
|
||||
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.
|
||||
|
||||
[Progress`<T>`]: https://learn.microsoft.com/en-us/dotnet/api/system.progress-1
|
||||
[ProgressNotificationValue]: https://modelcontextprotocol.github.io/csharp-sdk/api/ModelContextProtocol.ProgressNotificationValue.html
|
||||
|
||||
[!code-csharp[](samples/client/Program.cs?name=snippet_ProgressHandler)]
|
||||
|
|
|
|||
Loading…
Reference in a new issue