@apify/actors-mcp-server
Version:
Model Context Protocol Server for Apify
48 lines • 2.72 kB
TypeScript
import type { ActorCallOptions, PaginatedList } from 'apify-client';
import type { ActorInfo, ToolEntry } from '../types.js';
import type { ProgressTracker } from '../utils/progress.js';
export type CallActorGetDatasetResult = {
runId: string;
datasetId: string;
items: PaginatedList<Record<string, unknown>>;
};
/**
* Calls an Apify actor and retrieves the dataset items.
*
*
* It requires the `APIFY_TOKEN` environment variable to be set.
* If the `APIFY_IS_AT_HOME` the dataset items are pushed to the Apify dataset.
*
* @param {string} actorName - The name of the actor to call.
* @param {ActorCallOptions} callOptions - The options to pass to the actor.
* @param {unknown} input - The input to pass to the actor.
* @param {string} apifyToken - The Apify token to use for authentication.
* @param {ProgressTracker} progressTracker - Optional progress tracker for real-time updates.
* @returns {Promise<{ actorRun: any, items: object[] }>} - A promise that resolves to an object containing the actor run and dataset items.
* @throws {Error} - Throws an error if the `APIFY_TOKEN` is not set
*/
export declare function callActorGetDataset(actorName: string, input: unknown, apifyToken: string, callOptions?: ActorCallOptions | undefined, progressTracker?: ProgressTracker | null): Promise<CallActorGetDatasetResult>;
/**
* This function is used to fetch normal non-MCP server Actors as a tool.
*
* Fetches actor input schemas by Actor IDs or Actor full names and creates MCP tools.
*
* This function retrieves the input schemas for the specified actors and compiles them into MCP tools.
* It uses the AJV library to validate the input schemas.
*
* Tool name can't contain /, so it is replaced with _
*
* The input schema processing workflow:
* 1. Properties are marked as required using markInputPropertiesAsRequired() to add "REQUIRED" prefix to descriptions
* 2. Nested properties are built by analyzing editor type (proxy, requestListSources) using buildNestedProperties()
* 3. Properties are filtered using filterSchemaProperties()
* 4. Properties are shortened using shortenProperties()
* 5. Enums are added to descriptions with examples using addEnumsToDescriptionsWithExamples()
*
* @param {ActorInfo[]} actorsInfo - An array of ActorInfo objects with webServerMcpPath and actorDefinitionPruned.
* @returns {Promise<ToolEntry[]>} - A promise that resolves to an array of MCP tools.
*/
export declare function getNormalActorsAsTools(actorsInfo: ActorInfo[]): Promise<ToolEntry[]>;
export declare function getActorsAsTools(actorIdsOrNames: string[], apifyToken: string): Promise<ToolEntry[]>;
export declare const callActor: ToolEntry;
//# sourceMappingURL=actor.d.ts.map