Package org.springframework.ai.mcp
Class DefaultMcpToolNamePrefixGenerator
java.lang.Object
org.springframework.ai.mcp.DefaultMcpToolNamePrefixGenerator
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprefixedToolName
(McpConnectionInfo mcpConnectionInfo, io.modelcontextprotocol.spec.McpSchema.Tool tool)
-
Constructor Details
-
DefaultMcpToolNamePrefixGenerator
public DefaultMcpToolNamePrefixGenerator()
-
-
Method Details
-
prefixedToolName
public String prefixedToolName(McpConnectionInfo mcpConnectionInfo, io.modelcontextprotocol.spec.McpSchema.Tool tool) - Specified by:
prefixedToolName
in interfaceMcpToolNamePrefixGenerator
-