You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please do a quick search on GitHub issues first, the feature you are about to request might have already been requested.
Expected Behavior
I would like to add custom HTTP request headers to WebFluxSseClientTransport
like this, overload sendMessage method
@OverridepublicMono<Void> sendMessage(JSONRPCMessagemessage) {
returnsendMessage(message, httpHeaders -> {});
}
publicMono<Void> sendMessage(JSONRPCMessagemessage, Consumer<HttpHeaders> mutateHeaders) {
// The messageEndpoint is the endpoint URI to send the messages// It is provided by the server as part of the endpoint eventreturnmessageEndpointSink.asMono().flatMap(messageEndpointUri -> {
if (isClosing) {
returnMono.empty();
}
try {
StringjsonText = this.objectMapper.writeValueAsString(message);
returnwebClient.post()
.uri(messageEndpointUri)
.headers(mutateHeaders)
.contentType(MediaType.APPLICATION_JSON)
.bodyValue(jsonText)
.retrieve()
.toBodilessEntity()
.doOnSuccess(response -> {
logger.debug("Message sent successfully");
})
.doOnError(error -> {
if (!isClosing) {
logger.error("Error sending message: {}", error.getMessage());
}
});
}
catch (IOExceptione) {
if (!isClosing) {
returnMono.error(newRuntimeException("Failed to serialize message", e));
}
returnMono.empty();
}
}).then(); // TODO: Consider non-200-ok response
}
Current Behavior
Can't add custom header in WebFluxSseClientTransport
Context
If I can change the HTTP request header, I can do some extra processing on the server side like data permission checking. I briefly checked this article https://modelcontextprotocol.io/specification/2025-03-26/basic/authorization It doesn't seem to have been developed yet, so I don't know exactly how it will be used.
For common API Server to MCP Server conversion scenarios, the API Server already has its own authentication methods, and functional access control, data access control, for the current only missing the HTTP Header transfer.
The text was updated successfully, but these errors were encountered:
SunJiFengPlus
changed the title
Support mutate http header in WebFluxSseClientTransport
Support add custom http header in WebFluxSseClientTransportApr 18, 2025
Please do a quick search on GitHub issues first, the feature you are about to request might have already been requested.
Expected Behavior
I would like to add custom HTTP request headers to
WebFluxSseClientTransport
like this, overload
sendMessage
methodCurrent Behavior
Can't add custom header in
WebFluxSseClientTransport
Context
If I can change the HTTP request header, I can do some extra processing on the server side like data permission checking. I briefly checked this article https://modelcontextprotocol.io/specification/2025-03-26/basic/authorization It doesn't seem to have been developed yet, so I don't know exactly how it will be used.
For common API Server to MCP Server conversion scenarios, the API Server already has its own authentication methods, and functional access control, data access control, for the current only missing the HTTP Header transfer.
The text was updated successfully, but these errors were encountered: