From 9e80fe80b8d4fa00a258f5b6c345b5ae7b99017f Mon Sep 17 00:00:00 2001 From: Jiri Spilka Date: Tue, 13 May 2025 10:56:53 +0200 Subject: [PATCH] fix: Use a new API to get Actor default build` --- package-lock.json | 26 +++++++++++++++++++++----- package.json | 2 +- src/tools/actor.ts | 4 ++-- src/tools/build.ts | 13 ++----------- 4 files changed, 26 insertions(+), 19 deletions(-) diff --git a/package-lock.json b/package-lock.json index 03bf7eda..901785aa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@modelcontextprotocol/sdk": "^1.10.1", "ajv": "^8.17.1", "apify": "^3.4.0", - "apify-client": "^2.12.1", + "apify-client": "^2.12.3", "express": "^4.21.2", "minimist": "^1.2.8", "zod": "^3.24.1", @@ -2473,12 +2473,12 @@ } }, "node_modules/apify-client": { - "version": "2.12.2", - "resolved": "https://registry.npmjs.org/apify-client/-/apify-client-2.12.2.tgz", - "integrity": "sha512-+eSexDukVso58MQ8pOJj67mnaDkexH80VJs0/stfM8yNSUKMa/BIIdbG3rX8axjpTtT3UzpPgMIz6qh8inxFCQ==", + "version": "2.12.3", + "resolved": "https://registry.npmjs.org/apify-client/-/apify-client-2.12.3.tgz", + "integrity": "sha512-z12/QmvgJoVustbuujJ4fASfRq8K3b3fdxcXRm0mxFP6ufjmJt9k13755rXytvNnHaKRmKh0ViUIRUQ4al9lOg==", "license": "Apache-2.0", "dependencies": { - "@apify/consts": "^2.40.0", + "@apify/consts": "^2.25.0", "@apify/log": "^2.2.6", "@crawlee/types": "^3.3.0", "agentkeepalive": "^4.2.1", @@ -2486,6 +2486,7 @@ "axios": "^1.6.7", "content-type": "^1.0.5", "ow": "^0.28.2", + "prettier": "^3.5.3", "tslib": "^2.5.0", "type-fest": "^4.0.0" } @@ -6337,6 +6338,21 @@ "node": ">= 0.8.0" } }, + "node_modules/prettier": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.5.3.tgz", + "integrity": "sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==", + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/proper-lockfile": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/proper-lockfile/-/proper-lockfile-4.1.2.tgz", diff --git a/package.json b/package.json index 4e6401ff..ba315e55 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "@modelcontextprotocol/sdk": "^1.10.1", "ajv": "^8.17.1", "apify": "^3.4.0", - "apify-client": "^2.12.1", + "apify-client": "^2.12.3", "express": "^4.21.2", "minimist": "^1.2.8", "zod": "^3.24.1", diff --git a/src/tools/actor.ts b/src/tools/actor.ts index 2c4e7744..98032cf2 100644 --- a/src/tools/actor.ts +++ b/src/tools/actor.ts @@ -76,6 +76,7 @@ export async function callActorGetDataset( * 5. Enums are added to descriptions with examples using addEnumsToDescriptionsWithExamples() * * @param {string[]} actors - An array of actor IDs or Actor full names. + * @param {string} apifyToken - The Apify token to use for authentication. * @returns {Promise} - A promise that resolves to an array of MCP tools. */ export async function getNormalActorsAsTools( @@ -84,8 +85,7 @@ export async function getNormalActorsAsTools( ): Promise { const ajv = new Ajv({ coerceTypes: 'array', strict: false }); const getActorDefinitionWithToken = async (actorId: string) => { - const actor = await getActorDefinition(actorId, apifyToken); - return actor; + return await getActorDefinition(actorId, apifyToken); }; const results = await Promise.all(actors.map(getActorDefinitionWithToken)); const tools: ToolWrap[] = []; diff --git a/src/tools/build.ts b/src/tools/build.ts index 1d0d1266..c1b6951c 100644 --- a/src/tools/build.ts +++ b/src/tools/build.ts @@ -41,18 +41,9 @@ export async function getActorDefinition( return null; } - // fnesveda: The default build is not necessarily tagged, you can specify any build number as default build. - // There will be a new API endpoint to fetch a default build. - // For now, we'll use the tagged build, it will work for 90% of Actors. Later, we can update this. - const tag = actor.defaultRunOptions?.build || ''; - const buildId = actor.taggedBuilds?.[tag]?.buildId || ''; + const defaultBuildClient = await actorClient.defaultBuild(); + const buildDetails = await defaultBuildClient.get(); - if (!buildId) { - log.error(`Failed to fetch input schema for Actor: ${actorIdOrName}. Build ID not found.`); - return null; - } - // Fetch build details and return the input schema - const buildDetails = await client.build(buildId).get(); if (buildDetails?.actorDefinition) { const actorDefinitions = buildDetails?.actorDefinition as ActorDefinitionWithDesc; actorDefinitions.id = actor.id;