MCPcopy Create free account
hub / github.com/diillson/chatcli / RunBuiltinTool

Method RunBuiltinTool

cli/rpc_support.go:188–212  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

186// with a raw argument string, returning its output. Only tools in
187// rpcExposedTools are allowed.
188func (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.
215func execBuiltin(ctx context.Context, p plugins.Plugin, argv []string) (string, error) {

Callers 3

CallBuiltinMethod · 0.80

Calls 3

execBuiltinFunction · 0.85
ErrorfMethod · 0.80
GetPluginMethod · 0.80

Tested by 2