Skip to content

Commit f5310a6

Browse files
committed
fix: logic when starting server
1 parent 76eba1c commit f5310a6

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

src/actor/server.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ export function createExpressApp(
6969
const tools = await processParamsGetTools(req.url, process.env.APIFY_TOKEN as string);
7070
if (tools) {
7171
mcpServer.updateTools(tools);
72+
} else {
73+
// We are loading default Actors (if not specified otherwise), so that we don't have "empty" tools
74+
await mcpServer.loadDefaultTools(process.env.APIFY_TOKEN as string);
7275
}
7376
transportSSE = new SSEServerTransport(Routes.MESSAGE, res);
7477
await mcpServer.connect(transportSSE);

src/main.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ import type { ActorCallOptions } from 'apify-client';
99
import log from '@apify/log';
1010

1111
import { createExpressApp } from './actor/server.js';
12-
import { defaults } from './const.js';
1312
import { processInput } from './input.js';
1413
import { ActorsMcpServer } from './mcp/server.js';
15-
import { actorDefinitionTool, addTool, callActorGetDataset, getActorsAsTools, removeTool, searchTool } from './tools/index.js';
14+
import { actorDefinitionTool, addTool, callActorGetDataset, removeTool, searchTool } from './tools/index.js';
1615
import type { Input } from './types.js';
1716

1817
const STANDBY_MODE = Actor.getEnv().metaOrigin === 'STANDBY';
@@ -35,14 +34,11 @@ log.info(`Loaded input: ${JSON.stringify(input)} `);
3534
if (STANDBY_MODE) {
3635
const app = createExpressApp(HOST, mcpServer);
3736
log.info('Actor is running in the STANDBY mode.');
37+
// Do not load default Actors here, for mastra.ai template we need to start without default Actors
3838
const tools = [searchTool, actorDefinitionTool];
39-
if (input.enableActorAutoLoading) {
39+
if (input.enableAddingActors) {
4040
tools.push(addTool, removeTool);
4141
}
42-
const actors = input.actors ?? defaults.actors;
43-
const actorsToLoad = Array.isArray(actors) ? actors : actors.split(',');
44-
const actorTools = await getActorsAsTools(actorsToLoad, process.env.APIFY_TOKEN as string);
45-
tools.push(...actorTools);
4642
mcpServer.updateTools(tools);
4743
app.listen(PORT, () => {
4844
log.info(`The Actor web server is listening for user requests at ${HOST}`);

src/mcp/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export async function processParamsGetTools(url: string, apifyToken: string) {
4747
// Normal Actors as a tool
4848
tools = await getActorsAsTools(actors, apifyToken);
4949
}
50-
if (input.enableActorAutoLoading) {
50+
if (input.enableAddingActors) {
5151
tools.push(addTool, removeTool);
5252
}
5353
return tools;

0 commit comments

Comments
 (0)