Remove obsolete APIs from codebase and standardize MCP diagnostic IDs (#985)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: MackinnonBuck <10456961+MackinnonBuck@users.noreply.github.com> Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com> Co-authored-by: Mackinnon Buck <mackinnon.buck@gmail.com> Co-authored-by: jeffhandley <1031940+jeffhandley@users.noreply.github.com> Co-authored-by: Jeff Handley <jeffhandley@users.noreply.github.com>
This commit is contained in:
parent
5385c0de67
commit
136755f2be
11 changed files with 663 additions and 2674 deletions
|
|
@ -66,26 +66,4 @@ public sealed class ClientCapabilities
|
|||
/// </summary>
|
||||
[JsonPropertyName("elicitation")]
|
||||
public ElicitationCapability? Elicitation { get; set; }
|
||||
|
||||
/// <summary>Gets or sets notification handlers to register with the client.</summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// When constructed, the client will enumerate these handlers, which may contain multiple handlers per notification method key, once.
|
||||
/// The client will not re-enumerate the sequence after initialization.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Notification handlers allow the client to respond to server-sent notifications for specific methods.
|
||||
/// Each key in the collection is a notification method name, and each value is a callback that will be invoked
|
||||
/// when a notification with that method is received.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Handlers provided via <see cref="NotificationHandlers"/> will be registered with the client for the lifetime of the client.
|
||||
/// For transient handlers, <see cref="McpSession.RegisterNotificationHandler"/> can be used to register a handler that can
|
||||
/// then be unregistered by disposing of the <see cref="IAsyncDisposable"/> returned from the method.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
[JsonIgnore]
|
||||
[Obsolete($"Use {nameof(McpClientOptions.Handlers.NotificationHandlers)} instead. This member will be removed in a subsequent release.")] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public IEnumerable<KeyValuePair<string, Func<JsonRpcNotification, CancellationToken, ValueTask>>>? NotificationHandlers { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,16 +28,4 @@ namespace ModelContextProtocol.Protocol;
|
|||
/// </remarks>
|
||||
public sealed class CompletionsCapability
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the handler for completion requests.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This handler provides auto-completion suggestions for prompt arguments or resource references in the Model Context Protocol.
|
||||
/// The handler receives a reference type (e.g., "ref/prompt" or "ref/resource") and the current argument value,
|
||||
/// and should return appropriate completion suggestions.
|
||||
/// </remarks>
|
||||
[JsonIgnore]
|
||||
[Obsolete($"Use {nameof(McpServerOptions.Handlers.CompleteHandler)} instead. This member will be removed in a subsequent release.")] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public McpRequestHandler<CompleteRequestParams, CompleteResult>? CompleteHandler { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -247,10 +247,12 @@ public sealed class ElicitRequestParams
|
|||
{
|
||||
if (enumNames is not null)
|
||||
{
|
||||
// EnumSchema for backward compatibility
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
// EnumSchema is deprecated but supported for backward compatibility.
|
||||
// Use the EnumSchema class, which is an alias for LegacyTitledEnumSchema,
|
||||
// to ensure backward compatibility with existing code relying on that type.
|
||||
#pragma warning disable MCP9001
|
||||
psd = new EnumSchema
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
#pragma warning restore MCP9001
|
||||
{
|
||||
Enum = enumValues,
|
||||
EnumNames = enumNames,
|
||||
|
|
@ -558,22 +560,22 @@ public sealed class ElicitRequestParams
|
|||
}
|
||||
break;
|
||||
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
case LegacyTitledEnumSchema legacyEnum:
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
if (legacyEnum.Enum is not null)
|
||||
#pragma warning disable MCP9001 // LegacyTitledEnumSchema is deprecated but supported for backward compatibility
|
||||
case LegacyTitledEnumSchema legacyTitledEnum:
|
||||
#pragma warning restore MCP9001
|
||||
if (legacyTitledEnum.Enum is not null)
|
||||
{
|
||||
writer.WritePropertyName("enum");
|
||||
JsonSerializer.Serialize(writer, legacyEnum.Enum, McpJsonUtilities.JsonContext.Default.IListString);
|
||||
JsonSerializer.Serialize(writer, legacyTitledEnum.Enum, McpJsonUtilities.JsonContext.Default.IListString);
|
||||
}
|
||||
if (legacyEnum.EnumNames is not null)
|
||||
if (legacyTitledEnum.EnumNames is not null)
|
||||
{
|
||||
writer.WritePropertyName("enumNames");
|
||||
JsonSerializer.Serialize(writer, legacyEnum.EnumNames, McpJsonUtilities.JsonContext.Default.IListString);
|
||||
JsonSerializer.Serialize(writer, legacyTitledEnum.EnumNames, McpJsonUtilities.JsonContext.Default.IListString);
|
||||
}
|
||||
if (legacyEnum.Default is not null)
|
||||
if (legacyTitledEnum.Default is not null)
|
||||
{
|
||||
writer.WriteString("default", legacyEnum.Default);
|
||||
writer.WriteString("default", legacyTitledEnum.Default);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -740,51 +742,6 @@ public sealed class ElicitRequestParams
|
|||
public bool? Default { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a legacy schema for an enum type with enumNames.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This schema is deprecated in favor of <see cref="TitledSingleSelectEnumSchema"/>.
|
||||
/// </remarks>
|
||||
[Obsolete("Use TitledSingleSelectEnumSchema instead. This type will be removed in a future version.")]
|
||||
public class LegacyTitledEnumSchema : PrimitiveSchemaDefinition
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
[JsonPropertyName("type")]
|
||||
public override string Type
|
||||
{
|
||||
get => "string";
|
||||
set
|
||||
{
|
||||
if (value is not "string")
|
||||
{
|
||||
throw new ArgumentException("Type must be 'string'.", nameof(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Gets or sets the list of allowed string values for the enum.</summary>
|
||||
[JsonPropertyName("enum")]
|
||||
[field: MaybeNull]
|
||||
public IList<string> Enum
|
||||
{
|
||||
get => field ??= [];
|
||||
set
|
||||
{
|
||||
Throw.IfNull(value);
|
||||
field = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Gets or sets optional display names corresponding to the enum values.</summary>
|
||||
[JsonPropertyName("enumNames")]
|
||||
public IList<string>? EnumNames { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the default value for the enum.</summary>
|
||||
[JsonPropertyName("default")]
|
||||
public string? Default { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a schema for single-selection enumeration without display titles for options.
|
||||
/// </summary>
|
||||
|
|
@ -970,10 +927,59 @@ public sealed class ElicitRequestParams
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a schema for an enum type. This is a compatibility alias for <see cref="LegacyTitledEnumSchema"/>.
|
||||
/// Represents a legacy schema for an enum type with enumNames.
|
||||
/// This is a compatibility alias for <see cref="LegacyTitledEnumSchema"/>.
|
||||
/// </summary>
|
||||
[Obsolete("Use UntitledSingleSelectEnumSchema or TitledSingleSelectEnumSchema instead. This type will be removed in a future version.")]
|
||||
/// <remarks>
|
||||
/// This schema is deprecated in favor of <see cref="TitledSingleSelectEnumSchema"/>.
|
||||
/// </remarks>
|
||||
[Obsolete(Obsoletions.LegacyTitledEnumSchema_Message, DiagnosticId = Obsoletions.LegacyTitledEnumSchema_DiagnosticId, UrlFormat = Obsoletions.LegacyTitledEnumSchema_Url)]
|
||||
public sealed class EnumSchema : LegacyTitledEnumSchema
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a legacy schema for an enum type with enumNames.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This schema is deprecated in favor of <see cref="TitledSingleSelectEnumSchema"/>.
|
||||
/// </remarks>
|
||||
[Obsolete(Obsoletions.LegacyTitledEnumSchema_Message, DiagnosticId = Obsoletions.LegacyTitledEnumSchema_DiagnosticId, UrlFormat = Obsoletions.LegacyTitledEnumSchema_Url)]
|
||||
public class LegacyTitledEnumSchema : PrimitiveSchemaDefinition
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
[JsonPropertyName("type")]
|
||||
public override string Type
|
||||
{
|
||||
get => "string";
|
||||
set
|
||||
{
|
||||
if (value is not "string")
|
||||
{
|
||||
throw new ArgumentException("Type must be 'string'.", nameof(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Gets or sets the list of allowed string values for the enum.</summary>
|
||||
[JsonPropertyName("enum")]
|
||||
[field: MaybeNull]
|
||||
public IList<string> Enum
|
||||
{
|
||||
get => field ??= [];
|
||||
set
|
||||
{
|
||||
Throw.IfNull(value);
|
||||
field = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Gets or sets optional display names corresponding to the enum values.</summary>
|
||||
[JsonPropertyName("enumNames")]
|
||||
public IList<string>? EnumNames { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the default value for the enum.</summary>
|
||||
[JsonPropertyName("default")]
|
||||
public string? Default { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,21 +23,4 @@ namespace ModelContextProtocol.Protocol;
|
|||
/// </remarks>
|
||||
public sealed class ElicitationCapability
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the handler for processing <see cref="RequestMethods.ElicitationCreate"/> requests.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// This handler function is called when an MCP server requests the client to provide additional
|
||||
/// information during interactions. The client must set this property for the elicitation capability to work.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// The handler receives message parameters and a cancellation token.
|
||||
/// It should return a <see cref="ElicitResult"/> containing the response to the elicitation request.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
[JsonIgnore]
|
||||
[Obsolete($"Use {nameof(McpClientOptions.Handlers.ElicitationHandler)} instead. This member will be removed in a subsequent release.")] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public Func<ElicitRequestParams?, CancellationToken, ValueTask<ElicitResult>>? ElicitationHandler { get; set; }
|
||||
}
|
||||
|
|
@ -20,11 +20,4 @@ namespace ModelContextProtocol.Protocol;
|
|||
/// </remarks>
|
||||
public sealed class LoggingCapability
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the handler for set logging level requests from clients.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[Obsolete($"Use {nameof(McpServerOptions.Handlers.SetLoggingLevelHandler)} instead. This member will be removed in a subsequent release.")] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public McpRequestHandler<SetLevelRequestParams, EmptyResult>? SetLoggingLevelHandler { get; set; }
|
||||
}
|
||||
|
|
@ -31,59 +31,4 @@ public sealed class PromptsCapability
|
|||
/// </remarks>
|
||||
[JsonPropertyName("listChanged")]
|
||||
public bool? ListChanged { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the handler for <see cref="RequestMethods.PromptsList"/> requests.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This handler is invoked when a client requests a list of available prompts from the server
|
||||
/// via a <see cref="RequestMethods.PromptsList"/> request. Results from this handler are returned
|
||||
/// along with any prompts defined in <see cref="PromptCollection"/>.
|
||||
/// </remarks>
|
||||
[JsonIgnore]
|
||||
[Obsolete($"Use {nameof(McpServerOptions.Handlers.ListPromptsHandler)} instead. This member will be removed in a subsequent release.")] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public McpRequestHandler<ListPromptsRequestParams, ListPromptsResult>? ListPromptsHandler { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the handler for <see cref="RequestMethods.PromptsGet"/> requests.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// This handler is invoked when a client requests details for a specific prompt by name and provides arguments
|
||||
/// for the prompt if needed. The handler receives the request context containing the prompt name and any arguments,
|
||||
/// and should return a <see cref="GetPromptResult"/> with the prompt messages and other details.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// This handler will be invoked if the requested prompt name is not found in the <see cref="PromptCollection"/>,
|
||||
/// allowing for dynamic prompt generation or retrieval from external sources.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
[JsonIgnore]
|
||||
[Obsolete($"Use {nameof(McpServerOptions.Handlers.GetPromptHandler)} instead. This member will be removed in a subsequent release.")] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public McpRequestHandler<GetPromptRequestParams, GetPromptResult>? GetPromptHandler { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a collection of prompts that will be served by the server.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// The <see cref="PromptCollection"/> contains the predefined prompts that clients can request from the server.
|
||||
/// This collection works in conjunction with <see cref="ListPromptsHandler"/> and <see cref="GetPromptHandler"/>
|
||||
/// when those are provided:
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// - For <see cref="RequestMethods.PromptsList"/> requests: The server returns all prompts from this collection
|
||||
/// plus any additional prompts provided by the <see cref="ListPromptsHandler"/> if it's set.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// - For <see cref="RequestMethods.PromptsGet"/> requests: The server first checks this collection for the requested prompt.
|
||||
/// If not found, it will invoke the <see cref="GetPromptHandler"/> as a fallback if one is set.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
[JsonIgnore]
|
||||
[Obsolete($"Use {nameof(McpServerOptions.PromptCollection)} instead. This member will be removed in a subsequent release.")] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public McpServerPrimitiveCollection<McpServerPrompt>? PromptCollection { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,92 +29,4 @@ public sealed class ResourcesCapability
|
|||
/// </remarks>
|
||||
[JsonPropertyName("listChanged")]
|
||||
public bool? ListChanged { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the handler for <see cref="RequestMethods.ResourcesTemplatesList"/> requests.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This handler is called when clients request available resource templates that can be used
|
||||
/// to create resources within the Model Context Protocol server.
|
||||
/// Resource templates define the structure and URI patterns for resources accessible in the system,
|
||||
/// allowing clients to discover available resource types and their access patterns.
|
||||
/// </remarks>
|
||||
[JsonIgnore]
|
||||
[Obsolete($"Use {nameof(McpServerOptions.Handlers.ListResourceTemplatesHandler)} instead. This member will be removed in a subsequent release.")] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public McpRequestHandler<ListResourceTemplatesRequestParams, ListResourceTemplatesResult>? ListResourceTemplatesHandler { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the handler for <see cref="RequestMethods.ResourcesList"/> requests.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This handler responds to client requests for available resources and returns information about resources accessible through the server.
|
||||
/// The implementation should return a <see cref="ListResourcesResult"/> with the matching resources.
|
||||
/// </remarks>
|
||||
[JsonIgnore]
|
||||
[Obsolete($"Use {nameof(McpServerOptions.Handlers.ListResourcesHandler)} instead. This member will be removed in a subsequent release.")] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public McpRequestHandler<ListResourcesRequestParams, ListResourcesResult>? ListResourcesHandler { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the handler for <see cref="RequestMethods.ResourcesRead"/> requests.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This handler is responsible for retrieving the content of a specific resource identified by its URI in the Model Context Protocol.
|
||||
/// When a client sends a resources/read request, this handler is invoked with the resource URI.
|
||||
/// The handler should implement logic to locate and retrieve the requested resource, then return
|
||||
/// its contents in a ReadResourceResult object.
|
||||
/// </remarks>
|
||||
[JsonIgnore]
|
||||
[Obsolete($"Use {nameof(McpServerOptions.Handlers.ReadResourceHandler)} instead. This member will be removed in a subsequent release.")] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public McpRequestHandler<ReadResourceRequestParams, ReadResourceResult>? ReadResourceHandler { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the handler for <see cref="RequestMethods.ResourcesSubscribe"/> requests.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// When a client sends a <see cref="RequestMethods.ResourcesSubscribe"/> request, this handler is invoked with the resource URI
|
||||
/// to be subscribed to. The implementation should register the client's interest in receiving updates
|
||||
/// for the specified resource.
|
||||
/// Subscriptions allow clients to receive real-time notifications when resources change, without
|
||||
/// requiring polling.
|
||||
/// </remarks>
|
||||
[JsonIgnore]
|
||||
[Obsolete($"Use {nameof(McpServerOptions.Handlers.SubscribeToResourcesHandler)} instead. This member will be removed in a subsequent release.")] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public McpRequestHandler<SubscribeRequestParams, EmptyResult>? SubscribeToResourcesHandler { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the handler for <see cref="RequestMethods.ResourcesUnsubscribe"/> requests.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// When a client sends a <see cref="RequestMethods.ResourcesUnsubscribe"/> request, this handler is invoked with the resource URI
|
||||
/// to be unsubscribed from. The implementation should remove the client's registration for receiving updates
|
||||
/// about the specified resource.
|
||||
/// </remarks>
|
||||
[JsonIgnore]
|
||||
[Obsolete($"Use {nameof(McpServerOptions.Handlers.UnsubscribeFromResourcesHandler)} instead. This member will be removed in a subsequent release.")] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public McpRequestHandler<UnsubscribeRequestParams, EmptyResult>? UnsubscribeFromResourcesHandler { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a collection of resources served by the server.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// Resources specified via <see cref="ResourceCollection"/> augment the <see cref="ListResourcesHandler"/>, <see cref="ListResourceTemplatesHandler"/>
|
||||
/// and <see cref="ReadResourceHandler"/> handlers, if provided. Resources with template expressions in their URI templates are considered resource templates
|
||||
/// and are listed via ListResourceTemplate, whereas resources without template parameters are considered static resources and are listed with ListResources.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// ReadResource requests will first check the <see cref="ResourceCollection"/> for the exact resource being requested. If no match is found, they'll proceed to
|
||||
/// try to match the resource against each resource template in <see cref="ResourceCollection"/>. If no match is still found, the request will fall back to
|
||||
/// any handler registered for <see cref="ReadResourceHandler"/>.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
[JsonIgnore]
|
||||
[Obsolete($"Use {nameof(McpServerOptions.ResourceCollection)} instead. This member will be removed in a subsequent release.")] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public McpServerResourceCollection? ResourceCollection { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,16 +33,4 @@ public sealed class RootsCapability
|
|||
/// </remarks>
|
||||
[JsonPropertyName("listChanged")]
|
||||
public bool? ListChanged { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the handler for <see cref="RequestMethods.RootsList"/> requests.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This handler is invoked when a client sends a <see cref="RequestMethods.RootsList"/> request to retrieve available roots.
|
||||
/// The handler receives request parameters and should return a <see cref="ListRootsResult"/> containing the collection of available roots.
|
||||
/// </remarks>
|
||||
[JsonIgnore]
|
||||
[Obsolete($"Use {nameof(McpClientOptions.Handlers.RootsHandler)} instead. This member will be removed in a subsequent release.")] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public Func<ListRootsRequestParams?, CancellationToken, ValueTask<ListRootsResult>>? RootsHandler { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,29 +19,6 @@ namespace ModelContextProtocol.Protocol;
|
|||
/// </remarks>
|
||||
public sealed class SamplingCapability
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the handler for processing <see cref="RequestMethods.SamplingCreateMessage"/> requests.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// This handler function is called when an MCP server requests the client to generate content
|
||||
/// using an AI model. The client must set this property for the sampling capability to work.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// The handler receives message parameters, a progress reporter for updates, and a
|
||||
/// cancellation token. It should return a <see cref="CreateMessageResult"/> containing the
|
||||
/// generated content.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// You can create a handler using the <see cref="AIContentExtensions.CreateSamplingHandler"/> extension
|
||||
/// method with any implementation of <see cref="IChatClient"/>.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
[JsonIgnore]
|
||||
[Obsolete($"Use {nameof(McpClientOptions.Handlers.SamplingHandler)} instead. This member will be removed in a subsequent release.")] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public Func<CreateMessageRequestParams?, IProgress<ProgressNotificationValue>, CancellationToken, ValueTask<CreateMessageResult>>? SamplingHandler { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the client supports context inclusion via includeContext parameter.
|
||||
/// </summary>
|
||||
|
|
@ -57,4 +34,3 @@ public sealed class SamplingCapability
|
|||
[JsonPropertyName("tools")]
|
||||
public SamplingToolsCapability? Tools { get; set; }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -65,26 +65,4 @@ public sealed class ServerCapabilities
|
|||
/// </summary>
|
||||
[JsonPropertyName("completions")]
|
||||
public CompletionsCapability? Completions { get; set; }
|
||||
|
||||
/// <summary>Gets or sets notification handlers to register with the server.</summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// When constructed, the server will enumerate these handlers once, which may contain multiple handlers per notification method key.
|
||||
/// The server will not re-enumerate the sequence after initialization.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Notification handlers allow the server to respond to client-sent notifications for specific methods.
|
||||
/// Each key in the collection is a notification method name, and each value is a callback that will be invoked
|
||||
/// when a notification with that method is received.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Handlers provided via <see cref="NotificationHandlers"/> will be registered with the server for the lifetime of the server.
|
||||
/// For transient handlers, <see cref="McpSession.RegisterNotificationHandler"/> may be used to register a handler that can
|
||||
/// then be unregistered by disposing of the <see cref="IAsyncDisposable"/> returned from the method.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
[JsonIgnore]
|
||||
[Obsolete($"Use {nameof(McpServerOptions.Handlers.NotificationHandlers)} instead. This member will be removed in a subsequent release.")] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public IEnumerable<KeyValuePair<string, Func<JsonRpcNotification, CancellationToken, ValueTask>>>? NotificationHandlers { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,49 +22,4 @@ public sealed class ToolsCapability
|
|||
/// </remarks>
|
||||
[JsonPropertyName("listChanged")]
|
||||
public bool? ListChanged { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the handler for <see cref="RequestMethods.ToolsList"/> requests.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The handler should return a list of available tools when requested by a client.
|
||||
/// It supports pagination through the cursor mechanism, where the client can make
|
||||
/// repeated calls with the cursor returned by the previous call to retrieve more tools.
|
||||
/// When used in conjunction with <see cref="ToolCollection"/>, both the tools from this handler
|
||||
/// and the tools from the collection will be combined to form the complete list of available tools.
|
||||
/// </remarks>
|
||||
[JsonIgnore]
|
||||
[Obsolete($"Use {nameof(McpServerOptions.Handlers.ListToolsHandler)} instead. This member will be removed in a subsequent release.")] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public McpRequestHandler<ListToolsRequestParams, ListToolsResult>? ListToolsHandler { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the handler for <see cref="RequestMethods.ToolsCall"/> requests.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This handler is invoked when a client makes a call to a tool that isn't found in the <see cref="ToolCollection"/>.
|
||||
/// The handler should implement logic to execute the requested tool and return appropriate results.
|
||||
/// It receives a <see cref="RequestContext{CallToolRequestParams}"/> containing information about the tool
|
||||
/// being called and its arguments, and should return a <see cref="CallToolResult"/> with the execution results.
|
||||
/// </remarks>
|
||||
[JsonIgnore]
|
||||
[Obsolete($"Use {nameof(McpServerOptions.Handlers.CallToolHandler)} instead. This member will be removed in a subsequent release.")] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public McpRequestHandler<CallToolRequestParams, CallToolResult>? CallToolHandler { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a collection of tools served by the server.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Tools will specified via <see cref="ToolCollection"/> augment the <see cref="ListToolsHandler"/> and
|
||||
/// <see cref="CallToolHandler"/>, if provided. ListTools requests will output information about every tool
|
||||
/// in <see cref="ToolCollection"/> and then also any tools output by <see cref="ListToolsHandler"/>, if it's
|
||||
/// non-<see langword="null"/>. CallTool requests will first check <see cref="ToolCollection"/> for the tool
|
||||
/// being requested, and if the tool is not found in the <see cref="ToolCollection"/>, any specified <see cref="CallToolHandler"/>
|
||||
/// will be invoked as a fallback.
|
||||
/// </remarks>
|
||||
[JsonIgnore]
|
||||
[Obsolete($"Use {nameof(McpServerOptions.ToolCollection)} instead. This member will be removed in a subsequent release.")] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public McpServerPrimitiveCollection<McpServerTool>? ToolCollection { get; set; }
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue