-
Notifications
You must be signed in to change notification settings - Fork 70
Open
Description
I am using Spring AI MCP in combination with MCP Link to connect to GitHub. However, the tool names generated by MCP Link are quite long. Spring AI MCP truncates these tool names, which causes some tools to have the same name.
For example:
mcplink_github_v3_rest_api_get_repos_owner_repo_environments_environment_name_secrets_secret_name
mcplink_github_v3_rest_api_delete_repos_owner_repo_environments_environment_name_secrets_secret_name
After truncation, both become:
pos_owner_repo_environments_environment_name_secrets_secret_name
This results in a naming conflict.
public static String prefixedToolName(String prefix, String toolName) {
if (StringUtils.isEmpty(prefix) || StringUtils.isEmpty(toolName)) {
throw new IllegalArgumentException("Prefix or toolName cannot be null or empty");
}
String input = prefix + "_" + toolName;
// Replace any character that isn't alphanumeric, underscore, or hyphen with
// concatenation
String formatted = input.replaceAll("[^a-zA-Z0-9_-]", "");
formatted = formatted.replaceAll("-", "_");
// If the string is longer than 64 characters, keep the last 64 characters
if (formatted.length() > 64) {
formatted = formatted.substring(formatted.length() - 64);
}
return formatted;
}](https://github.com/spring-projects/spring-ai/blob/2294c5a807db3b927d215545354f3525c9fd0388/mcp/common/src/main/java/org/springframework/ai/mcp/McpToolUtils.java#L64C1-L84C3)](https://github.com/spring-projects/spring-ai/blob/3f7f2f1bffade3d6029dc6bca9631033533273d8/mcp/common/src/main/java/org/springframework/ai/mcp/McpToolUtils.java#L62)
Metadata
Metadata
Assignees
Labels
No labels