-
Notifications
You must be signed in to change notification settings - Fork 575
HttpRequest.Builder customizer for Client transports #388
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
HttpRequest.Builder customizer for Client transports #388
Conversation
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.
@Kehrlann I think this would work.
What about the webflux clients. would we need to expose a similar customizer abstractions there as well?
mcp/src/main/java/io/modelcontextprotocol/client/transport/HttpClientSseClientTransport.java
Show resolved
Hide resolved
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. |
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
Thanks @Kehrlann |
Would you consider renaming |
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. |
Provide a way to customize HTTP requests before executing them, for both
HttpClientSseClientTransport
andHttpClientStreamableHttpTransport
.We introduce
AsyncHttpRequestCustomizer
, which is the core class that does the heavy lifting. For blocking contexts, we provide a simplerSyncHttpRequestCustomizer
API, 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:AsyncHttpRequestCustomizer
SyncHttpRequestCustomizer
HttpClientSseClientTransport.Builder#requestCustomizer
andHttpClientSseClientTransport.Builder#asyncRequestCustomizer
HttpClientStreamableHttpTransport.Builder#requestCustomizer
andHttpClientStreamableHttpTransport.Builder#asyncRequestCustomizer
Motivation 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