Adding a base class for request params that exposes the progressToken (#99)
* Adding a base class for request params that exposes the progressToken This aligns more with the type structure see in the other SDK's (eg: https://github.com/modelcontextprotocol/python-sdk/blob/main/src/mcp/types.py#L41) while also ensuring they are exposing the JSONRPCRequest (https://github.com/modelcontextprotocol/specification/blob/main/schema/2024-11-05/schema.json#L771-L806) data. Storing progressToken as an object as it could be an int or string (per https://github.com/modelcontextprotocol/specification/blob/main/schema/2024-11-05/schema.json#L1268-L1274). Fixes #67 * Using usings * Apply suggestions from code review --------- Co-authored-by: Stephen Toub <stoub@microsoft.com>
This commit is contained in:
parent
a9175f0917
commit
6fa1443a6c
11 changed files with 40 additions and 9 deletions
|
|
@ -4,7 +4,7 @@
|
|||
/// Used by the client to invoke a tool provided by the server.
|
||||
/// <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/2024-11-05/schema.json">See the schema for details</see>
|
||||
/// </summary>
|
||||
public class CallToolRequestParams
|
||||
public class CallToolRequestParams : RequestParams
|
||||
{
|
||||
/// <summary>
|
||||
/// Tool name.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
/// A request from the client to the server, to ask for completion options.
|
||||
/// <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/2024-11-05/schema.json">See the schema for details</see>
|
||||
/// </summary>
|
||||
public class CompleteRequestParams
|
||||
public class CompleteRequestParams : RequestParams
|
||||
{
|
||||
/// <summary>
|
||||
/// The reference's information
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
/// clients have full discretion over model selection and should inform users before sampling.
|
||||
/// <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/2024-11-05/schema.json">See the schema for details</see>
|
||||
/// </summary>
|
||||
public class CreateMessageRequestParams
|
||||
public class CreateMessageRequestParams : RequestParams
|
||||
{
|
||||
/// <summary>
|
||||
/// A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. The client MAY ignore this request.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
/// Used by the client to get a prompt provided by the server.
|
||||
/// <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/2024-11-05/schema.json">See the schema for details</see>
|
||||
/// </summary>
|
||||
public class GetPromptRequestParams
|
||||
public class GetPromptRequestParams : RequestParams
|
||||
{
|
||||
/// <summary>
|
||||
/// he name of the prompt or prompt template.
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ namespace ModelContextProtocol.Protocol.Types;
|
|||
/// Parameters for an initialization request sent to the server.
|
||||
/// <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/2024-11-05/schema.json">See the schema for details</see>
|
||||
/// </summary>
|
||||
public record InitializeRequestParams
|
||||
public class InitializeRequestParams : RequestParams
|
||||
{
|
||||
/// <summary>
|
||||
/// The version of the Model Context Protocol that the client wants to use.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
/// Sent from the client to the server, to read a specific resource URI.
|
||||
/// <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/2024-11-05/schema.json">See the schema for details</see>
|
||||
/// </summary>
|
||||
public class ReadResourceRequestParams
|
||||
public class ReadResourceRequestParams : RequestParams
|
||||
{
|
||||
/// <summary>
|
||||
/// The URI of the resource to read. The URI can use any protocol; it is up to the server how to interpret it.
|
||||
|
|
|
|||
16
src/ModelContextProtocol/Protocol/Types/RequestParams.cs
Normal file
16
src/ModelContextProtocol/Protocol/Types/RequestParams.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ModelContextProtocol.Protocol.Types;
|
||||
|
||||
/// <summary>
|
||||
/// Base class for all request parameters.
|
||||
/// <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/2024-11-05/schema.json#L771-L806">See the schema for details</see>
|
||||
/// </summary>
|
||||
public abstract class RequestParams
|
||||
{
|
||||
/// <summary>
|
||||
/// Metadata related to the tool invocation.
|
||||
/// </summary>
|
||||
[JsonPropertyName("_meta")]
|
||||
public RequestParamsMetadata? Meta { get; init; }
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ModelContextProtocol.Protocol.Types;
|
||||
|
||||
/// <summary>
|
||||
/// Metadata related to the request.
|
||||
/// </summary>
|
||||
public class RequestParamsMetadata
|
||||
{
|
||||
/// <summary>
|
||||
/// If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.
|
||||
/// </summary>
|
||||
[JsonPropertyName("progressToken")]
|
||||
public object ProgressToken { get; set; } = default!;
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@ namespace ModelContextProtocol.Protocol.Types;
|
|||
/// A request from the client to the server, to enable or adjust logging.
|
||||
/// <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/2024-11-05/schema.json">See the schema for details</see>
|
||||
/// </summary>
|
||||
public class SetLevelRequestParams
|
||||
public class SetLevelRequestParams : RequestParams
|
||||
{
|
||||
/// <summary>
|
||||
/// The level of logging that the client wants to receive from the server.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
/// Sent from the client to request updated notifications from the server whenever a particular primitive changes.
|
||||
/// <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/2024-11-05/schema.json">See the schema for details</see>
|
||||
/// </summary>
|
||||
public class SubscribeRequestParams
|
||||
public class SubscribeRequestParams : RequestParams
|
||||
{
|
||||
/// <summary>
|
||||
/// The URI of the resource to subscribe to. The URI can use any protocol; it is up to the server how to interpret it.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
/// Sent from the client to request not receiving updated notifications from the server whenever a primitive resource changes.
|
||||
/// <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/2024-11-05/schema.json">See the schema for details</see>
|
||||
/// </summary>
|
||||
public class UnsubscribeRequestParams
|
||||
public class UnsubscribeRequestParams : RequestParams
|
||||
{
|
||||
/// <summary>
|
||||
/// The URI of the resource to unsubscribe fro. The URI can use any protocol; it is up to the server how to interpret it.
|
||||
|
|
|
|||
Loading…
Reference in a new issue