MCP ToolCallbackProvider autoconfig should use concrete class
Currently, the MCP Tool autoconfiguration defines the SyncMcpToolCallbackProvider and AsyncMcpToolCallbackProvider beans returning the ToolCallbackProvider interface. That generates autowiring warnings in IDEs when trying to inject the specific class. The Spring Boot project recommends being specific. 'When declaring a @Bean method, provide as much type information as possible in the method’s return type. For example, if your bean’s concrete class implements an interface the bean method’s return type should be the concrete class and not the interface. Providing as much type information as possible in @Bean methods is particularly important when using bean conditions as their evaluation can only rely upon to type information that is available in the method signature.' See https://docs.spring.io/spring-boot/reference/features/developing-auto-configuration.html#features.developing-auto-configuration.condition-annotations.bean-conditions This PR ensures concrete classes are used. Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
This commit is contained in:
committed by
Christian Tzolov
parent
14972f981f
commit
81137cae54
@@ -52,14 +52,14 @@ public class McpToolCallbackAutoConfiguration {
|
||||
@Bean
|
||||
@ConditionalOnProperty(prefix = McpClientCommonProperties.CONFIG_PREFIX, name = "type", havingValue = "SYNC",
|
||||
matchIfMissing = true)
|
||||
public ToolCallbackProvider mcpToolCallbacks(ObjectProvider<List<McpSyncClient>> syncMcpClients) {
|
||||
public SyncMcpToolCallbackProvider mcpToolCallbacks(ObjectProvider<List<McpSyncClient>> syncMcpClients) {
|
||||
List<McpSyncClient> mcpClients = syncMcpClients.stream().flatMap(List::stream).toList();
|
||||
return new SyncMcpToolCallbackProvider(mcpClients);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(prefix = McpClientCommonProperties.CONFIG_PREFIX, name = "type", havingValue = "ASYNC")
|
||||
public ToolCallbackProvider mcpAsyncToolCallbacks(ObjectProvider<List<McpAsyncClient>> mcpClientsProvider) {
|
||||
public AsyncMcpToolCallbackProvider mcpAsyncToolCallbacks(ObjectProvider<List<McpAsyncClient>> mcpClientsProvider) {
|
||||
List<McpAsyncClient> mcpClients = mcpClientsProvider.stream().flatMap(List::stream).toList();
|
||||
return new AsyncMcpToolCallbackProvider(mcpClients);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user