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
Refactor MCP client annotation handling with unified handler registries (#4802)
Replace specification factory pattern with centralized handler registries
that scan and register MCP client handlers (sampling, elicitation, logging,
progress, and list-changed notifications). This simplifies the
auto-configuration by:
- Introducing ClientMcpSyncHandlersRegistry and ClientMcpAsyncHandlersRegistry
that scan beans once for annotations and expose handlers by client name
- Removing intermediate specification factory beans and customizers
- Directly configuring MCP client specs from registries during client creation
- Eliminating need for separate specification classes per handler type
- Simplifying ToolCallingAutoConfiguration by removing
BeanDefinitionRegistryPostProcessor complexity
- In febf86c, we broke a dependency cycle ChatClient -> McpClient
- With the introduction of ClientMcpSyncHandlersRegistry and the async
variant, there is no dependency McpClient -> MCP handlers anymore,
breaking the cycle in a simpler way.
- Here, we revert most of the changes of febf86c, but keep the tests.
- Remove unused MCP annotated beans auto-configuration
- Introduce AbstractClientMcpHandlerRegistry
- Find MCP Client annotations on @component beans
- AbstractClientMcpHandlerRegistry also discovers proxied beans
- Remove custom class resolution method and use AutoProxyUtils instead
- Add logging to MCP handlers registry
- Throw MCP Error on missing sampling and elicitation handlers in a client
- Fix missing auto-configurations McpClientAutoConfigurationIT
Signed-off-by: Daniel Garnier-Moiroux <git@garnier.wf>
Copy file name to clipboardExpand all lines: auto-configurations/mcp/spring-ai-autoconfigure-mcp-client-common/src/main/java/org/springframework/ai/mcp/client/common/autoconfigure/McpClientAutoConfiguration.java
Copy file name to clipboardExpand all lines: auto-configurations/mcp/spring-ai-autoconfigure-mcp-client-common/src/main/java/org/springframework/ai/mcp/client/common/autoconfigure/annotations/McpAsyncAnnotationCustomizer.java
Copy file name to clipboardExpand all lines: auto-configurations/mcp/spring-ai-autoconfigure-mcp-client-common/src/main/java/org/springframework/ai/mcp/client/common/autoconfigure/annotations/McpClientAnnotationScannerAutoConfiguration.java
0 commit comments