Skip to content

Fix for #793 - public (or protected) constructors to allow subclassing for extensions#794

Open
scottslewis wants to merge 11 commits intomodelcontextprotocol:mainfrom
scottslewis:issue_792
Open

Fix for #793 - public (or protected) constructors to allow subclassing for extensions#794
scottslewis wants to merge 11 commits intomodelcontextprotocol:mainfrom
scottslewis:issue_792

Conversation

@scottslewis
Copy link
Contributor

@scottslewis scottslewis commented Feb 14, 2026

Fix for issue #793

This pr creates public constructors for McpSyncServer, McpAsyncServer and the stateless sync/async McpServer* types.

Technically the constructors could be protected rather than public, but I think for an SDK that public constructors is likely preferable.

Motivation and Context

The main motivation is to be able to subclass the various sdk server and client types...i.e. McpSyncServer, McpAsyncServer, McpSyncClient, McpAsyncClient, etc. I am creating an extension that has to override/customized notifyToolsListChanged() so that params can be added to the notification.

There are other use cases for extending the various server and client types in an sdk, along with making member variables protected, so that sdk external subsclasses can extend the behavior of these types.

Also, to extend these types requires that it be possible to invoke a subclass constructor, with instances of all the required arguments (e.g. McpServerFeatures.Async for McpAsyncServer). So these types also need to have public constructors.

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.

1 participant

Comments