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:
parent
b12d728700
commit
25bcb440a0
8 changed files with 175 additions and 154 deletions
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
15
src/ModelContextProtocol/Protocol/Types/PaginatedRequest.cs
Normal file
15
src/ModelContextProtocol/Protocol/Types/PaginatedRequest.cs
Normal 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; }
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue