(mcpSection any, toolName string)
| 456 | } |
| 457 | |
| 458 | func parseMCPSectionMap(mcpSection any, toolName string) (map[string]any, error) { |
| 459 | switch v := mcpSection.(type) { |
| 460 | case map[string]any: |
| 461 | return v, nil |
| 462 | case string: |
| 463 | var mcpConfig map[string]any |
| 464 | if err := json.Unmarshal([]byte(v), &mcpConfig); err != nil { |
| 465 | return nil, fmt.Errorf("invalid JSON in mcp configuration: %w", err) |
| 466 | } |
| 467 | return mcpConfig, nil |
| 468 | default: |
| 469 | return nil, fmt.Errorf("mcp configuration must be a map or JSON string, got %T. Example:\nmcp-servers:\n %s:\n command: \"npx @my/tool\"\n args: [\"--port\", \"3000\"]", v, toolName) |
| 470 | } |
| 471 | } |
| 472 | |
| 473 | func inferOrReadMCPType(mcpConfig map[string]any, toolName string) (string, error) { |
| 474 | if typeVal, hasType := mcpConfig["type"]; hasType { |
no test coverage detected