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

Function TestConnectAll_CallTool

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

Source from the content-addressed store, hash-verified

114}
115
116func TestConnectAll_CallTool(t *testing.T) {
117 t.Parallel()
118 ctx := context.Background()
119 logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true})
120
121 ts := newTestMCPServer(t, echoTool())
122
123 cfg := makeConfig("srv", ts.URL)
124 tools, cleanup := mcpclient.ConnectAll(ctx, logger, []database.MCPServerConfig{cfg}, nil, uuid.Nil, nil, nil)
125 t.Cleanup(cleanup)
126 require.Len(t, tools, 1)
127
128 tool := tools[0]
129 resp, err := tool.Run(ctx, fantasy.ToolCall{
130 ID: "call-1",
131 Name: "srv__echo",
132 Input: `{"input":"hello world"}`,
133 })
134 require.NoError(t, err)
135 assert.False(t, resp.IsError)
136 assert.Equal(t, "echo: hello world", resp.Content)
137}
138
139func TestConnectAll_ToolAllowList(t *testing.T) {
140 t.Parallel()

Callers

nothing calls this directly

Calls 8

ConnectAllFunction · 0.92
newTestMCPServerFunction · 0.85
echoToolFunction · 0.85
makeConfigFunction · 0.85
CleanupMethod · 0.65
RunMethod · 0.65
LenMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected