@@ -493,5 +493,58 @@ export function createIntegrationTestsSuite(
493493 await ( client . transport as StreamableHTTPClientTransport ) . terminateSession ( ) ;
494494 await client . close ( ) ;
495495 } ) ;
496+
497+ // Environment variable tests - only applicable to stdio transport
498+ it . runIf ( options . transport === 'stdio' ) ( 'should load actors from ACTORS environment variable' , async ( ) => {
499+ const actors = [ 'apify/python-example' , 'apify/rag-web-browser' ] ;
500+ const client = await createClientFn ( { actors, useEnv : true } ) ;
501+ const names = getToolNames ( await client . listTools ( ) ) ;
502+ expect ( names . length ) . toEqual ( defaultTools . length + actors . length + addRemoveTools . length ) ;
503+ expectToolNamesToContain ( names , DEFAULT_TOOL_NAMES ) ;
504+ expectToolNamesToContain ( names , actors . map ( ( actor ) => actorNameToToolName ( actor ) ) ) ;
505+ expectToolNamesToContain ( names , addRemoveTools . map ( ( tool ) => tool . tool . name ) ) ;
506+
507+ await client . close ( ) ;
508+ } ) ;
509+
510+ it . runIf ( options . transport === 'stdio' ) ( 'should respect ENABLE_ADDING_ACTORS environment variable' , async ( ) => {
511+ // Test with enableAddingActors = false via env var
512+ const client = await createClientFn ( { enableAddingActors : false , useEnv : true } ) ;
513+ const names = getToolNames ( await client . listTools ( ) ) ;
514+ expect ( names . length ) . toEqual ( defaultTools . length + defaults . actors . length ) ;
515+
516+ expectToolNamesToContain ( names , DEFAULT_TOOL_NAMES ) ;
517+ expectToolNamesToContain ( names , DEFAULT_ACTOR_NAMES ) ;
518+ await client . close ( ) ;
519+ } ) ;
520+
521+ it . runIf ( options . transport === 'stdio' ) ( 'should load tool categories from TOOLS environment variable' , async ( ) => {
522+ const categories = [ 'docs' , 'runs' ] as ToolCategory [ ] ;
523+ const client = await createClientFn ( { tools : categories , useEnv : true } ) ;
524+
525+ const loadedTools = await client . listTools ( ) ;
526+ const toolNames = getToolNames ( loadedTools ) ;
527+
528+ const expectedTools = [
529+ ...toolCategories . docs ,
530+ ...toolCategories . runs ,
531+ ] ;
532+ const expectedToolNames = expectedTools . map ( ( tool ) => tool . tool . name ) ;
533+
534+ // Handle case where tools are enabled by default
535+ const selectedCategoriesInDefault = categories . filter ( ( key ) => toolCategoriesEnabledByDefault . includes ( key ) ) ;
536+ const numberOfToolsFromCategoriesInDefault = selectedCategoriesInDefault
537+ . flatMap ( ( key ) => toolCategories [ key ] ) . length ;
538+
539+ const numberOfToolsExpected = defaultTools . length + defaults . actors . length + addRemoveTools . length
540+ // Tools from tool categories minus the ones already in default tools
541+ + ( expectedTools . length - numberOfToolsFromCategoriesInDefault ) ;
542+ expect ( toolNames . length ) . toEqual ( numberOfToolsExpected ) ;
543+ for ( const expectedToolName of expectedToolNames ) {
544+ expect ( toolNames ) . toContain ( expectedToolName ) ;
545+ }
546+
547+ await client . close ( ) ;
548+ } ) ;
496549 } ) ;
497550}
0 commit comments