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

Function TestBuiltinTools_WithManager

cli/rpc_support_test.go:61–89  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

59}
60
61func TestBuiltinTools_WithManager(t *testing.T) {
62 mgr, err := plugins.NewManager(zap.NewNop())
63 if err != nil {
64 t.Fatal(err)
65 }
66 mgr.RegisterBuiltinPlugin(plugins.NewBuiltinReadPlugin())
67 c := &ChatCLI{pluginManager: mgr}
68
69 found := false
70 for _, tl := range c.ListBuiltinTools() {
71 if tl.Name == "read" {
72 found = true
73 }
74 }
75 if !found {
76 t.Error("expected the read tool to be listed")
77 }
78
79 // Not in the exposed allowlist.
80 if _, err := c.RunBuiltinTool(context.Background(), "coder", "x"); err == nil {
81 t.Error("coder must not be exposed over MCP")
82 }
83 // Allowed but not registered in this manager.
84 if _, err := c.RunBuiltinTool(context.Background(), "search", "x"); err == nil {
85 t.Error("search is not registered -> should error")
86 }
87 // Allowed + registered: executes (bad path errors, but the code path runs).
88 _, _ = c.RunBuiltinTool(context.Background(), "read", `{"path":"/nonexistent-xyz"}`)
89}

Callers

nothing calls this directly

Calls 6

RegisterBuiltinPluginMethod · 0.95
ListBuiltinToolsMethod · 0.95
RunBuiltinToolMethod · 0.95
NewManagerFunction · 0.92
NewBuiltinReadPluginFunction · 0.92
ErrorMethod · 0.65

Tested by

no test coverage detected