File tree Expand file tree Collapse file tree 4 files changed +21
-7
lines changed Expand file tree Collapse file tree 4 files changed +21
-7
lines changed Original file line number Diff line number Diff line change 3131 ],
3232 "dependencies" : {
3333 "@apify/log" : " ^2.5.16" ,
34- "@modelcontextprotocol/sdk" : " ^1.10.0 " ,
34+ "@modelcontextprotocol/sdk" : " ^1.10.1 " ,
3535 "ajv" : " ^8.17.1" ,
3636 "apify" : " ^3.4.0" ,
3737 "apify-client" : " ^2.12.1" ,
Original file line number Diff line number Diff line change @@ -121,6 +121,14 @@ export function createExpressApp(
121121 sessionIdGenerator : ( ) => randomUUID ( ) ,
122122 enableJsonResponse : true , // Enable JSON response mode
123123 } ) ;
124+ // Load MCP server tools
125+ // TODO using query parameters in POST request is not standard
126+ const urlSearchParams = new URLSearchParams ( req . url . split ( '?' ) [ 1 ] ) ;
127+ if ( urlSearchParams . get ( 'actors' ) ) {
128+ await mcpServer . loadToolsFromUrl ( req . url , process . env . APIFY_TOKEN as string ) ;
129+ } else {
130+ await mcpServer . loadDefaultTools ( process . env . APIFY_TOKEN as string ) ;
131+ }
124132
125133 // Connect the transport to the MCP server BEFORE handling the request
126134 await mcpServer . connect ( transport ) ;
Original file line number Diff line number Diff line change @@ -57,7 +57,10 @@ export class ActorsMcpServer {
5757 public async loadDefaultTools ( apifyToken : string ) {
5858 const missingDefaultTools = defaults . actors . filter ( ( name ) => ! this . tools . has ( actorNameToToolName ( name ) ) ) ;
5959 const tools = await getActorsAsTools ( missingDefaultTools , apifyToken ) ;
60- if ( tools . length > 0 ) this . updateTools ( tools ) ;
60+ if ( tools . length > 0 ) {
61+ log . info ( 'Loading default tools...' ) ;
62+ this . updateTools ( tools ) ;
63+ }
6164 }
6265
6366 /**
@@ -69,7 +72,10 @@ export class ActorsMcpServer {
6972 */
7073 public async loadToolsFromUrl ( url : string , apifyToken : string ) {
7174 const tools = await processParamsGetTools ( url , apifyToken ) ;
72- if ( tools . length > 0 ) this . updateTools ( tools ) ;
75+ if ( tools . length > 0 ) {
76+ log . info ( 'Loading tools from query parameters...' ) ;
77+ this . updateTools ( tools ) ;
78+ }
7379 }
7480
7581 /**
You can’t perform that action at this time.
0 commit comments