Skip to content

Decouple Handlers and Collections from protocol types - #765

Merged
jozkee merged 6 commits into
modelcontextprotocol:mainfrom
jozkee:capabilities4
Sep 24, 2025
Merged

Decouple Handlers and Collections from protocol types#765
jozkee merged 6 commits into
modelcontextprotocol:mainfrom
jozkee:capabilities4

Conversation

@jozkee

@jozkeejozkee commented Sep 11, 2025

Copy link
Copy Markdown
Contributor

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

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

New

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

2. Handlers

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

Old

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

New

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

Mapping (Old → New)

OldNew
myClientOptions.Capabilities.NotificationHandlersmyClientOptions.Handlers.NotificationHandlers
myClientOptions.Capabilities.Elicitation.ElicitationHandlermyClientOptions.Handlers.ElicitationHandler
myClientOptions.Capabilities.Roots.RootsHandlermyClientOptions.Handlers.RootsHandler
myClientOptions.Capabilities.Sampling.SamplingHandlermyClientOptions.Handlers.SamplingHandler
myServerOptions.Capabilities.NotificationHandlersmyServerOptions.Handlers.NotificationHandlers
myServerOptions.Capabilities.Completions.CompleteHandlermyServerOptions.Handlers.CompleteHandler
myServerOptions.Capabilities.Logging.SetLoggingLevelHandlermyServerOptions.Handlers.SetLoggingLevelHandler
myServerOptions.Capabilities.Prompts.ListPromptsHandlermyServerOptions.Handlers.ListPromptsHandler
myServerOptions.Capabilities.Prompts.GetPromptHandlermyServerOptions.Handlers.GetPromptHandler
myServerOptions.Capabilities.Prompts.PromptCollectionmyServerOptions.PromptCollection
myServerOptions.Capabilities.Resources.ListResourceTemplatesHandlermyServerOptions.Handlers.ListResourceTemplatesHandler
myServerOptions.Capabilities.Resources.ListResourcesHandlermyServerOptions.Handlers.ListResourcesHandler
myServerOptions.Capabilities.Resources.ReadResourceHandlermyServerOptions.Handlers.ReadResourceHandler
myServerOptions.Capabilities.Resources.SubscribeToResourcesHandlermyServerOptions.Handlers.SubscribeToResourcesHandler
myServerOptions.Capabilities.Resources.UnsubscribeFromResourcesHandlermyServerOptions.Handlers.UnsubscribeFromResourcesHandler
myServerOptions.Capabilities.Resources.ResourceCollectionmyServerOptions.ResourceCollection
myServerOptions.Capabilities.Tools.ListToolsHandlermyServerOptions.Handlers.ListToolsHandler
myServerOptions.Capabilities.Tools.CallToolHandlermyServerOptions.Handlers.CallToolHandler
myServerOptions.Capabilities.Tools.ToolCollectionmyServerOptions.ToolCollection

Comment threadsrc/ModelContextProtocol/McpServerOptionsSetup.cs Outdated
Comment threadREADME.md Outdated
Comment threadREADME.md Outdated
Comment threadsrc/ModelContextProtocol.Core/Protocol/ClientCapabilities.cs
Comment threadsrc/ModelContextProtocol.Core/Protocol/ElicitationCapability.cs Outdated
…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.
Comment threadsrc/ModelContextProtocol.Core/Protocol/CompletionsCapability.cs Outdated
Comment threadsrc/ModelContextProtocol.Core/Client/McpClientHandlers.cs
Comment threadsrc/ModelContextProtocol.Core/Client/McpClientImpl.cs
Comment threadsrc/ModelContextProtocol.Core/Protocol/PromptsCapability.cs Outdated
Comment threadREADME.md Outdated
Comment threadsrc/ModelContextProtocol.Core/Client/McpClientHandlers.cs Outdated
Comment threadsrc/ModelContextProtocol.Core/Client/McpClientHandlers.cs
Comment threadsrc/ModelContextProtocol.Core/Protocol/CompletionsCapability.cs Outdated
Comment threadsrc/ModelContextProtocol.Core/Protocol/PromptsCapability.cs Outdated
Comment threadsrc/ModelContextProtocol.Core/Protocol/ClientCapabilities.cs Outdated
Comment threadsrc/ModelContextProtocol.Core/Server/McpServerOptions.cs
Comment threadsrc/ModelContextProtocol/McpServerOptionsSetup.cs
Comment threadtests/ModelContextProtocol.TestServer/Program.cs
Comment threadtests/ModelContextProtocol.Tests/Server/McpServerTests.cs
@jeffhandleyjeffhandley added the breaking-change This issue or PR introduces a breaking change label Sep 23, 2025

@eiriktsarpaliseiriktsarpalis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks.

@jozkee
jozkee merged commit 5f99299 into modelcontextprotocol:mainSep 24, 2025
8 checks passed
@jozkee
jozkee deleted the capabilities4 branch September 24, 2025 14:42

@sayiedanwartt-designsayiedanwartt-design left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Screenshot_2025-11-30-04-07-47-190_com android chrome

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-changeThis issue or PR introduces a breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@jozkee@stephentoub@eiriktsarpalis@sayiedanwartt-design@jeffhandley