11import type { Client } from '@modelcontextprotocol/sdk/client/index.js' ;
2+ import { ToolListChangedNotificationSchema } from '@modelcontextprotocol/sdk/types.js' ;
23import { afterAll , afterEach , beforeAll , beforeEach , describe , expect , it } from 'vitest' ;
34
45import { defaults , HelperTools } from '../../src/const.js' ;
@@ -10,6 +11,7 @@ import { addActor, expectArrayWeakEquals, type McpClientOptions } from '../helpe
1011interface 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