TestConnectAll_MCPToolIdentifier verifies that tools returned by ConnectAll implement the MCPToolIdentifier interface and report the correct server config ID.
(t *testing.T)
| 962 | // by ConnectAll implement the MCPToolIdentifier interface and |
| 963 | // report the correct server config ID. |
| 964 | func 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. |
nothing calls this directly
no test coverage detected