Skip to content

Commit 1a5b162

Browse files
committed
add tests
1 parent 9085fcf commit 1a5b162

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/actor/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export function createExpressApp(
130130
// New initialization request - use JSON response mode
131131
transport = new StreamableHTTPServerTransport({
132132
sessionIdGenerator: () => randomUUID(),
133-
enableJsonResponse: true, // Enable JSON response mode
133+
enableJsonResponse: false, // Use SSE response mode
134134
});
135135
// Load MCP server tools
136136
await loadToolsAndActors(mcpServer, req.url, process.env.APIFY_TOKEN as string);

tests/integration/suite.ts

Lines changed: 20 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';
@@ -329,5 +330,24 @@ export function createIntegrationTestsSuite(
329330
expect(notificationCount).toBe(1);
330331
await client.close();
331332
});
333+
334+
it('should notify client about tool list changed', async () => {
335+
const client = await createClientFn({ enableAddingActors: true });
336+
337+
// This flag is set to true when a 'notifications/tools/list_changed' notification is received,
338+
// indicating that the tool list has been updated dynamically.
339+
let hasReceivedNotification = false;
340+
client.setNotificationHandler(ToolListChangedNotificationSchema, async (notification) => {
341+
if (notification.method === 'notifications/tools/list_changed') {
342+
hasReceivedNotification = true;
343+
}
344+
});
345+
// Add Actor dynamically
346+
await client.callTool({ name: HelperTools.ACTOR_ADD, arguments: { actorName: ACTOR_PYTHON_EXAMPLE } });
347+
348+
expect(hasReceivedNotification).toBe(true);
349+
350+
await client.close();
351+
});
332352
});
333353
}

0 commit comments

Comments
 (0)