Improve progress reporting (#145)

* Improve progress reporting

- Enable injecting an `IProgress<>` into a tool call to report progress when the client has supplied a progress token
- Add a custom type for ProgressToken and ProgressNotification to map to the schema
- Simplify RequestId to match ProgressToken's shape
- Serialize StdioClientTransport's SendMessageAsync implementation
- Add strongly-typed names for all request methods
- Change all request IDs created by McpJsonRpcEndpoint to include a guid for that endpoint

* Address PR feedback
This commit is contained in:
Stephen Toub 2025-03-31 09:33:16 -04:00 • committed by GitHub
commit 2c75acded8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -34,4 +34,27 @@ public static class NotificationMethods
/// Sent by the server when a log message is generated.
/// </summary>
public const string LoggingMessageNotification = "notifications/message";
/// <summary>
/// Sent from the client to the server after initialization has finished.
/// </summary>
public const string InitializedNotification = "notifications/initialized";
/// <summary>
/// Sent to inform the receiver of a progress update for a long-running request.
/// </summary>
public const string ProgressNotification = "notifications/progress";
/// <summary>
/// Sent by either side to indicate that it is cancelling a previously-issued request.
/// </summary>
/// <remarks>
/// The request SHOULD still be in-flight, but due to communication latency, it is always possible that this notification
/// MAY arrive after the request has already finished.
///
/// This notification indicates that the result will be unused, so any associated processing SHOULD cease.
///
/// A client MUST NOT attempt to cancel its `initialize` request.".
/// </remarks>
public const string CancelledNotification = "notifications/cancelled";
}