Skip to content

Add an interface for McpServerSession to allow for more extensibility #258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

apontini
Copy link

@apontini apontini commented May 21, 2025

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 when
we 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 concrete
class rather than an interface and McpServerSession.Factory implementations returned said
concrete 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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

apontini added 4 commits May 21, 2025 16:15
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
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