| 165 | } |
| 166 | |
| 167 | func (cli *ChatCLI) mcpShowTools(filter string) { |
| 168 | tools := cli.mcpManager.GetTools() |
| 169 | |
| 170 | fmt.Println() |
| 171 | fmt.Println(uiBox("🔧", i18n.T("mcp.cmd.box_tools_title"), ColorCyan)) |
| 172 | p := uiPrefix(ColorCyan) |
| 173 | |
| 174 | if filter != "" && !cli.mcpServerExists(filter) { |
| 175 | fmt.Println(p + colorize(i18n.T("mcp.cmd.unknown_server", filter), ColorRed)) |
| 176 | fmt.Println(uiBoxEnd(ColorCyan)) |
| 177 | return |
| 178 | } |
| 179 | |
| 180 | if len(tools) == 0 { |
| 181 | fmt.Println(p + colorize(i18n.T("mcp.cmd.no_tools"), ColorGray)) |
| 182 | fmt.Println(uiBoxEnd(ColorCyan)) |
| 183 | return |
| 184 | } |
| 185 | |
| 186 | wantPrefix := "" |
| 187 | if filter != "" { |
| 188 | wantPrefix = fmt.Sprintf("[MCP:%s]", filter) |
| 189 | } |
| 190 | |
| 191 | shown := 0 |
| 192 | for _, t := range tools { |
| 193 | if wantPrefix != "" && !strings.HasPrefix(t.Function.Description, wantPrefix) { |
| 194 | continue |
| 195 | } |
| 196 | shown++ |
| 197 | fmt.Println(p + fmt.Sprintf(" %s%s%s", ColorLime, t.Function.Name, ColorReset)) |
| 198 | fmt.Println(p + fmt.Sprintf(" %s%s%s", ColorGray, t.Function.Description, ColorReset)) |
| 199 | if t.Function.Parameters != nil { |
| 200 | if props, ok := t.Function.Parameters["properties"].(map[string]interface{}); ok { |
| 201 | for pname := range props { |
| 202 | fmt.Println(p + fmt.Sprintf(" %s·%s %s", ColorPurple, ColorReset, pname)) |
| 203 | } |
| 204 | } |
| 205 | } |
| 206 | fmt.Println(p) |
| 207 | } |
| 208 | if filter != "" && shown == 0 { |
| 209 | fmt.Println(p + colorize(i18n.T("mcp.cmd.no_tools_for_server", filter), ColorGray)) |
| 210 | } |
| 211 | fmt.Println(uiBoxEnd(ColorCyan)) |
| 212 | fmt.Println() |
| 213 | } |
| 214 | |
| 215 | func (cli *ChatCLI) mcpRestart(ctx context.Context, name string) { |
| 216 | if name != "" { |