@@ -30,7 +30,7 @@ import {
3030import { prompts } from '../prompts/index.js' ;
3131import { callActorGetDataset , defaultTools , getActorsAsTools , toolCategories } from '../tools/index.js' ;
3232import { decodeDotPropertyNames } from '../tools/utils.js' ;
33- import type { ActorMcpTool , ActorTool , AuthToken , HelperTool , ToolEntry } from '../types.js' ;
33+ import type { ActorMcpTool , ActorTool , AuthInfo , HelperTool , ToolEntry } from '../types.js' ;
3434import { createProgressTracker } from '../utils/progress.js' ;
3535import { getToolPublicFieldOnly } from '../utils/tools.js' ;
3636import { connectMCPClient } from './client.js' ;
@@ -155,12 +155,12 @@ export class ActorsMcpServer {
155155 }
156156
157157 /**
158- * Loads missing toolNames from a provided list of tool names.
159- * Skips toolNames that are already loaded and loads only the missing ones.
160- * @param toolNames - Array of tool names to ensure are loaded
161- * @param authToken - Token for Apify service authentication
162- */
163- public async loadToolsByName ( toolNames : string [ ] , authToken : AuthToken ) {
158+ * Loads missing toolNames from a provided list of tool names.
159+ * Skips toolNames that are already loaded and loads only the missing ones.
160+ * @param toolNames - Array of tool names to ensure are loaded
161+ * @param authInfo - Info for Apify service authentication
162+ */
163+ public async loadToolsByName ( toolNames : string [ ] , authInfo : AuthInfo ) {
164164 const loadedTools = this . listAllToolNames ( ) ;
165165 const actorsToLoad : string [ ] = [ ] ;
166166 const toolsToLoad : ToolEntry [ ] = [ ] ;
@@ -185,19 +185,19 @@ export class ActorsMcpServer {
185185 }
186186
187187 if ( actorsToLoad . length > 0 ) {
188- await this . loadActorsAsTools ( actorsToLoad , authToken ) ;
188+ await this . loadActorsAsTools ( actorsToLoad , authInfo ) ;
189189 }
190190 }
191191
192192 /**
193193 * Load actors as tools, upsert them to the server, and return the tool entries.
194194 * This is a public method that wraps getActorsAsTools and handles the upsert operation.
195195 * @param actorIdsOrNames - Array of actor IDs or names to load as tools
196- * @param authToken - Token for Apify service authentication
196+ * @param authInfo - Info for Apify service authentication
197197 * @returns Promise<ToolEntry[]> - Array of loaded tool entries
198198 */
199- public async loadActorsAsTools ( actorIdsOrNames : string [ ] , authToken : AuthToken ) : Promise < ToolEntry [ ] > {
200- const actorTools = await getActorsAsTools ( actorIdsOrNames , authToken ) ;
199+ public async loadActorsAsTools ( actorIdsOrNames : string [ ] , authInfo : AuthInfo ) : Promise < ToolEntry [ ] > {
200+ const actorTools = await getActorsAsTools ( actorIdsOrNames , authInfo ) ;
201201 if ( actorTools . length > 0 ) {
202202 this . upsertTools ( actorTools , true ) ;
203203 }
@@ -211,8 +211,8 @@ export class ActorsMcpServer {
211211 *
212212 * Used primarily for SSE.
213213 */
214- public async loadToolsFromUrl ( url : string , authToken : AuthToken ) {
215- const tools = await processParamsGetTools ( url , authToken ) ;
214+ public async loadToolsFromUrl ( url : string , authInfo : AuthInfo ) {
215+ const tools = await processParamsGetTools ( url , authInfo ) ;
216216 if ( tools . length > 0 ) {
217217 log . debug ( 'Loading tools from query parameters' ) ;
218218 this . upsertTools ( tools , false ) ;
@@ -381,27 +381,27 @@ export class ActorsMcpServer {
381381 // eslint-disable-next-line prefer-const
382382 let { name, arguments : args , _meta : meta } = request . params ;
383383 const { progressToken } = meta || { } ;
384- // Extract auth token with fallback to APIFY_TOKEN environment variable
385- let authToken : AuthToken | undefined = request . params . authToken as AuthToken ;
384+ // Extract auth info with fallback to APIFY_TOKEN environment variable
385+ let authInfo : AuthInfo | undefined = request . params . authInfo as AuthInfo ;
386386
387387 // Fallback to APIFY_TOKEN environment variable for local development
388- if ( ! authToken && process . env . APIFY_TOKEN ) {
389- authToken = {
388+ if ( ! authInfo && process . env . APIFY_TOKEN ) {
389+ authInfo = {
390390 value : process . env . APIFY_TOKEN ,
391391 type : 'apify' , // Environment variable is always an Apify token
392392 } ;
393393 }
394394 const userRentedActorIds = request . params . userRentedActorIds as string [ ] | undefined ;
395395
396- // Remove authToken from request.params only if it was provided in params
397- if ( request . params . authToken ) {
398- delete request . params . authToken ;
396+ // Remove authInfo from request.params only if it was provided in params
397+ if ( request . params . authInfo ) {
398+ delete request . params . authInfo ;
399399 }
400400 // Remove other custom params passed from apify-mcp-server
401401 delete request . params . userRentedActorIds ;
402402
403- // Validate auth token
404- if ( ! authToken || ! authToken . value ) {
403+ // Validate auth info
404+ if ( ! authInfo || ! authInfo . value ) {
405405 const msg = `Valid authentication token required. It must be provided either in the Bearer Authorization header, APIFY_TOKEN environment variable or skyfire-pay-id header as Skyfire payment token.` ;
406406 log . error ( msg ) ;
407407 await this . server . sendLoggingMessage ( { level : 'error' , data : msg } ) ;
@@ -473,7 +473,7 @@ export class ActorsMcpServer {
473473 extra,
474474 apifyMcpServer : this ,
475475 mcpServer : this . server ,
476- authToken ,
476+ authInfo ,
477477 userRentedActorIds,
478478 progressTracker,
479479 } ) as object ;
@@ -489,7 +489,7 @@ export class ActorsMcpServer {
489489 const serverTool = tool . tool as ActorMcpTool ;
490490 let client : Client | undefined ;
491491 try {
492- client = await connectMCPClient ( serverTool . serverUrl , authToken . value ) ;
492+ client = await connectMCPClient ( serverTool . serverUrl , authInfo . value ) ;
493493
494494 // Only set up notification handlers if progressToken is provided by the client
495495 if ( progressToken ) {
@@ -538,7 +538,7 @@ export class ActorsMcpServer {
538538 const { runId, datasetId, items } = await callActorGetDataset (
539539 actorTool . actorFullName ,
540540 args ,
541- authToken ,
541+ authInfo ,
542542 callOptions ,
543543 progressTracker ,
544544 ) ;
0 commit comments