-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
Currently Spring AI adds a prefix to resource names (spring_ai_<CLIENT_ID>) in order to prevent tool-name collision for tools coming from different MCP servers
Expected Behavior
(A) Provide an option to customize tool name processing in McpToolsUtils#prefixedToolName:
- Prefixing of resource names
- Max length cutting: currently is 64 INCLUSIVE prefix
- [optionally] pattern for replacing special chars ([^a-zA-Z0-9_-])
(B) [optional]
By receiving tool to execute from LLM, check it's name again for length and pattern and if it doesn't match:
- display warning
- cut the name accordingly rules in McpToolsUtils#prefixedToolName
Current Behavior
Currently the prefixing and processing is not customizable
Context
I have interesting effect with some LLMs: Spring AI agent sends about 60 tools to LLM, with prefix like:
spring_ai_mcp_client_server1_<ORIG_TOOL_NAME>.
The most of names are not cut, but some of them are, because of exceed 64 chars limits:
_ai_mcp_client_server1_<ORIG_TOOL_NAME>
After that, some LLMs thinking, that it is mistake to name tool like _ai_mcp_client_server1_<ORIG_TOOL_NAME> and correct them to full name: spring_ai_mcp_client_server1_<ORIG_TOOL_NAME>.
As a result, Spring AI receives full tool name instead cut one and cannot find it in own callback definitions (because there are cut variant is saved: _ai_mcp_client_server1_<ORIG_TOOL_NAME> ).
It causes exception:
No ToolCallback found for tool name: spring_ai_mcp_client_server1_<ORIG_TOOL_NAME>
I am going to provide patch for (A), (B)