Skip to content

Conversation

jozkee
Copy link

@jozkee jozkee commented Sep 11, 2025

Decouple Handlers and Collections (e.g. ToolsHandler and ToolsCollection) from Capabilities by promoting them to the options types.
Also, group all handlers in container classes, for server, I decided to move McpServerHandlers down to Mcp.Core and move the NotificationHandlers there too.

/// See the <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/">schema</see> for details.
/// </para>
/// </remarks>
public sealed class CompletionsCapability
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to keep this empty class?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I now notice the remark about it being empty in the spec. Could you check that this is still the case with the latest revision and whether keeping this around is still necessary?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't the presence of an instance of this signal to the connected party whether that capability is available?

…ion) from Capabilities by promoting them to the options types.

Also, group all handlers in container classes, for server, I decided to move McpServerHandlers down to Mcp.Core and move the NotificationHandlers there too.

Also, Fix ListResourceTemplatesHandler issue.
/// </remarks>
[JsonIgnore]
public McpRequestHandler<CompleteRequestParams, CompleteResult>? CompleteHandler { get; set; }
[Obsolete($"Use {nameof(McpServerHandlers.CompleteHandler)} instead.")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to state the full path for McpServerOptions.Handlers.CompleteHandler for easier discoverability.

/// then be unregistered by disposing of the <see cref="IAsyncDisposable"/> returned from the method.
/// </para>
/// </remarks>
public IEnumerable<KeyValuePair<string, Func<JsonRpcNotification, CancellationToken, ValueTask>>>? NotificationHandlers { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be a Dictionary<string, Func<...>> for easier initialization syntax? cc @stephentoub

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that initializer expressions work even if we don't provide a setter. This should ensure that we always use a consistent key comparer.

var notificationHandlers = new NotificationHandlers();
var requestHandlers = new RequestHandlers();

if (options.Capabilities is { } capabilities)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to this discussion, does removing the check on the capability make this diverge from the MCP spec?

/// </remarks>
[JsonIgnore]
public McpRequestHandler<GetPromptRequestParams, GetPromptResult>? GetPromptHandler { get; set; }
[Obsolete($"Use {nameof(McpServerHandlers.GetPromptHandler)} instead.")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment to all obsoleted members linking to #774 for easier removal in the future.

[Obsolete($"Use {nameof(McpClient)} instead.")] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants