-
Notifications
You must be signed in to change notification settings - Fork 196
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
Refactor server side to handle multiple clients #31
Closed
+9,969
−1,127
Conversation
This file contains 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
6e94fd8
to
c56ab94
Compare
WARN: This is still work in progress and does not compile. Breaking changes: * McpAsyncServer * getClientCapabilities deprecated + throws * getClientInfo deprecated + throws * listRoots deprecated + throws * createMessage deprecated + throws * McpTransport * connect deprecated - should only belong to McpClientTransport * ServerMcpTransport * connect default implementation that throws The major change is the introduction of ServerMcpSession for per-client communication. The user should be exposed to a limited abstraction that hides the session called ServerMcpExchange which currently exposes sampling and roots. Signed-off-by: Dariusz Jędrzejczyk <[email protected]>
Signed-off-by: Dariusz Jędrzejczyk <[email protected]>
Signed-off-by: Dariusz Jędrzejczyk <[email protected]>
Signed-off-by: Dariusz Jędrzejczyk <[email protected]>
Signed-off-by: Dariusz Jędrzejczyk <[email protected]>
Signed-off-by: Dariusz Jędrzejczyk <[email protected]>
…change This commit changes the parameter type in sync handler interfaces from McpAsyncServerExchange to McpSyncServerExchange for better API consistency. It also adds proper wrapping of async exchanges in sync exchanges when bridging between async and sync contexts in the adapter methods. Signed-off-by: Christian Tzolov <[email protected]>
Add StdioServerTransportProvider implementation that uses reactive streams for both inbound and outbound message processing. - Using Flux for asynchronous message handling - Implementing separate inbound and outbound processing pipelines - Improving error handling with proper propagation Signed-off-by: Christian Tzolov <[email protected]>
This commit introduces WebMvcSseServerTransportProvider as a replacement for the now-deprecated WebMvcSseServerTransport. The new provider-based implementation offers improved session management and better alignment with the MCP specification. Additional changes: - Deprecate WebMvcSseServerTransport and StdioServerTransport - Add corresponding deprecated test classes to maintain backward compatibility - Increase test timeouts from 300ms to 1000ms/2000ms for more reliable testing - Minor rename of ClientMcpTransport to McpClientTransport for naming consistency Signed-off-by: Christian Tzolov <[email protected]>
…sed implementation Introduces HttpServletSseServerTransportProvider as a replacement for HttpServletSseServerTransport, following the provider pattern used by other transport implementations. The new implementation offers the same functionality but with a more consistent API aligned with the McpServerTransportProvider interface. - Mark HttpServletSseServerTransport as @deprecated (to be removed in 0.9.0) - Add new HttpServletSseServerTransportProvider implementation - Update test classes to use the new provider-based implementation - Add separate test classes for deprecated implementation Signed-off-by: Christian Tzolov <[email protected]>
Signed-off-by: Christian Tzolov <[email protected]>
Changed visibility of toSpecification() methods from package-private to public in all registration classes: - AsyncToolRegistration - AsyncResourceRegistration - AsyncPromptRegistration - SyncToolRegistration - SyncResourceRegistration - SyncPromptRegistration Signed-off-by: Christian Tzolov <[email protected]>
Signed-off-by: Christian Tzolov <[email protected]>
f5fed84
to
6da69b4
Compare
Loading status checks…
…tMcpSession to McpClientSession - Replace the ClientMcpTransport interface with McpClientTransport and deprecate former - Replace the DefaultMcpSession with McpClientSession and deprecate DefaultMcpSession - Change all client transport implementation to implement the McpClientTransport instead of ClientMcpTransport - The McpMockTransport implements McpClientTransport instead of ClientMcpTransport Signed-off-by: Christian Tzolov <[email protected]>
Signed-off-by: Christian Tzolov <[email protected]>
Signed-off-by: Christian Tzolov <[email protected]>
tzolov
added a commit
that referenced
this pull request
Mar 20, 2025
Loading
Loading status checks…
This commit introduces a major refactoring of the MCP Java SDK to implement a session-based architecture for server-side implementations. The changes improve the SDK's ability to handle multiple concurrent client connections and provide an API better aligned with the MCP specification. Key changes: - Introduce McpServerTransportProvider interface to manage client connections - Rename ClientMcpTransport to McpClientTransport and ServerMcpTransport to McpServerTransport - Add exchange objects (McpAsyncServerExchange, McpSyncServerExchange) for client interaction - Update handler signatures to include exchange parameter: (args) -> result to (exchange, args) -> result - Rename Registration classes to Specification classes - Update method names (e.g., rootsChangeConsumers to rootsChangeHandlers) - Deprecate old interfaces and classes for removal in 0.9.0 - Add migration guide (migration-0.8.0.md) Resolves #9, #15 Co-authored-by: Dariusz Jędrzejczyk <[email protected]> Signed-off-by: Christian Tzolov <[email protected]>
squashed and merged at f50f88c |
This was referenced Mar 20, 2025
Closed
tzolov
added a commit
that referenced
this pull request
Mar 20, 2025
This commit introduces a major refactoring of the MCP Java SDK to implement a session-based architecture for server-side implementations. The changes improve the SDK's ability to handle multiple concurrent client connections and provide an API better aligned with the MCP specification. Key changes: - Introduce McpServerTransportProvider interface to manage client connections - Rename ClientMcpTransport to McpClientTransport and ServerMcpTransport to McpServerTransport - Add exchange objects (McpAsyncServerExchange, McpSyncServerExchange) for client interaction - Update handler signatures to include exchange parameter: (args) -> result to (exchange, args) -> result - Rename Registration classes to Specification classes - Update method names (e.g., rootsChangeConsumers to rootsChangeHandlers) - Deprecate old interfaces and classes for removal in 0.9.0 - Add migration guide (migration-0.8.0.md) Resolves #9, #15 Co-authored-by: Christian Tzolov <[email protected]> Signed-off-by: Christian Tzolov <[email protected]>
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.
This PR introduces an internal concept of a server session maintained with a particular client alongside with a user-facing concept of an exchange, which provides means to communicate with the client as part of a server handler.
We are trying to avoid breaking changes by introducing deprecations with occasional breakages for those enhancing the core SDK. These are listed in the migration document.