Skip to content

Commit 709c3fe

Browse files
committed
add tests
1 parent 9085fcf commit 709c3fe

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

tests/integration/actor.server-sse.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const mcpUrl = `${httpServerHost}/sse`;
1818

1919
createIntegrationTestsSuite({
2020
suiteName: 'Actors MCP Server SSE',
21+
serverType: 'sse',
2122
getActorsMcpServer: () => mcpServer,
2223
createClientFn: async (options) => await createMcpSseClient(mcpUrl, options),
2324
beforeAllFn: async () => {

tests/integration/actor.server-streamable.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const mcpUrl = `${httpServerHost}/mcp`;
1818

1919
createIntegrationTestsSuite({
2020
suiteName: 'Actors MCP Server Streamable HTTP',
21+
serverType: 'http-streamable',
2122
getActorsMcpServer: () => mcpServer,
2223
createClientFn: async (options) => await createMcpStreamableClient(mcpUrl, options),
2324
beforeAllFn: async () => {

tests/integration/stdio.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ import { createIntegrationTestsSuite } from './suite.js';
33

44
createIntegrationTestsSuite({
55
suiteName: 'MCP stdio',
6+
serverType: 'stdio',
67
createClientFn: createMcpStdioClient,
78
});

tests/integration/suite.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Client } from '@modelcontextprotocol/sdk/client/index.js';
2+
import { ToolListChangedNotificationSchema } from '@modelcontextprotocol/sdk/types.js';
23
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from 'vitest';
34

45
import { defaults, HelperTools } from '../../src/const.js';
@@ -10,6 +11,7 @@ import { addActor, expectArrayWeakEquals, type McpClientOptions } from '../helpe
1011
interface IntegrationTestsSuiteOptions {
1112
suiteName: string;
1213
getActorsMcpServer?: () => ActorsMcpServer;
14+
serverType: 'stdio' | 'sse' | 'http-streamable';
1315
createClientFn: (options?: McpClientOptions) => Promise<Client>;
1416
beforeAllFn?: () => Promise<void>;
1517
afterAllFn?: () => Promise<void>;
@@ -56,6 +58,7 @@ export function createIntegrationTestsSuite(
5658
) {
5759
const {
5860
suiteName,
61+
serverType,
5962
getActorsMcpServer,
6063
createClientFn,
6164
beforeAllFn,
@@ -329,5 +332,25 @@ export function createIntegrationTestsSuite(
329332
expect(notificationCount).toBe(1);
330333
await client.close();
331334
});
335+
336+
// Skip for streamable since in this case we do NOT support SSE inside streamable transport
337+
it.runIf(serverType !== 'http-streamable')('should notify client about tool list changed', async () => {
338+
const client = await createClientFn({ enableAddingActors: true });
339+
340+
// This flag is set to true when a 'notifications/tools/list_changed' notification is received,
341+
// indicating that the tool list has been updated dynamically.
342+
let hasReceivedNotification = false;
343+
client.setNotificationHandler(ToolListChangedNotificationSchema, async (notification) => {
344+
if (notification.method === 'notifications/tools/list_changed') {
345+
hasReceivedNotification = true;
346+
}
347+
});
348+
// Add Actor dynamically
349+
await client.callTool({ name: HelperTools.ACTOR_ADD, arguments: { actorName: ACTOR_PYTHON_EXAMPLE } });
350+
351+
expect(hasReceivedNotification).toBe(true);
352+
353+
await client.close();
354+
});
332355
});
333356
}

0 commit comments

Comments
 (0)