@@ -22,9 +22,10 @@ import { hideBin } from 'yargs/helpers';
2222
2323import log from '@apify/log' ;
2424
25- import { defaults } from './const.js' ;
2625import { ActorsMcpServer } from './mcp/server.js' ;
27- import { getActorsAsTools } from './tools/index.js' ;
26+ import { toolCategories } from './tools/index.js' ;
27+ import type { Input , ToolCategory } from './types.js' ;
28+ import { loadToolsFromInput } from './utils/tools-loader.js' ;
2829
2930// Keeping this interface here and not types.ts since
3031// it is only relevant to the CLI/STDIO transport in this file
@@ -36,7 +37,8 @@ interface CliArgs {
3637 enableAddingActors: boolean ;
3738 /** @deprecated */
3839 enableActorAutoLoading: boolean ;
39- beta: boolean ;
40+ /** Tool categories to include */
41+ tools ? : string ;
4042}
4143
4244// Configure logging, set to ERROR
@@ -47,24 +49,35 @@ const argv = yargs(hideBin(process.argv))
4749 . usage ( 'Usage: $0 [options]' )
4850 . option ( 'actors' , {
4951 type : 'string' ,
50- describe : 'Comma-separated list of Actor full names to add to the server' ,
52+ describe : 'Comma-separated list of Actor full names to add to the server. ' ,
5153 example : 'apify/google-search-scraper,apify/instagram-scraper' ,
5254 } )
5355 . option ( 'enable-adding-actors' , {
5456 type : 'boolean' ,
5557 default : true ,
56- describe : 'Enable dynamically adding Actors as tools based on user requests' ,
58+ describe : 'Enable dynamically adding Actors as tools based on user requests. ' ,
5759 } )
5860 . option ( 'enableActorAutoLoading' , {
5961 type : 'boolean' ,
6062 default : true ,
6163 hidden : true ,
62- describe : 'Deprecated: use enable-adding-actors instead' ,
64+ describe : 'Deprecated: use enable-adding-actors instead. ' ,
6365 } )
64- . option ( 'beta' , {
65- type : 'boolean' ,
66- default : false ,
67- describe : 'Enable beta features' ,
66+ . options ( 'tools' , {
67+ type : 'string' ,
68+ describe : `Comma-separated list of specific tool categories to enable.
69+
70+ Available choices: ${ Object . keys ( toolCategories ) . join ( ', ' ) }
71+
72+ Tool categories are as follows:
73+ - docs: Search and fetch Apify documentation tools.
74+ - runs: Get Actor runs list, run details, and logs from a specific Actor run.
75+ - storage: Access datasets, key-value stores, and their records.
76+ - preview: Experimental tools in preview mode.
77+
78+ Note: Tools that enable you to search Actors from the Apify Store and get their details are always enabled by default.
79+ ` ,
80+ example : 'docs,runs,storage' ,
6881 } )
6982 . help ( 'help' )
7083 . alias ( 'h' , 'help' )
@@ -73,13 +86,14 @@ const argv = yargs(hideBin(process.argv))
7386 'To connect, set your MCP client server command to `npx @apify/actors-mcp-server`'
7487 + ' and set the environment variable `APIFY_TOKEN` to your Apify API token.\n' ,
7588 )
76- . epilogue ( 'For more information, visit https://github.com/apify/actors-mcp-server' )
89+ . epilogue ( 'For more information, visit https://mcp.apify.com or https:// github.com/apify/actors-mcp-server' )
7790 . parseSync ( ) as CliArgs ;
7891
7992const enableAddingActors = argv . enableAddingActors && argv . enableActorAutoLoading ;
8093const actors = argv . actors as string || '' ;
8194const actorList = actors ? actors . split ( ',' ) . map ( ( a : string ) => a . trim ( ) ) : [ ] ;
82- const enableBeta = argv . beta ;
95+ // Keys of the tool categories to enable
96+ const toolCategoryKeys = argv . tools ? argv . tools . split ( ',' ) . map ( ( t : string ) => t . trim ( ) ) : [ ] ;
8397
8498// Validate environment
8599if ( ! process . env . APIFY_TOKEN ) {
@@ -88,8 +102,18 @@ if (!process.env.APIFY_TOKEN) {
88102}
89103
90104async function main ( ) {
91- const mcpServer = new ActorsMcpServer ( { enableAddingActors, enableDefaultActors : false , enableBeta } ) ;
92- const tools = await getActorsAsTools ( actorList . length ? actorList : defaults . actors , process . env . APIFY_TOKEN as string ) ;
105+ const mcpServer = new ActorsMcpServer ( { enableAddingActors, enableDefaultActors : false } ) ;
106+
107+ // Create an Input object from CLI arguments
108+ const input : Input = {
109+ actors : actorList . length ? actorList : [ ] ,
110+ enableAddingActors,
111+ tools : toolCategoryKeys as ToolCategory [ ] ,
112+ } ;
113+
114+ // Use the shared tools loading logic
115+ const tools = await loadToolsFromInput ( input , process . env . APIFY_TOKEN as string , actorList . length === 0 ) ;
116+
93117 mcpServer . upsertTools ( tools ) ;
94118
95119 // Start server
0 commit comments