@@ -294,11 +294,55 @@ class McpConfiguration {
294294}
295295```
296296
297+ ### Use with ` spring-ai-starter-mcp-client-webflux `
298+
299+ When using ` spring-ai-starter-mcp-client-webflux ` , the underlying MCP client transport will be based on a Spring
300+ reactive ` WebClient ` .
301+ In that case, you can expose a bean of type ` WebClient.Builder ` , configured with an MCP implementation of
302+ ` ExchangeFilterFunction ` .
303+ Depending on your [ authorization flow] ( #authorization-flows ) of choice, you may use one of the following
304+ implementations:
305+
306+ - ` McpOAuth2AuthorizationCodeExchangeFilterFunction ` (preferred)
307+ - ` McpOAuth2ClientCredentialsExchangeFilterFunction ` (machine-to-machine)
308+ - ` McpOAuth2HybridExchangeFilterFunction ` (last resort)
309+
310+ All these request customizers rely on request and authentication data.
311+ That data is passed through
312+ ` McpTransportContext ` ([ MCP docs] ( https://modelcontextprotocol.io/sdk/java/mcp-client#adding-context-information ) ).
313+ To make that information available, you also need to add an ` AuthenticationMcpTransportContextProvider ` to your MCP Sync
314+ Client.
315+ Tying it all together, taking ` McpOAuth2AuthorizationCodeExchangeFilterFunction ` as an example:
316+
317+ ``` java
318+
319+ @Configuration
320+ class McpConfiguration {
321+
322+ @Bean
323+ McpSyncClientCustomizer syncClientCustomizer () {
324+ return (name, syncSpec) - > syncSpec. transportContextProvider(new AuthenticationMcpTransportContextProvider ());
325+ }
326+
327+ @Bean
328+ WebClient .Builder mcpWebClientBuilder (OAuth2AuthorizedClientManager clientManager ) {
329+ // The clientRegistration name, "authserver", must match the name in application.properties
330+ return WebClient . builder()
331+ .filter(new McpOAuth2AuthorizationCodeExchangeFilterFunction (clientManager, " authserver" ));
332+ }
333+ }
334+ ```
335+
297336### Known limitations
298337
299- TODO
338+ - Spring WebFlux servers are not supported.
339+ - Spring AI autoconfiguration initializes the MCP client app start.
340+ Most MCP servers want require calls to be authenticated with a token.
341+
342+ Note:
300343
301- - Mention Tool confusion on initialization
344+ - Unlike the ` mcp-server-security ` module, the client implementation supports the SSE transport, both with ` HttpClient `
345+ and ` WebClient ` .
302346
303347## Authorization Server
304348
0 commit comments