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.

Breaking Changes (Migration Summary)

Handlers and collections in the Capabilities types are now obsolete; they've been moved to McpClientOptions and McpServerOptions.

1. Collections

Replace usages of the obsolete collections with the corresponding collections on the options types:

Old

new McpServerOptions() 
{
    Capabilities = new() 
    {
        Tools = new() 
        { 
            ToolCollection = [McpServerTool.Create(...)] 
        }
    }
};

New

new McpServerOptions()
{
    ToolCollection = [McpServerTool.Create(...)]
};

2. Handlers

Replace usages of the obsolete handlers with the corresponding handlers on the options types:

Old

new McpServerOptions()
{
    Capabilities = new()
    {
        Tools = new()
        {
            CallToolHandler = (request, ct) => { ... }
        }
    }
};

New

new McpServerOptions()
{
    Handlers = new()
    {
        CallToolHandler = (request, ct) => { ... }
    }
};

Mapping (Old → New)

Old New
myClientOptions.Capabilities.NotificationHandlers myClientOptions.Handlers.NotificationHandlers
myClientOptions.Capabilities.Elicitation.ElicitationHandler myClientOptions.Handlers.ElicitationHandler
myClientOptions.Capabilities.Roots.RootsHandler myClientOptions.Handlers.RootsHandler
myClientOptions.Capabilities.Sampling.SamplingHandler myClientOptions.Handlers.SamplingHandler
myServerOptions.Capabilities.NotificationHandlers myServerOptions.Handlers.NotificationHandlers
myServerOptions.Capabilities.Completions.CompleteHandler myServerOptions.Handlers.CompleteHandler
myServerOptions.Capabilities.Logging.SetLoggingLevelHandler myServerOptions.Handlers.SetLoggingLevelHandler
myServerOptions.Capabilities.Prompts.ListPromptsHandler myServerOptions.Handlers.ListPromptsHandler
myServerOptions.Capabilities.Prompts.GetPromptHandler myServerOptions.Handlers.GetPromptHandler
myServerOptions.Capabilities.Prompts.PromptCollection myServerOptions.PromptCollection
myServerOptions.Capabilities.Resources.ListResourceTemplatesHandler myServerOptions.Handlers.ListResourceTemplatesHandler
myServerOptions.Capabilities.Resources.ListResourcesHandler myServerOptions.Handlers.ListResourcesHandler
myServerOptions.Capabilities.Resources.ReadResourceHandler myServerOptions.Handlers.ReadResourceHandler
myServerOptions.Capabilities.Resources.SubscribeToResourcesHandler myServerOptions.Handlers.SubscribeToResourcesHandler
myServerOptions.Capabilities.Resources.UnsubscribeFromResourcesHandler myServerOptions.Handlers.UnsubscribeFromResourcesHandler
myServerOptions.Capabilities.Resources.ResourceCollection myServerOptions.ResourceCollection
myServerOptions.Capabilities.Tools.ListToolsHandler myServerOptions.Handlers.ListToolsHandler
myServerOptions.Capabilities.Tools.CallToolHandler myServerOptions.Handlers.CallToolHandler
myServerOptions.Capabilities.Tools.ToolCollection myServerOptions.ToolCollection

…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.
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?

Copy link
Author

Choose a reason for hiding this comment

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

Sorry, how it would diverge? The logic below will initialize the capabilities if they are null, if a handler is provided.

@jeffhandley jeffhandley added the breaking-change This issue or PR introduces a breaking change label Sep 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change This issue or PR introduces a breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants