Should Spring AI MCP Client support Service Discovery integration? #5593
SkyeBeFreeman
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Background
As Spring AI is increasingly adopted in enterprise microservices environments, a common pain point emerges: MCP client connections require statically configured URLs in application properties.
In a dynamic microservices landscape powered by service registries (Nacos, Consul, Eureka, Kubernetes), this approach has clear limitations:
The Question
Should Spring AI provide first-class support for integrating MCP client transports with service discovery?
Option A: Interceptor-based (minimal, flexible)
Introduce a lightweight
McpSseConnectionInterceptor/McpStreamableHttpConnectionInterceptorthat lets users plug in any service discovery mechanism at startup:Pros: Zero extra dependency, works with any registry, composable with Spring Cloud LoadBalancer
Cons: Requires user code; resolution happens at startup, not per-request
Option B: Dedicated
spring-ai-mcp-client-spring-cloudmoduleProvide an optional auto-configuration module that bridges
DiscoveryClientwith MCP transport creation automatically, similar to how Spring Cloud OpenFeign integrates with Ribbon/LoadBalancer.Pros: Zero boilerplate for Spring Cloud users; can support per-request resolution and load balancing
Cons: Additional dependency on
spring-cloud-commons; adds maintenance burdenOption C: Dynamic MCP client management
Go further: support hot-plugging MCP servers at runtime by watching the service registry for changes, dynamically creating/destroying
McpClientbeans as services register and deregister.Pros: True dynamic tooling — AI agents can discover new capabilities without restart
Cons: Significantly more complex; requires lifecycle management of
McpClientbeansMy Current Proposal
I've submitted PRs #5549 (1.1.x) and #5578 (main) implementing Option A as a low-risk first step. This unblocks enterprise users immediately while leaving the door open for Options B and C in the future.
Questions for the Community
spring-ai-mcp-client-spring-cloudintegration module?Would love to hear thoughts from both the Spring AI team and the community!
Beta Was this translation helpful? Give feedback.
All reactions