MCPcopy Create free account
hub / github.com/coder/coder / TestConnectAll_DiscoverTools

Function TestConnectAll_DiscoverTools

coderd/x/chatd/mcpclient/mcpclient_test.go:91–114  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

89}
90
91func TestConnectAll_DiscoverTools(t *testing.T) {
92 t.Parallel()
93 ctx := context.Background()
94 logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true})
95
96 ts := newTestMCPServer(t, echoTool(), greetTool())
97
98 cfg := makeConfig("myserver", ts.URL)
99 tools, cleanup := mcpclient.ConnectAll(ctx, logger, []database.MCPServerConfig{cfg}, nil, uuid.Nil, nil, nil)
100 t.Cleanup(cleanup)
101
102 // Two tools should be discovered, namespaced with the server slug.
103 require.Len(t, tools, 2)
104
105 names := toolNames(tools)
106 assert.Contains(t, names, "myserver__echo")
107 assert.Contains(t, names, "myserver__greet")
108
109 // Verify the description is preserved.
110 foundEcho := findTool(tools, "myserver__echo")
111 require.NotNilf(t, foundEcho, "expected to find myserver__echo")
112 echoInfo := foundEcho.Info()
113 assert.Equal(t, "Echoes the input", echoInfo.Description)
114}
115
116func TestConnectAll_CallTool(t *testing.T) {
117 t.Parallel()

Callers

nothing calls this directly

Calls 12

ConnectAllFunction · 0.92
newTestMCPServerFunction · 0.85
echoToolFunction · 0.85
greetToolFunction · 0.85
makeConfigFunction · 0.85
toolNamesFunction · 0.85
findToolFunction · 0.85
CleanupMethod · 0.65
LenMethod · 0.45
ContainsMethod · 0.45
InfoMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected