Skip to content

Conversation

@tzolov
Copy link
Contributor

@tzolov tzolov commented Sep 11, 2025

  • Introduce DefaultMcpToolNamePrefixGenerator to ensure unique tool names across MCP connections
  • Replace default prefix generation strategy from client/title-based to duplicate detection
  • Automatically add counter prefixes (dp_1_, dp_2_) when duplicate tool names are detected
  • Track existing connections and tool names to maintain idempotency
  • Update tests to reflect new duplicate handling behavior (keep existing tool on duplicate)
  • Update documentation to describe the new default generator behavior
  • Change default from McpToolNamePrefixGenerator.defaultGenerator() to new DefaultMcpToolNamePrefixGenerator

BREAKING CHANGE: The default tool name generation strategy has changed. Tools now use their original names by default, with automatic prefixing only when duplicates are detected across different connections.

…icate handling

- Introduce DefaultMcpToolNamePrefixGenerator to ensure unique tool names across MCP connections
- Replace default prefix generation strategy from client/title-based to duplicate detection
- Automatically add counter prefixes (dp_1_, dp_2_) when duplicate tool names are detected
- Track existing connections and tool names to maintain idempotency
- Update tests to reflect new duplicate handling behavior (keep existing tool on duplicate)
- Update documentation to describe the new default generator behavior
- Change default from McpToolNamePrefixGenerator.defaultGenerator() to new DefaultMcpToolNamePrefixGenerator

BREAKING CHANGE: The default tool name generation strategy has changed. Tools now use their original
names by default, with automatic prefixing only when duplicates are detected across different connections.

Signed-off-by: Christian Tzolov <[email protected]>
return (mcpConnectionIfo, tool) -> McpToolUtils.prefixedToolName(mcpConnectionIfo.clientInfo().name(),
mcpConnectionIfo.clientInfo().title(), tool.name());
}
// static McpToolNamePrefixGenerator defaultGenerator() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will remove when merging.

.add(new ConnectionId(mcpConnectionInfo.clientInfo(), (mcpConnectionInfo.initializeResult() != null)
? mcpConnectionInfo.initializeResult().serverInfo() : null, tool))) {
if (!this.allUsedToolNames.add(uniqueToolName)) {
uniqueToolName = "dp_" + this.counter.getAndIncrement() + "_" + uniqueToolName;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While one can provide a custom prefix generator, It would be good if we can make the prefix "dp_" customisable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps "sa" to denote "Spring AI" as a prefix here instead of "dp_"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After discussion, changing this to use "alt_" when merging.

@ilayaperumalg
Copy link
Member

Rebased, updated the prefix for the duplicate tool name to use "alt_", merged as 31db86d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants