@@ -996,7 +996,10 @@ public static Tool createTool(Map<String, Tool.Factory> toolFactories, Map<Strin
996996 throw new IllegalArgumentException ("Tool not found: " + toolSpec .getType ());
997997 }
998998 Map <String , Object > toolParams = new HashMap <>();
999- toolParams .putAll (executeParams );
999+ // Parse JSON strings back to original type since we need to validate each parameter type when creating tool
1000+ for (Map .Entry <String , String > entry : executeParams .entrySet ()) {
1001+ toolParams .put (entry .getKey (), parseValue (entry .getValue ()));
1002+ }
10001003 Map <String , Object > runtimeResources = toolSpec .getRuntimeResources ();
10011004 if (runtimeResources != null ) {
10021005 toolParams .putAll (runtimeResources );
@@ -1014,4 +1017,32 @@ public static Tool createTool(Map<String, Tool.Factory> toolFactories, Map<Strin
10141017
10151018 return tool ;
10161019 }
1020+
1021+ private static Object parseValue (String value ) {
1022+ if (value == null || "null" .equals (value )) {
1023+ return null ;
1024+ }
1025+ String v = value .trim ();
1026+
1027+ // Try JSON array
1028+ if (v .startsWith ("[" ) && v .endsWith ("]" )) {
1029+ try {
1030+ return gson .fromJson (v , List .class );
1031+ } catch (Exception e ) {
1032+ return value ;
1033+ }
1034+ }
1035+
1036+ // Try boolean
1037+ if ("true" .equalsIgnoreCase (v ) || "false" .equalsIgnoreCase (v )) {
1038+ return Boolean .parseBoolean (v );
1039+ }
1040+
1041+ // Try integer
1042+ try {
1043+ return Integer .parseInt (v );
1044+ } catch (NumberFormatException e ) {
1045+ return value ;
1046+ }
1047+ }
10171048}
0 commit comments