Extend progress notification support (#163)

* Extend progress notification support

* Address feedback and fix test

---------

Co-authored-by: Stephen Toub <stoub@microsoft.com>
This commit is contained in:
Tyler Kendrick 2025-04-01 10:43:50 -05:00 • committed by GitHub
commit 25bcb440a0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 175 additions and 154 deletions

View file

@ -55,7 +55,7 @@ public class SamplingCapability
/// <summary>Gets or sets the handler for sampling requests.</summary>
[JsonIgnore]
public Func<CreateMessageRequestParams?, CancellationToken, Task<CreateMessageResult>>? SamplingHandler { get; set; }
public Func<CreateMessageRequestParams?, IProgress<ProgressNotificationValue>, CancellationToken, Task<CreateMessageResult>>? SamplingHandler { get; set; }
}
/// <summary>

View file

@ -4,12 +4,4 @@
/// Sent from the client to request a list of prompts and prompt templates the server has.
/// <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/">See the schema for details</see>
/// </summary>
public class ListPromptsRequestParams
{
/// <summary>
/// An opaque token representing the current pagination position.
/// If provided, the server should return results starting after this cursor.
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("cursor")]
public string? Cursor { get; init; }
}
public class ListPromptsRequestParams : PaginatedRequestParams;

View file

@ -4,12 +4,4 @@
/// Sent from the client to request a list of resource templates the server has.
/// <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/">See the schema for details</see>
/// </summary>
public class ListResourceTemplatesRequestParams
{
/// <summary>
/// An opaque token representing the current pagination position.
/// If provided, the server should return results starting after this cursor.
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("cursor")]
public string? Cursor { get; init; }
}
public class ListResourceTemplatesRequestParams : PaginatedRequestParams;

View file

@ -4,12 +4,4 @@
/// Sent from the client to request a list of resources the server has.
/// <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/">See the schema for details</see>
/// </summary>
public class ListResourcesRequestParams
{
/// <summary>
/// An opaque token representing the current pagination position.
/// If provided, the server should return results starting after this cursor.
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("cursor")]
public string? Cursor { get; init; }
}
public class ListResourcesRequestParams : PaginatedRequestParams;

View file

@ -6,11 +6,4 @@ namespace ModelContextProtocol.Protocol.Types;
/// A request from the server to get a list of root URIs from the client.
/// <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/">See the schema for details</see>
/// </summary>
public class ListRootsRequestParams
{
/// <summary>
/// Optional progress token for out-of-band progress notifications.
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("progressToken")]
public ProgressToken? ProgressToken { get; init; }
}
public class ListRootsRequestParams : RequestParams;

View file

@ -4,12 +4,4 @@
/// Sent from the client to request a list of tools the server has.
/// <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/">See the schema for details</see>
/// </summary>
public class ListToolsRequestParams
{
/// <summary>
/// An opaque token representing the current pagination position.
/// If provided, the server should return results starting after this cursor.
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("cursor")]
public string? Cursor { get; init; }
}
public class ListToolsRequestParams : PaginatedRequestParams;

View file

@ -0,0 +1,15 @@
namespace ModelContextProtocol.Protocol.Types;
/// <summary>
/// Used as a base class for paginated requests.
/// <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/2024-11-05/schema.json">See the schema for details</see>
/// </summary>
public class PaginatedRequestParams : RequestParams
{
/// <summary>
/// An opaque token representing the current pagination position.
/// If provided, the server should return results starting after this cursor.
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("cursor")]
public string? Cursor { get; init; }
}

View file

@ -38,7 +38,7 @@ public class Tool
{
if (!McpJsonUtilities.IsValidMcpToolSchema(value))
{
throw new ArgumentException("The specified document is not a valid MPC tool JSON schema.", nameof(InputSchema));
throw new ArgumentException("The specified document is not a valid MCP tool JSON schema.", nameof(InputSchema));
}
_inputSchema = value;