The MCP C# SDK provides built-in support for progress tracking during long-running operations. This feature allows servers to send real-time progress updates to clients while processing tools, prompts, or resources.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/modelcontextprotocol/csharp-sdk/llms.txt
Use this file to discover all available pages before exploring further.
Server Implementation
Sending Progress Notifications
Servers can send progress updates using theSendNotificationAsync method on McpServer. The server must check if the client provided a progressToken in the request before sending notifications.
Accept McpServer in your tool
Add
McpServer and RequestContext<CallToolRequestParams> parameters to access the server instance and request context:Check for progress token
Verify that the client provided a
progressToken before sending notifications:Complete Server Example
Here’s a complete tool that performs work in steps and reports progress:~/workspace/source/docs/concepts/progress/samples/server/Tools/LongRunningTools.cs
Client Implementation
Clients have two ways to receive progress updates: using aProgress<T> handler or registering a global notification handler.
Using Progress Handler (Recommended)
The simplest approach is to pass aProgress<ProgressNotificationValue> instance when calling a tool:
~/workspace/source/docs/concepts/progress/samples/client/Program.cs
- Generates a unique
progressToken - Sends it with the request
- Routes progress notifications to your handler
- Only receives updates for this specific request
Using Global Notification Handler
For more control, register a global handler to receive all progress notifications:The global handler receives all progress notifications from the server. You must filter by
progressToken to identify notifications for your specific request.Progress Notification Structure
TheProgressNotificationValue contains:
| Property | Type | Description |
|---|---|---|
Progress | double | Current progress value |
Total | double? | Total expected value (optional) |
Message | string? | Human-readable status message (optional) |
Best Practices
When to use progress tracking
When to use progress tracking
Use progress tracking for operations that:
- Take more than a few seconds
- Have measurable progress (e.g., processing items, steps in a workflow)
- Would benefit from user feedback during execution
How often to send updates
How often to send updates
Balance between responsiveness and performance:
- Too frequent: Network overhead, client UI updates
- Too infrequent: Poor user experience
- Recommended: Every 1-5 seconds or 5-10% progress increments
Always check for progressToken
Always check for progressToken
Not all clients request progress updates. Always verify the token exists before sending notifications:
API Reference
McpServer.SendNotificationAsync- Send notifications from serverProgressNotificationParams- Progress notification parametersProgressNotificationValue- Progress value structureNotificationMethods- Notification method constants