The SseParameters and McpStreamableHttpClientProperties need Map<String, String> headers to support custom headers for our MCP server.
@tzolov would you like to take a look at this?
Comment From: quaff
See https://github.com/spring-projects/spring-ai/pull/3949
Comment From: Kehrlann
After discussion with the team, we have decided not to expand the configuration surface.
If you would like to add headers for which you know the value in advance, please use the following java configuration:
- For web-client based support, provide your own
WebClient.Builder:
@Bean
WebClient.Builder mcpClient() {
return WebClient.builder().defaultHeader("x-custom-header", "<HEADER-VALUE>");
}
- For HTTP-client based, provide
McpSyncRequestCustomizerorMcpAsyncRequestCustomizer:
@Bean
McpSyncHttpClientRequestCustomizer requestCustomizer() {
return (builder, method, endpoint, body, context) -> builder.header("x-custom-header", "<HEADER-VALUE>");
}