on main help sign in
fix(mcp): add type assertion guards (#1239)

Signed-off-by: Evan Wies <evan@neomantra.net>

commit23e0fd441709aa040dda95d00de19ff2770ab037 authorEvan <evan@neomantra.net> dateWed 15 Oct 2025, 15:58 (1 year ago) parent1a40fba
1 file changed+20−3
internal/llm/agent/mcp-tools.go+20−3
internal/llm/agent/mcp-tools.go+20−3
@@ -98,9 +98,26 @@ func (b *McpTool) Name() string {
9898}
9999
100100func (b *McpTool) Info() tools.ToolInfo {
101− input := b.tool.InputSchema.(map[string]any)
102− required, _ := input["required"].([]string)
103− parameters, _ := input["properties"].(map[string]any)
101+ var parameters map[string]any
102+ var required []string
103+
104+ if input, ok := b.tool.InputSchema.(map[string]any); ok {
105+ if props, ok := input["properties"].(map[string]any); ok {
106+ parameters = props
107+ }
108+ if req, ok := input["required"].([]any); ok {
109+ // Convert []any -> []string when elements are strings
110+ for _, v := range req {
111+ if s, ok := v.(string); ok {
112+ required = append(required, s)
113+ }
114+ }
115+ } else if reqStr, ok := input["required"].([]string); ok {
116+ // Handle case where it's already []string
117+ required = reqStr
118+ }
119+ }
120+
104121 return tools.ToolInfo{
105122 Name: fmt.Sprintf("mcp_%s_%s", b.mcpName, b.tool.Name),
106123 Description: b.tool.Description,