Skip to content

Commit ecbbfc5

Browse files
committed
add test for number of tools returned
1 parent 80bb07c commit ecbbfc5

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

test/servers/mcp-server.spec.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,52 @@ describe("MCP Server", () => {
179179
expect(liveboardTool?.description).toBe("Create a liveboard from a list of answers");
180180
});
181181

182+
it("should return 4 tools when enableSpotterDataSourceDiscovery is false", async () => {
183+
// Mock getThoughtSpotClient with enableSpotterDataSourceDiscovery set to false
184+
vi.spyOn(thoughtspotClient, "getThoughtSpotClient").mockReturnValue({
185+
getSessionInfo: vi.fn().mockResolvedValue({
186+
clusterId: "test-cluster-123",
187+
clusterName: "test-cluster",
188+
releaseVersion: "10.13.0.cl-110",
189+
userGUID: "test-user-123",
190+
configInfo: {
191+
mixpanelConfig: {
192+
devSdkKey: "test-dev-token",
193+
prodSdkKey: "test-prod-token",
194+
production: false,
195+
},
196+
selfClusterName: "test-cluster",
197+
selfClusterId: "test-cluster-123",
198+
},
199+
userName: "test-user",
200+
currentOrgId: "test-org",
201+
privileges: [],
202+
enableSpotterDataSourceDiscovery: false,
203+
}),
204+
searchMetadata: vi.fn().mockResolvedValue([]),
205+
instanceUrl: "https://test.thoughtspot.cloud",
206+
} as any);
207+
208+
// Create a new server instance to pick up the new mock
209+
const testServer = new MCPServer({ props: mockProps });
210+
await testServer.init();
211+
const { listTools } = connect(testServer);
212+
213+
const result = await listTools();
214+
215+
expect(result.tools).toHaveLength(4);
216+
expect(result.tools?.map(t => t.name)).toEqual([
217+
"ping",
218+
"getRelevantQuestions",
219+
"getAnswer",
220+
"createLiveboard"
221+
]);
222+
223+
// Verify that getDataSourceSuggestions is not included
224+
const dataSourceTool = result.tools?.find(t => t.name === "getDataSourceSuggestions");
225+
expect(dataSourceTool).toBeUndefined();
226+
});
227+
182228
});
183229

184230
describe("Ping Tool", () => {

0 commit comments

Comments
 (0)