Class McpToolCallbackAutoConfiguration

java.lang.Object
org.springframework.ai.mcp.client.common.autoconfigure.McpToolCallbackAutoConfiguration

@AutoConfiguration(after=McpClientAutoConfiguration.class, beforeName="org.springframework.ai.model.chat.client.autoconfigure.ChatClientAutoConfiguration") @EnableConfigurationProperties(McpClientCommonProperties.class) @Conditional(McpToolCallbackAutoConfigurationCondition.class) public class McpToolCallbackAutoConfiguration extends Object
Responsible to convert MCP (sync and async) clients into Spring AI ToolCallbacksProviders. These providers are used by Spring AI to discover and execute tools.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.ai.mcp.McpToolNamePrefixGenerator
     
    org.springframework.ai.mcp.AsyncMcpToolCallbackProvider
    mcpAsyncToolCallbacks(org.springframework.beans.factory.ObjectProvider<org.springframework.ai.mcp.McpToolFilter> asyncClientsToolFilter, org.springframework.beans.factory.ObjectProvider<List<io.modelcontextprotocol.client.McpAsyncClient>> mcpClientsProvider, org.springframework.beans.factory.ObjectProvider<org.springframework.ai.mcp.McpToolNamePrefixGenerator> toolNamePrefixGenerator, org.springframework.beans.factory.ObjectProvider<org.springframework.ai.mcp.ToolContextToMcpMetaConverter> toolContextToMcpMetaConverter)
     
    org.springframework.ai.mcp.SyncMcpToolCallbackProvider
    mcpToolCallbacks(org.springframework.beans.factory.ObjectProvider<org.springframework.ai.mcp.McpToolFilter> syncClientsToolFilter, org.springframework.beans.factory.ObjectProvider<List<io.modelcontextprotocol.client.McpSyncClient>> syncMcpClients, org.springframework.beans.factory.ObjectProvider<org.springframework.ai.mcp.McpToolNamePrefixGenerator> mcpToolNamePrefixGenerator, org.springframework.beans.factory.ObjectProvider<org.springframework.ai.mcp.ToolContextToMcpMetaConverter> toolContextToMcpMetaConverter)
    Creates tool callbacks for all configured MCP clients.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • McpToolCallbackAutoConfiguration

      public McpToolCallbackAutoConfiguration()
  • Method Details

    • defaultMcpToolNamePrefixGenerator

      @Bean @ConditionalOnMissingBean public org.springframework.ai.mcp.McpToolNamePrefixGenerator defaultMcpToolNamePrefixGenerator()
    • mcpToolCallbacks

      @Bean @ConditionalOnProperty(prefix="spring.ai.mcp.client", name="type", havingValue="SYNC", matchIfMissing=true) public org.springframework.ai.mcp.SyncMcpToolCallbackProvider mcpToolCallbacks(org.springframework.beans.factory.ObjectProvider<org.springframework.ai.mcp.McpToolFilter> syncClientsToolFilter, org.springframework.beans.factory.ObjectProvider<List<io.modelcontextprotocol.client.McpSyncClient>> syncMcpClients, org.springframework.beans.factory.ObjectProvider<org.springframework.ai.mcp.McpToolNamePrefixGenerator> mcpToolNamePrefixGenerator, org.springframework.beans.factory.ObjectProvider<org.springframework.ai.mcp.ToolContextToMcpMetaConverter> toolContextToMcpMetaConverter)
      Creates tool callbacks for all configured MCP clients.

      These callbacks enable integration with Spring AI's tool execution framework, allowing MCP tools to be used as part of AI interactions.

      Parameters:
      syncClientsToolFilter - list of McpToolFilters for the sync client to filter the discovered tools
      syncMcpClients - provider of MCP sync clients
      mcpToolNamePrefixGenerator - the tool name prefix generator
      Returns:
      list of tool callbacks for MCP integration
    • mcpAsyncToolCallbacks

      @Bean @ConditionalOnProperty(prefix="spring.ai.mcp.client", name="type", havingValue="ASYNC") public org.springframework.ai.mcp.AsyncMcpToolCallbackProvider mcpAsyncToolCallbacks(org.springframework.beans.factory.ObjectProvider<org.springframework.ai.mcp.McpToolFilter> asyncClientsToolFilter, org.springframework.beans.factory.ObjectProvider<List<io.modelcontextprotocol.client.McpAsyncClient>> mcpClientsProvider, org.springframework.beans.factory.ObjectProvider<org.springframework.ai.mcp.McpToolNamePrefixGenerator> toolNamePrefixGenerator, org.springframework.beans.factory.ObjectProvider<org.springframework.ai.mcp.ToolContextToMcpMetaConverter> toolContextToMcpMetaConverter)