11import { Ajv } from 'ajv' ;
2- import type { ApifyClientOptions } from 'apify' ;
32import type { ActorCallOptions } from 'apify-client' ;
4- import { ApifyClient } from 'apify-client' ;
5- import type { AxiosRequestConfig } from 'axios' ;
63
74import log from '@apify/log' ;
85
96import type { ToolWrap } from '../types.js' ;
107import { getActorDefinition } from './build.js' ;
11- import { ACTOR_ADDITIONAL_INSTRUCTIONS , ACTOR_MAX_MEMORY_MBYTES , USER_AGENT_ORIGIN } from '../const.js' ;
8+ import { ACTOR_ADDITIONAL_INSTRUCTIONS , ACTOR_MAX_MEMORY_MBYTES } from '../const.js' ;
9+ import { ApifyClient } from './mcp-apify-client.js' ;
1210import {
1311 actorNameToToolName ,
1412 addEnumsToDescriptionsWithExamples ,
@@ -18,18 +16,6 @@ import {
1816 shortenProperties ,
1917} from './utils.js' ;
2018
21- /**
22- * Adds a User-Agent header to the request config.
23- * @param config
24- * @private
25- */
26- export function addUserAgent ( config : AxiosRequestConfig ) : AxiosRequestConfig {
27- const updatedConfig = { ...config } ;
28- updatedConfig . headers = updatedConfig . headers ?? { } ;
29- updatedConfig . headers [ 'User-Agent' ] = `${ updatedConfig . headers [ 'User-Agent' ] ?? '' } ; ${ USER_AGENT_ORIGIN } ` ;
30- return updatedConfig ;
31- }
32-
3319/**
3420 * Calls an Apify actor and retrieves the dataset items.
3521 *
@@ -54,8 +40,7 @@ export async function callActorGetDataset(
5440 try {
5541 log . info ( `Calling Actor ${ name } with input: ${ JSON . stringify ( input ) } ` ) ;
5642
57- const options : ApifyClientOptions = { requestInterceptors : [ addUserAgent ] } ;
58- const client = new ApifyClient ( { ...options , token : apifyToken } ) ;
43+ const client = new ApifyClient ( { token : apifyToken } ) ;
5944 const actorClient = client . actor ( name ) ;
6045
6146 const results = await actorClient . call ( input , callOptions ) ;
0 commit comments