UNPKG

@apify/actors-mcp-server

Version:

Model Context Protocol Server for Apify

108 lines 5.24 kB
import type { ValidateFunction } from 'ajv'; import type Ajv from 'ajv'; import type { ActorInputSchemaProperties, IActorInputSchema, ISchemaProperties } from '../types.js'; export declare function actorNameToToolName(actorName: string): string; export declare function getToolSchemaID(actorName: string): string; export declare function fixedAjvCompile(ajvInstance: Ajv, schema: object): ValidateFunction<unknown>; /** * Builds nested properties for object types in the schema. * * Specifically handles special cases like proxy configuration and request list sources * by adding predefined nested properties to these object types. * This is necessary for the agent to correctly infer how to structure object inputs * when passing arguments to the Actor. * * For proxy objects (type='object', editor='proxy'), adds 'useApifyProxy' property. * For request list sources (type='array', editor='requestListSources'), adds URL structure to items. * * @param {Record<string, ISchemaProperties>} properties - The input schema properties * @returns {Record<string, ISchemaProperties>} Modified properties with nested properties */ export declare function buildApifySpecificProperties(properties: Record<string, ISchemaProperties>): Record<string, ISchemaProperties>; /** * Filters schema properties to include only the necessary fields. * This is done to reduce the size of the input schema and to make it more readable. * @param properties */ export declare function filterSchemaProperties(properties: { [key: string]: ISchemaProperties; }): { [key: string]: ISchemaProperties; }; /** * For array properties missing items.type, infers and sets the type using inferArrayItemType. * @param properties */ export declare function inferArrayItemsTypeIfMissing(properties: { [key: string]: ISchemaProperties; }): { [key: string]: ISchemaProperties; }; /** * Marks input properties as required by adding a "REQUIRED" prefix to their descriptions. * Takes an IActorInput object and returns a modified Record of SchemaProperties. * * This is done for maximum compatibility in case where library or agent framework does not consider * required fields and does not handle the JSON schema properly: we are prepending this to the description * as a preventive measure. * @param {IActorInputSchema} input - Actor input object containing properties and required fields * @returns {Record<string, ISchemaProperties>} - Modified properties with required fields marked */ export declare function markInputPropertiesAsRequired(input: IActorInputSchema): Record<string, ISchemaProperties>; /** * Helps determine the type of items in an array schema property. * Priority order: explicit type in items > prefill type > default value type > editor type. * * Based on JSON schema, the array needs a type, and most of the time Actor input schema does not have this, so we need to infer that. * */ export declare function inferArrayItemType(property: ISchemaProperties): string | null; /** * Add enum values as string to property descriptions. * * This is done as a preventive measure to prevent cases where library or agent framework * does not handle enums or examples based on JSON schema definition. * * https://json-schema.org/understanding-json-schema/reference/enum * https://json-schema.org/understanding-json-schema/reference/annotations * * @param properties */ export declare function addEnumsToDescriptionsWithExamples(properties: Record<string, ISchemaProperties>): Record<string, ISchemaProperties>; /** * Helper function to shorten the enum list if it is too long. * * @param {string[]} enumList - The list of enum values to be shortened. * @returns {string[] | undefined} - The shortened enum list or undefined if the list is too long. */ export declare function shortenEnum(enumList: string[]): string[] | undefined; /** * Shortens the description, enum, and items.enum properties of the schema properties. * @param properties */ export declare function shortenProperties(properties: { [key: string]: ISchemaProperties; }): { [key: string]: ISchemaProperties; }; /** * Fixes dot notation in the property names of schema properties. * * Some providers, such as Anthropic, allow only the following characters in property names: `^[a-zA-Z0-9_-]{1,64}$`. * * @param properties - The schema properties to fix. * @returns {Record<string, ISchemaProperties>} The schema properties with fixed names. */ export declare function encodeDotPropertyNames(properties: Record<string, ISchemaProperties>): Record<string, ISchemaProperties>; /** * Restores original property names by replacing '-dot-' with '.'. * * This is necessary to decode the property names that were encoded to avoid issues with providers * that do not allow dots in property names. * * @param properties - The schema properties with encoded names. * @returns {Record<string, ISchemaProperties>} The schema properties with restored names. */ export declare function decodeDotPropertyNames(properties: Record<string, unknown>): Record<string, unknown>; export declare function transformActorInputSchemaProperties(input: Readonly<IActorInputSchema>): ActorInputSchemaProperties; //# sourceMappingURL=utils.d.ts.map