Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/tools/actor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Tool[]>} - A promise that resolves to an array of MCP tools.
*/
export async function getNormalActorsAsTools(
Expand All @@ -84,8 +85,7 @@ export async function getNormalActorsAsTools(
): Promise<ToolWrap[]> {
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[] = [];
Expand Down
13 changes: 2 additions & 11 deletions src/tools/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Copy link

Copilot AI May 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The previous implementation logged an error when the build details were missing. Consider adding error logging here to aid troubleshooting in case the new API returns no actorDefinition.

Suggested change
const buildDetails = await defaultBuildClient.get();
const buildDetails = await defaultBuildClient.get();
if (!buildDetails) {
log.error(`Failed to fetch build details for Actor: ${actorIdOrName}. Build details not found.`);
return null;
}

Copilot uses AI. Check for mistakes.

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;
Expand Down