Class DefaultMcpToolNamePrefixGenerator

java.lang.Object
org.springframework.ai.mcp.DefaultMcpToolNamePrefixGenerator
All Implemented Interfaces:
McpToolNamePrefixGenerator

public class DefaultMcpToolNamePrefixGenerator extends Object implements McpToolNamePrefixGenerator
Default implementation of McpToolNamePrefixGenerator that ensures unique tool names for all client/server connections.

This implementation ensures that tool names are unique across different MCP clients and servers by tracking existing connections and appending a counter to duplicate tool names.

For each unique combination of (client, server, tool), e.g. each connection, the tool name is generated only once. If a tool name has already been used, a prefix with a counter is added to make it unique (e.g., "alt_1_toolName", "alt_2_toolName", etc.).

This implementation is thread-safe.

Author:
Christian Tzolov
  • Constructor Details

    • DefaultMcpToolNamePrefixGenerator

      public DefaultMcpToolNamePrefixGenerator()
  • Method Details