Skip to content

Commit 6236e44

Browse files
authored
fix: Use a new API to get Actor default build (#114)
fix: Use a new API to get Actor default build`
1 parent 8354adb commit 6236e44

File tree

4 files changed

+26
-19
lines changed

4 files changed

+26
-19
lines changed

package-lock.json

Lines changed: 21 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"@modelcontextprotocol/sdk": "^1.10.1",
3535
"ajv": "^8.17.1",
3636
"apify": "^3.4.0",
37-
"apify-client": "^2.12.1",
37+
"apify-client": "^2.12.3",
3838
"express": "^4.21.2",
3939
"minimist": "^1.2.8",
4040
"zod": "^3.24.1",

src/tools/actor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export async function callActorGetDataset(
7676
* 5. Enums are added to descriptions with examples using addEnumsToDescriptionsWithExamples()
7777
*
7878
* @param {string[]} actors - An array of actor IDs or Actor full names.
79+
* @param {string} apifyToken - The Apify token to use for authentication.
7980
* @returns {Promise<Tool[]>} - A promise that resolves to an array of MCP tools.
8081
*/
8182
export async function getNormalActorsAsTools(
@@ -84,8 +85,7 @@ export async function getNormalActorsAsTools(
8485
): Promise<ToolWrap[]> {
8586
const ajv = new Ajv({ coerceTypes: 'array', strict: false });
8687
const getActorDefinitionWithToken = async (actorId: string) => {
87-
const actor = await getActorDefinition(actorId, apifyToken);
88-
return actor;
88+
return await getActorDefinition(actorId, apifyToken);
8989
};
9090
const results = await Promise.all(actors.map(getActorDefinitionWithToken));
9191
const tools: ToolWrap[] = [];

src/tools/build.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,9 @@ export async function getActorDefinition(
4141
return null;
4242
}
4343

44-
// fnesveda: The default build is not necessarily tagged, you can specify any build number as default build.
45-
// There will be a new API endpoint to fetch a default build.
46-
// For now, we'll use the tagged build, it will work for 90% of Actors. Later, we can update this.
47-
const tag = actor.defaultRunOptions?.build || '';
48-
const buildId = actor.taggedBuilds?.[tag]?.buildId || '';
44+
const defaultBuildClient = await actorClient.defaultBuild();
45+
const buildDetails = await defaultBuildClient.get();
4946

50-
if (!buildId) {
51-
log.error(`Failed to fetch input schema for Actor: ${actorIdOrName}. Build ID not found.`);
52-
return null;
53-
}
54-
// Fetch build details and return the input schema
55-
const buildDetails = await client.build(buildId).get();
5647
if (buildDetails?.actorDefinition) {
5748
const actorDefinitions = buildDetails?.actorDefinition as ActorDefinitionWithDesc;
5849
actorDefinitions.id = actor.id;

0 commit comments

Comments
 (0)