RunBuiltinTool invokes a curated built-in tool by name (without the '@') with a raw argument string, returning its output. Only tools in rpcExposedTools are allowed.
(ctx context.Context, name, args string)
| 186 | // with a raw argument string, returning its output. Only tools in |
| 187 | // rpcExposedTools are allowed. |
| 188 | func (cli *ChatCLI) RunBuiltinTool(ctx context.Context, name, args string) (string, error) { |
| 189 | if cli.pluginManager == nil { |
| 190 | return "", fmt.Errorf("plugins not available") |
| 191 | } |
| 192 | full := "@" + strings.TrimPrefix(name, "@") |
| 193 | allowed := false |
| 194 | for _, t := range rpcExposedTools { |
| 195 | if t == full { |
| 196 | allowed = true |
| 197 | break |
| 198 | } |
| 199 | } |
| 200 | if !allowed { |
| 201 | return "", fmt.Errorf("tool %q is not exposed over MCP", name) |
| 202 | } |
| 203 | p, ok := cli.pluginManager.GetPlugin(full) |
| 204 | if !ok { |
| 205 | return "", fmt.Errorf("tool %q not found", name) |
| 206 | } |
| 207 | var argv []string |
| 208 | if strings.TrimSpace(args) != "" { |
| 209 | argv = []string{args} |
| 210 | } |
| 211 | return execBuiltin(ctx, p, argv) |
| 212 | } |
| 213 | |
| 214 | // execBuiltin runs a plugin, capturing any streamed output into the result. |
| 215 | func execBuiltin(ctx context.Context, p plugins.Plugin, argv []string) (string, error) { |