|
77 | 77 | Arguments map[string]interface{} `json:"arguments"`
|
78 | 78 | }
|
79 | 79 |
|
80 |
| - // Define structure to match the response format |
| 80 | + // Content matches the response format of a text content response |
81 | 81 | Content struct {
|
82 | 82 | Type string `json:"type"`
|
83 | 83 | Text string `json:"text"`
|
@@ -284,10 +284,10 @@ func addCommandFromTool(toolsCmd *cobra.Command, tool *Tool, prettyPrint bool) {
|
284 | 284 | cmd.Flags().Bool(name, false, description)
|
285 | 285 | case "array":
|
286 | 286 | if prop.Items != nil {
|
287 |
| - if prop.Items.Type == "string" { |
| 287 | + switch prop.Items.Type { |
| 288 | + case "string": |
288 | 289 | cmd.Flags().StringSlice(name, []string{}, description)
|
289 |
| - } else if prop.Items.Type == "object" { |
290 |
| - // For complex objects in arrays, we'll use a JSON string that users can provide |
| 290 | + case "object": |
291 | 291 | cmd.Flags().String(name+"-json", "", description+" (provide as JSON array)")
|
292 | 292 | }
|
293 | 293 | }
|
@@ -327,11 +327,12 @@ func buildArgumentsMap(cmd *cobra.Command, tool *Tool) (map[string]interface{},
|
327 | 327 | }
|
328 | 328 | case "array":
|
329 | 329 | if prop.Items != nil {
|
330 |
| - if prop.Items.Type == "string" { |
| 330 | + switch prop.Items.Type { |
| 331 | + case "string": |
331 | 332 | if values, _ := cmd.Flags().GetStringSlice(name); len(values) > 0 {
|
332 | 333 | arguments[name] = values
|
333 | 334 | }
|
334 |
| - } else if prop.Items.Type == "object" { |
| 335 | + case "object": |
335 | 336 | if jsonStr, _ := cmd.Flags().GetString(name + "-json"); jsonStr != "" {
|
336 | 337 | var jsonArray []interface{}
|
337 | 338 | if err := json.Unmarshal([]byte(jsonStr), &jsonArray); err != nil {
|
|
0 commit comments