Add an interface for McpServerSession to allow for more extensibility #258
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.
Having an interface rather than a concrete class
can help with extensibility of the McpServerSession class. This PR implements that and changes usages around the code to only mention the interface rather than the implementation class.
I don't think this qualifies as an extensive change so I didn't open an issue for that.
But I'm happy to do so if you deem it otherwise.
Motivation and Context
I was doing a hack project at my company and we were using the
HttpServletSseServerTransportProvider
whenwe realized that we couldn't really add some functionalities (in this case it was mainly logging) to active
sessions by creating a delegate because the
McpServerSession
class was a concreteclass rather than an interface and
McpServerSession.Factory
implementations returned saidconcrete implementation.
If we use and interface there, we could make the code more flexible and extendible.
How Has This Been Tested?
mvn clean verify
Breaking Changes
It should be transparent to users given that the interface has the same name the concrete class had.
Types of changes
Checklist
Additional context