Skip to content

Commit 4237dfe

Browse files
fix McpToolUtils.prefixedToolName formatted in order to support Chinese characters in toolName
1 parent 7e8482e commit 4237dfe

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

mcp/common/src/main/java/org/springframework/ai/mcp/McpToolUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ public static String prefixedToolName(String prefix, String toolName) {
7979

8080
String input = prefix + "_" + toolName;
8181

82-
// Replace any character that isn't alphanumeric, underscore, or hyphen with
83-
// concatenation
84-
String formatted = input.replaceAll("[^a-zA-Z0-9_-]", "");
82+
// Replace any character that isn't alphanumeric, underscore, hyphen, or Chinese
83+
// characters with empty string
84+
String formatted = input.replaceAll("[^a-zA-Z0-9_\u4e00-\u9fa5]", "");
8585

8686
formatted = formatted.replaceAll("-", "_");
8787

0 commit comments

Comments
 (0)