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

Function TestConnectAll_MCPToolIdentifier

coderd/x/chatd/mcpclient/mcpclient_test.go:964–991  ·  view source on GitHub ↗

TestConnectAll_MCPToolIdentifier verifies that tools returned by ConnectAll implement the MCPToolIdentifier interface and report the correct server config ID.

(t *testing.T)

Source from the content-addressed store, hash-verified

962// by ConnectAll implement the MCPToolIdentifier interface and
963// report the correct server config ID.
964func TestConnectAll_MCPToolIdentifier(t *testing.T) {
965 t.Parallel()
966 ctx := context.Background()
967 logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true})
968
969 ts := newTestMCPServer(t, echoTool())
970
971 configID := uuid.New()
972 cfg := database.MCPServerConfig{
973 ID: configID,
974 Slug: "id-srv",
975 DisplayName: "ID Server",
976 Url: ts.URL,
977 Transport: "streamable_http",
978 AuthType: "none",
979 Enabled: true,
980 }
981
982 tools, cleanup := mcpclient.ConnectAll(ctx, logger, []database.MCPServerConfig{cfg}, nil, uuid.Nil, nil, nil)
983 t.Cleanup(cleanup)
984
985 require.Len(t, tools, 1)
986
987 // Assert the tool implements MCPToolIdentifier.
988 identifier, ok := tools[0].(mcpclient.MCPToolIdentifier)
989 require.True(t, ok, "tool should implement MCPToolIdentifier")
990 assert.Equal(t, configID, identifier.MCPServerConfigID())
991}
992
993// TestConnectAll_MCPToolIdentifier_MultipleServers verifies that
994// each tool from a different MCP server carries its own config ID.

Callers

nothing calls this directly

Calls 8

ConnectAllFunction · 0.92
newTestMCPServerFunction · 0.85
echoToolFunction · 0.85
NewMethod · 0.65
CleanupMethod · 0.65
MCPServerConfigIDMethod · 0.65
LenMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected