File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
mcp/common/src/main/java/org/springframework/ai/mcp Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change 1717
1818import java .util .List ;
1919
20+ import io .micrometer .common .util .StringUtils ;
2021import io .modelcontextprotocol .client .McpAsyncClient ;
2122import io .modelcontextprotocol .client .McpSyncClient ;
2223import io .modelcontextprotocol .server .McpServerFeatures ;
@@ -58,12 +59,12 @@ private McpToolUtils() {
5859
5960 public static String prefixedToolName (String prefix , String toolName ) {
6061
61- String input = prefix + "-" + toolName ;
62-
63- if (input == null || input .isEmpty ()) {
64- throw new IllegalArgumentException ("Input string cannot be null or empty" );
62+ if (StringUtils .isEmpty (prefix ) || StringUtils .isEmpty (toolName )) {
63+ throw new IllegalArgumentException ("Prefix or toolName cannot be null or empty" );
6564 }
6665
66+ String input = prefix + "-" + toolName ;
67+
6768 // Replace any character that isn't alphanumeric, underscore, or hyphen with
6869 // concatenation
6970 String formatted = input .replaceAll ("[^a-zA-Z0-9_-]" , "" );
You can’t perform that action at this time.
0 commit comments