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.

…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.
},
};

options.Handlers.ListToolsHandler = (request, cancellationToken) =>
Copy link
Member

Choose a reason for hiding this comment

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

Not being able to set a handler within the object expression seems to me like a regression from a usability perspective. If decoupling handlers from the capability types is essential, consider using a structure that doesn't force this pattern (e.g. putting all handler properties on the ServerCapabilities type itself).

Copy link
Author

Choose a reason for hiding this comment

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

That could be enabled by adding a setter to McpServerOptions.Handlers.
I thought of having Handlers initialized by default to avoid the null-terminating operator in cases like Handlers?.ListToolsHandler. We could still achieve both if we make that the setter disallows null.

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.

2 participants