-
Notifications
You must be signed in to change notification settings - Fork 575
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
Merged
tzolov
merged 22 commits into
modelcontextprotocol:main
from
tzolov:streamable-server-webmvc
Jul 30, 2025
Merged
feat: Add Spring WebMVC streamable server transport provider #425
tzolov
merged 22 commits into
modelcontextprotocol:main
from
tzolov:streamable-server-webmvc
Jul 30, 2025
+2,410
−1,159
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]>
8 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]>
5c1d0d5
to
5290f39
Compare
Signed-off-by: Dariusz Jędrzejczyk <[email protected]>
6e7c16c
to
fd8d7bb
Compare
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]>
…protocol#425) - Add WebMvcStreamableServerTransportProvider with SSE support for streamable sessions - Support GET, POST, DELETE endpoints for MCP protocol operations - Implement thread-safe SSE operations using ReentrantLock in WebMvcSseServerTransportProvider - Add test infrastructure with AbstractMcpClientServerIntegrationTests - Refactor WebMvcStreamableIntegrationTests to use parameterized tests - Support testing with both HttpClient and WebFlux transports - Add streamable transport tests for both async and sync server modes - Refactor existing WebMVC SSE integration tests to use shared test base - Add error handling improvements in McpStreamableServerSession - Update dependencies: add json-unit-assertj for enhanced JSON testing - Reorganize POM dependencies and add mcp-spring-webflux test dependency This change enables Spring WebMVC applications to use the streamable MCP transport protocol with proper thread safety guarantees and comprehensive test coverage. Related to modelcontextprotocol#72 Signed-off-by: Christian Tzolov <[email protected]>
- Wrap consumer, tool, resource, prompt, and completion handler calls with Mono.defer() - Ensures proper lazy evaluation and error handling in reactive streams Signed-off-by: Christian Tzolov <[email protected]>
fd8d7bb
to
8a2e978
Compare
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