Fix for #793 - public (or protected) constructors to allow subclassing for extensions#794
Open
scottslewis wants to merge 11 commits intomodelcontextprotocol:mainfrom
Open
Fix for #793 - public (or protected) constructors to allow subclassing for extensions#794scottslewis wants to merge 11 commits intomodelcontextprotocol:mainfrom
scottslewis wants to merge 11 commits intomodelcontextprotocol:mainfrom
Conversation
Signed-off-by: Scott Lewis <scottslewis@gmail.com>
variable to protected, so that extensions/subclasses can access.
and async servers and clients
for subclassing/extension.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.