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 17
17
18
18
import java .util .List ;
19
19
20
+ import io .micrometer .common .util .StringUtils ;
20
21
import io .modelcontextprotocol .client .McpAsyncClient ;
21
22
import io .modelcontextprotocol .client .McpSyncClient ;
22
23
import io .modelcontextprotocol .server .McpServerFeatures ;
@@ -58,12 +59,12 @@ private McpToolUtils() {
58
59
59
60
public static String prefixedToolName (String prefix , String toolName ) {
60
61
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" );
65
64
}
66
65
66
+ String input = prefix + "-" + toolName ;
67
+
67
68
// Replace any character that isn't alphanumeric, underscore, or hyphen with
68
69
// concatenation
69
70
String formatted = input .replaceAll ("[^a-zA-Z0-9_-]" , "" );
You can’t perform that action at this time.
0 commit comments