HttpRequest.Builder customizer for Client transports#388
Merged
tzolov merged 1 commit intomodelcontextprotocol:mainfrom Jul 30, 2025
Merged
Conversation
tzolov
reviewed
Jul 16, 2025
mcp/src/main/java/io/modelcontextprotocol/client/transport/HttpClientSseClientTransport.java
Show resolved
Hide resolved
Contributor
Author
|
Nice! I’ll tidy up the PR then. for WebClient-based transport, the WebClient has transformation primitives already (for ex ExchangeFilterFunction), so no need to add an MCP-specific customizer. |
Closed
3929197 to
0bfcc7c
Compare
- Minor improvement: speed up HttpClientSseClientTransportTests by reusing the MCP Server container across tests. - Minor improvement: rename "messageSink" to "deliveredSink" in HttpClientStreamableHttpTransport#sendMessage
0bfcc7c to
eeb4837
Compare
Contributor
|
Thanks @Kehrlann |
|
Would you consider renaming |
Contributor
Author
Member
|
A very recent class that's not intended for mainstream daily usage.. I think it should be acceptable. I'll leave it to @tzolov to make the final call. |
This was referenced Aug 4, 2025
Closed
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
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.
Provide a way to customize HTTP requests before executing them, for both
HttpClientSseClientTransportandHttpClientStreamableHttpTransport.We introduce
AsyncHttpRequestCustomizer, which is the core class that does the heavy lifting. For blocking contexts, we provide a simplerSyncHttpRequestCustomizerAPI, which ultimately gets wrapped. The details of the implementation in both transports is not relevant (yet) ; we are focused on both customizers and also on the transpots, specifically:AsyncHttpRequestCustomizerSyncHttpRequestCustomizerHttpClientSseClientTransport.Builder#requestCustomizerandHttpClientSseClientTransport.Builder#asyncRequestCustomizerHttpClientStreamableHttpTransport.Builder#requestCustomizerandHttpClientStreamableHttpTransport.Builder#asyncRequestCustomizerMotivation and Context
These are transport-level hooks, to allow users to modify request, e.g. to add security in headers (OAuth2 tokens, API keys, etc).
How Has This Been Tested?
Tested with a Servlet Spring app, using
SyncHttpRequestCustomizer.Breaking Changes
No.
Types of changes
Checklist