on main help sign in
fix(mcp): add type assertion guards (#1239)
23e0fd4Evan
internal/llm/agent/mcp-tools.go+20−3
@@ -98,9 +98,26 @@ func (b *McpTool) Name() string {
98}
98}
99
99
100func (b *McpTool) Info() tools.ToolInfo {
100func (b *McpTool) Info() tools.ToolInfo {
101+ var parameters map[string]any
102+ var required []string
103+
101− input := b.tool.InputSchema.(map[string]any)
104+ if input, ok := b.tool.InputSchema.(map[string]any); ok {
102− required, _ := input["required"].([]string)
103− parameters, _ := input["properties"].(map[string]any)
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+
104 return tools.ToolInfo{
121 return tools.ToolInfo{
105 Name: fmt.Sprintf("mcp_%s_%s", b.mcpName, b.tool.Name),
122 Name: fmt.Sprintf("mcp_%s_%s", b.mcpName, b.tool.Name),
106 Description: b.tool.Description,
123 Description: b.tool.Description,