Skip to content

Commit 5238225

Browse files
authored
fix: load actors as tools dynamically based on input (#87)
1 parent fcccfcd commit 5238225

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/input.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import log from '@apify/log';
66
import type { Input } from './types.js';
77

88
/**
9-
* Process input parameters, split actors string into an array
9+
* Process input parameters, split Actors string into an array
1010
* @param originalInput
1111
* @returns input
1212
*/

src/main.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@ import log from '@apify/log';
1111
import { createExpressApp } from './actor/server.js';
1212
import { processInput } from './input.js';
1313
import { ActorsMcpServer } from './mcp/server.js';
14-
import { actorDefinitionTool, addTool, callActorGetDataset, removeTool, searchTool } from './tools/index.js';
14+
import {
15+
actorDefinitionTool,
16+
addTool,
17+
callActorGetDataset,
18+
getActorsAsTools,
19+
removeTool,
20+
searchTool,
21+
} from './tools/index.js';
1522
import type { Input } from './types.js';
1623

1724
const STANDBY_MODE = Actor.getEnv().metaOrigin === 'STANDBY';
@@ -39,6 +46,11 @@ if (STANDBY_MODE) {
3946
if (input.enableAddingActors) {
4047
tools.push(addTool, removeTool);
4148
}
49+
if (input.actors && input.actors.length > 0) {
50+
const { actors } = input;
51+
const actorsToLoad = Array.isArray(actors) ? actors : actors.split(',');
52+
tools.push(...await getActorsAsTools(actorsToLoad, process.env.APIFY_TOKEN as string));
53+
}
4254
mcpServer.updateTools(tools);
4355
app.listen(PORT, () => {
4456
log.info(`The Actor web server is listening for user requests at ${HOST}`);

0 commit comments

Comments
 (0)