forked from modelcontextprotocol/java-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/mcp transport context for http servlet sse server transport provider #4
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
Closed
stantonk
wants to merge
37
commits into
main
from
feature/McpTransportContext-for-HttpServletSseServerTransportProvider
Closed
Feature/mcp transport context for http servlet sse server transport provider #4
stantonk
wants to merge
37
commits into
main
from
feature/McpTransportContext-for-HttpServletSseServerTransportProvider
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: Christian Tzolov <[email protected]>
…xtprotocol#413) Addresses issues with servers like Shopify that violate MCP/HTTP specs: - Prioritize application/json in Accept headers to fix content-type issues - Handle non-compliant notification non-empty responses - Add status code validation and null safety improvements Resolves modelcontextprotocol#406 Signed-off-by: Christian Tzolov <[email protected]>
…nts (modelcontextprotocol#423) - Replace McpError exceptions with debug/warning logs for unrecognized SSE event types - Continue processing instead of failing when encountering unknown SSE events - Update transport implementations: - WebClientStreamableHttpTransport: return empty tuple instead of throwing - WebFluxSseClientTransport: complete stream instead of erroring - HttpClientSseClientTransport: call sink.success() instead of sink.error() - HttpClientStreamableHttpTransport: return empty Flux for unknown events This improves client resilience when servers send non-standard or future SSE event types. Resolves modelcontextprotocol#272 , modelcontextprotocol#223 , modelcontextprotocol#93, modelcontextprotocol#421 Signed-off-by: Christian Tzolov <[email protected]>
…ransport provider (modelcontextprotocol#420) - Add WebFluxStreamableServerTransportProvider for streamable HTTP sessions - Add WebFluxStatelessServerTransport for stateless HTTP MCP servers - Add McpStatelessServerFeatures, McpStatelessServerHandler, McpStatelessRequestHandler, McpStatelessNotificationHandler - Refactor server architecture to support multiple transport categories: streamable, single-session, stateless - Introduce McpTransportContext for transport-level metadata extraction - Add session management capabilities for streamable HTTP connections - Update MCP protocol version to 2025-03-26 - Add test coverage for new transport implementations - Implement integration tests for both stateless and streamable transports Signed-off-by: Dariusz Jędrzejczyk <[email protected]> Signed-off-by: Christian Tzolov <[email protected]> Co-authored-by: Christian Tzolov <[email protected]>
…ntextprotocol#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 - Wrap handler invocations with Mono.defer for lazy evaluation - Wrap consumer, tool, resource, prompt, and completion handler calls with Mono.defer() - Ensures proper lazy evaluation and error handling in reactive streams Related to modelcontextprotocol#72 Signed-off-by: Christian Tzolov <[email protected]> Signed-off-by: Dariusz Jędrzejczyk <[email protected]> Co-authored-by: Dariusz Jędrzejczyk <[email protected]>
…protocol#290) Implementation of the Streamable HTTP transport provider for the Servlet API. --- Signed-off-by: Christian Tzolov <[email protected]> Co-authored-by: Christian Tzolov <[email protected]> Co-authored-by: Zachary German <[email protected]>
- Minor improvement: speed up HttpClientSseClientTransportTests by reusing the MCP Server container across tests. - Minor improvement: rename "messageSink" to "deliveredSink" in HttpClientStreamableHttpTransport#sendMessage
…nsports - Add KeepAliveScheduler utility class for configurable periodic session pings - Integrate keep-alive support in WebFlux, WebMVC, and HttpServlet SSE transport providers - Add keepAliveInterval configuration option to all transport provider builders - Deprecate existing constructors in favor of builder pattern with enhanced configuration - Update graceful shutdown to properly clean up keep-alive schedulers - Add unit tests for KeepAliveScheduler functionality Implements MCP specification recommendations for connection health detection: - Configurable ping frequency to suit different network environments - Optional keep-alive (disabled by default) to avoid excessive network overhead - Proper resource cleanup to prevent connection leaks https://modelcontextprotocol.io/specification/2025-06-18/basic/utilities/ping#implementation-considerations Resolves: modelcontextprotocol#414, modelcontextprotocol#158 Replaces modelcontextprotocol#353 Signed-off-by: Christian Tzolov <[email protected]>
- Add getters for both MCP Sync/Async clients Signed-off-by: Ilayaperumal Gopinathan <[email protected]>
…extprotocol#404) - Add protocolVersion() method to transport and transport provider interfaces and implementations - Replace hardcoded HTTP header strings with HttpHeaders constants - Update protocol versions to be transport-specific rather than global - Deprecate McpSchema.LATEST_PROTOCOL_VERSION in favor of transport-specific versions - Standardize header names: MCP-Protocol-Version, mcp-session-id, last-event-id - Update clients and servers to use transport.protocolVersion() for initialization - Refactor tests to use transport-specific protocol versions - Include MCP-Protocol-Version header in all GET/POST/DELETE requests - Update WebClientStreamableHttpTransport, WebFluxSseClientTransport, HttpClientSseClientTransport, and HttpClientStreamableHttpTransport Related to modelcontextprotocol#398 , modelcontextprotocol#363 , modelcontextprotocol#250 Signed-off-by: Christian Tzolov <[email protected]>
- Add WebMvcStatelessServerTransport for mcp-spring-webmvc module - Add HttpServletStatelessServerTransport for mcp module - Implement builder patterns for AsyncToolSpecification and SyncToolSpecification - Create AbstractStatelessIntegrationTests base class for shared test functionality - Add integration tests for both transport implementations Signed-off-by: Christian Tzolov <[email protected]>
Signed-off-by: Christian Tzolov <[email protected]>
Signed-off-by: Christian Tzolov <[email protected]>
Signed-off-by: Christian Tzolov <[email protected]>
Signed-off-by: Christian Tzolov <[email protected]>
Signed-off-by: Christian Tzolov <[email protected]>
Signed-off-by: Christian Tzolov <[email protected]>
Signed-off-by: Christian Tzolov <[email protected]>
Signed-off-by: Christian Tzolov <[email protected]>
- Add copyright headers to files missing them - Add blank lines after copyright headers for consistency - Remove unused imports in test files - Remove unnecessary keep-alive warning logs in WebFlux and WebMvc transport providers Signed-off-by: Christian Tzolov <[email protected]>
…col versions - Add ProtocolVersions interface with version constants - Change protocolVersion() to protocolVersions() returning List<String> - Streamable HTTP clients now support both 2024-11-05 and 2025-03-26 - Fixes compatibility with MCP servers that return 2024-11-05 instead of 2025-03-26 Resolves modelcontextprotocol#436 Related to modelcontextprotocol#438 Signed-off-by: Christian Tzolov <[email protected]>
Signed-off-by: Yanming Zhou <[email protected]>
- Remove length check in hookOnComplete() to always emit AggregateResponseEvent - Ensures proper completion handling regardless of response content length - Add test for empty application/json responses with 200 OK status
- Change logger.error() to logger.warn() for unhandled notification methods - Log full notification object instead of just method name for better context - Affects McpClientSession, McpServerSession, and McpStreamableServerSession Signed-off-by: Christian Tzolov <[email protected]>
- Closes modelcontextprotocol#458 Signed-off-by: Daniel Garnier-Moiroux <[email protected]>
- Add support for ignoring SSE comment lines that start with ':' - Add debug logging for comment line processing Resolves modelcontextprotocol#443 Signed-off-by: Christian Tzolov <[email protected]>
Handlers should be able to throw RPC errors and `McpError` is the right exception for that. Improve `DefaultMcpStatelessServerHandler` error handler to check if the exception is `McpError` and, if so, use it to build the RPC error result instead of re-writing as `INTERNAL_ERROR`.
…ties - Add builder pattern to McpError for structured error creation with validation - Deprecate McpError(Object) constructor in favor of builder approach - Add mutate() method to server capabilities for creating modified copies Signed-off-by: Christian Tzolov <[email protected]>
…asses (modelcontextprotocol#473) refactor: extract common integration test logic into abstract base classes - Move duplicated test methods from WebFlux and WebMvc integration test classes to abstract base classes - WebFluxSseIntegrationTests, WebFluxStreamableIntegrationTests now extend AbstractMcpClientServerIntegrationTests - WebFluxStatelessIntegrationTests, WebMvcStatelessIntegrationTests now extend AbstractStatelessIntegrationTests - Each concrete test class now only implements transport-specific setup methods (prepareClients, prepareAsyncServerBuilder, prepareSyncServerBuilder) - Eliminates ~1300+ lines of duplicated test code across multiple files - Improves maintainability by centralizing test logic in reusable base classes - Updates WebMvcSseServerTransportProvider to use builder pattern - Adds new HttpServletSseIntegrationTests extending AbstractMcpClientServerIntegrationTests - Removes HttpServletSseServerTransportProviderIntegrationTests - Standardizes timeout configurations and client setup across all integration tests Signed-off-by: Christian Tzolov <[email protected]>
- Replace inline StepVerifier assertions with AtomicReference pattern for better testability - Add assertWith() usage for cleaner assertion blocks in async tests - Simplify reactive chains using doOnNext() and thenReturn() patterns - Remove unnecessary Thread.sleep() from elicitation handler - Improve variable naming (rootsRef → toolsRef) for clarity - Update timeout error message assertions to be more specific - Clean up code formatting and remove redundant comments Signed-off-by: Christian Tzolov <[email protected]>
…rovider and HttpServletStreamableServerTransportProvider
maxrjohnson23
approved these changes
Aug 12, 2025
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.
NOTE: I'm waiting on this being merged upstream (modelcontextprotocol#477), but for now we'll build internally
Implements modelcontextprotocol#476.
Motivation and Context
modelcontextprotocol#420 introduced McpTransportContext.
McpTransportContext
should be supported inHttpServletSseServerTransportProvider
to enable those who are still on that transport to leverageMcpTransportContext
to set attributes that Tools, etc. have access to. This is crucial for implementing Authentication & Authorization at the Tool level.Current Behavior
McpTransportContext
is absent fromHttpServletSseServerTransportProvider
Context
How has this issue affected you?
We're not able to switch to
HttpServletStreamableServerTransportProvider
yet, but wish to useMcpTransportContext
instead of our custom built similar capability.What are you trying to accomplish?
Authn/z at Tool level.
How Has This Been Tested?
HttpServletSseServerTransportProvider
HttpServletSseServerTransportProvider
Breaking Changes
No, use of the
McpTransportContext
is optional.Types of changes
Checklist
Additional context
None