-
Notifications
You must be signed in to change notification settings - Fork 564
[WIP] feat: Add Spring WebMVC streamable server transport provider #425
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
Draft
tzolov
wants to merge
19
commits into
modelcontextprotocol:main
Choose a base branch
from
tzolov:streamable-server-webmvc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
[WIP] feat: Add Spring WebMVC streamable server transport provider #425
tzolov
wants to merge
19
commits into
modelcontextprotocol:main
from
tzolov:streamable-server-webmvc
Conversation
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
Signed-off-by: Dariusz Jędrzejczyk <[email protected]>
…raction 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]>
…sync server tests Signed-off-by: Dariusz Jędrzejczyk <[email protected]>
7 tasks
Open
ba7756f
to
9e660d1
Compare
tzolov
commented
Jul 28, 2025
return ServerResponse.status(HttpStatus.SERVICE_UNAVAILABLE).body("Server is shutting down"); | ||
} | ||
|
||
McpTransportContext transportContext = this.contextExtractor.apply(request); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How to make use of this?
tzolov
commented
Jul 28, 2025
return ServerResponse.notFound().build(); | ||
} | ||
|
||
return session.delete().then(ServerResponse.ok().build()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we need to remove the session from the sessions maps as well?
e.g. this.sessions.remove(sessionId);
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: Christian Tzolov <[email protected]>
- Add WebMvcStreamableServerTransportProvider for non-reactive MCP server support - Implement HTTP/SSE transport with session management and graceful shutdown - Support GET, POST, DELETE endpoints for MCP protocol operations - Add test suite including integration tests with Tomcat - Refactor AbstractMcpAsyncServerTests to support multiple transport implementations - Provide WebMVC alternative to existing WebFlux streamable transport Related to modelcontextprotocol#72 Signed-off-by: Christian Tzolov <[email protected]>
- Enhance McpStreamableServerSession error handling with proper JSON-RPC error responses - Add mcp-spring-webflux test dependency to webmvc module - Refactor WebMvcStreamableIntegrationTests to use parameterized tests - Support testing with both HttpClient and WebFlux transports - Add WebClientStreamableHttpTransport integration - Improve error handling in McpStreamableServerSession - Add proper timeout configurations for test clients - Clean up test structure and imports organization This enables comprehensive testing of WebMVC functionality with multiple transport mechanisms, ensuring compatibility across different client types. Signed-off-by: Christian Tzolov <[email protected]>
…ble transport - Add ReentrantLock synchronization to prevent race conditions in concurrent sseBuilder usage - Add volatile closed flag to track session state and prevent operations on closed sessions - Move SSE onComplete callback to properly close listening stream when connection completes - Refactor closeGracefully to delegate to close() method for consistent cleanup - Update class documentation to reflect thread-safety guarantees This ensures safe concurrent access to SSE builder and proper cleanup of streaming resources. Signed-off-by: Christian Tzolov <[email protected]>
… class - Extract common test logic from WebMvcSseIntegrationTests and WebMvcStreamableIntegrationTests into AbstractMcpClientServerIntegrationTests - Add json-unit-assertj dependency to mcp-test module for JSON assertion support - Make McpServer.SyncSpecification abstract to enforce proper inheritance - Remove duplicate test implementations (~2000+ lines of code deduplicated) - Maintain parameterized testing across different client transport types (httpclient, webflux) This refactoring eliminates significant code duplication between Spring WebMVC integration test classes while maintaining full test coverage and functionality. Signed-off-by: Christian Tzolov <[email protected]>
5c1d0d5
to
5290f39
Compare
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.
Related to #72
NOTE: built on top and depending on the #420
This PR adds Spring WebMVC streamable server transport provider support to the MCP Java SDK, providing a non-reactive alternative to the existing WebFlux implementation for HTTP/SSE-based MCP servers.
How Has This Been Tested?
The implementation has been thoroughly tested with:
WebMcpStreamableMcpAsyncServerTests
extending the abstract test suiteWebMvcStreamableIntegrationTests
with comprehensive scenarios including:Breaking Changes
No breaking changes.
Types of changes
Checklist
Additional context
Implementation Details:
WebMvcStreamableServerTransportProvider
implementsMcpStreamableServerTransportProvider
RouterFunction
for endpoint handling (GET, POST, DELETE)ServerResponse.sse()
for streaming responsesConcurrentHashMap
for thread safetyKey Features:
Testing Strategy:
AbstractMcpAsyncServerTests
to useprepareAsyncServerBuilder()
pattern