Skip to content

Commit 261e1aa

Browse files
authored
feat: dynamic actor loading is enabled by default (#147)
1 parent 2e0c9b6 commit 261e1aa

File tree

7 files changed

+32
-20
lines changed

7 files changed

+32
-20
lines changed

.actor/input_schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"title": "Enable adding Actors based on context and use-case (experimental, check if it supported by your client)",
2626
"type": "boolean",
2727
"description": "When enabled, the server can dynamically add Actors as tools based on user requests and context. \n\nNote: MCP client must support notification on tool updates. To try it, you can use the [Tester MCP Client](https://apify.com/jiri.spilka/tester-mcp-client). This is an experimental feature and may require client-specific support.",
28-
"default": false
28+
"default": true
2929
},
3030
"maxActorMemoryBytes": {
3131
"title": "Limit the maximum memory used by an Actor",
@@ -48,7 +48,7 @@
4848
"description": "Specify the input for the Actor that will be used for debugging in normal mode",
4949
"editor": "json",
5050
"prefill": {
51-
"query": "hello world"
51+
"query": "hello world"
5252
}
5353
}
5454
}

src/input.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function processInput(originalInput: Partial<Input>): Input {
2424
log.warning('enableActorAutoLoading is deprecated, use enableAddingActors instead');
2525
input.enableAddingActors = input.enableActorAutoLoading === true || input.enableActorAutoLoading === 'true';
2626
} else {
27-
input.enableAddingActors = false;
27+
input.enableAddingActors = true;
2828
}
2929
} else {
3030
input.enableAddingActors = input.enableAddingActors === true || input.enableAddingActors === 'true';

src/mcp/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class ActorsMcpServer {
5050

5151
constructor(options: ActorsMcpServerOptions = {}, setupSigintHandler = true) {
5252
this.options = {
53-
enableAddingActors: options.enableAddingActors ?? false,
53+
enableAddingActors: options.enableAddingActors ?? true,
5454
enableDefaultActors: options.enableDefaultActors ?? true, // Default to true for backward compatibility
5555
};
5656
this.server = new Server(

src/stdio.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ import { getActorsAsTools } from './tools/index.js';
3333
*/
3434
interface CliArgs {
3535
actors?: string;
36-
'enable-adding-actors'?: boolean;
37-
enableActorAutoLoading?: boolean;
36+
enableAddingActors: boolean;
37+
/** @deprecated */
38+
enableActorAutoLoading: boolean;
3839
}
3940

4041
// Configure logging, set to ERROR
@@ -50,12 +51,12 @@ const argv = yargs(hideBin(process.argv))
5051
})
5152
.option('enable-adding-actors', {
5253
type: 'boolean',
53-
default: false,
54+
default: true,
5455
describe: 'Enable dynamically adding Actors as tools based on user requests',
5556
})
5657
.option('enableActorAutoLoading', {
5758
type: 'boolean',
58-
default: false,
59+
default: true,
5960
hidden: true,
6061
describe: 'Deprecated: use enable-adding-actors instead',
6162
})
@@ -69,7 +70,7 @@ const argv = yargs(hideBin(process.argv))
6970
.epilogue('For more information, visit https://github.com/apify/actors-mcp-server')
7071
.parseSync() as CliArgs;
7172

72-
const enableAddingActors = argv['enable-adding-actors'] || argv.enableActorAutoLoading || false;
73+
const enableAddingActors = argv.enableAddingActors && argv.enableActorAutoLoading;
7374
const actors = argv.actors as string || '';
7475
const actorList = actors ? actors.split(',').map((a: string) => a.trim()) : [];
7576

tests/helpers.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ export async function createMcpSseClient(
2323
if (actors) {
2424
url.searchParams.append('actors', actors.join(','));
2525
}
26-
if (enableAddingActors) {
27-
url.searchParams.append('enableAddingActors', 'true');
26+
if (enableAddingActors !== undefined) {
27+
url.searchParams.append('enableAddingActors', enableAddingActors.toString());
2828
}
2929

3030
const transport = new SSEClientTransport(
@@ -59,8 +59,8 @@ export async function createMcpStreamableClient(
5959
if (actors) {
6060
url.searchParams.append('actors', actors.join(','));
6161
}
62-
if (enableAddingActors) {
63-
url.searchParams.append('enableAddingActors', 'true');
62+
if (enableAddingActors !== undefined) {
63+
url.searchParams.append('enableAddingActors', enableAddingActors.toString());
6464
}
6565

6666
const transport = new StreamableHTTPClientTransport(
@@ -94,8 +94,8 @@ export async function createMcpStdioClient(
9494
if (actors) {
9595
args.push('--actors', actors.join(','));
9696
}
97-
if (enableAddingActors) {
98-
args.push('--enable-adding-actors');
97+
if (enableAddingActors !== undefined) {
98+
args.push('--enable-adding-actors', enableAddingActors.toString());
9999
}
100100
const transport = new StdioClientTransport({
101101
command: 'node',

tests/integration/suite.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,19 @@ export function createIntegrationTestsSuite(
8282
describe(suiteName, {
8383
concurrent: false, // Make all tests sequential to prevent state interference
8484
}, () => {
85-
it('should list all default tools and default Actors', async () => {
85+
it('should list all default tools and Actors', async () => {
8686
const client = await createClientFn();
8787
const tools = await client.listTools();
88-
expect(tools.tools.length).toEqual(defaultTools.length + defaults.actors.length);
88+
expect(tools.tools.length).toEqual(defaultTools.length + defaults.actors.length + addRemoveTools.length);
8989

9090
const names = getToolNames(tools);
9191
expectToolNamesToContain(names, DEFAULT_TOOL_NAMES);
9292
expectToolNamesToContain(names, DEFAULT_ACTOR_NAMES);
93+
expectToolNamesToContain(names, addRemoveTools.map((tool) => tool.tool.name));
9394
await client.close();
9495
});
9596

96-
it('should list all default tools, tools for adding/removing Actors, and default Actors', async () => {
97+
it('should list all default tools and Actors, with add/remove tools', async () => {
9798
const client = await createClientFn({ enableAddingActors: true });
9899
const names = getToolNames(await client.listTools());
99100
expect(names.length).toEqual(defaultTools.length + defaults.actors.length + addRemoveTools.length);
@@ -104,6 +105,16 @@ export function createIntegrationTestsSuite(
104105
await client.close();
105106
});
106107

108+
it('should list all default tools and Actors, without add/remove tools', async () => {
109+
const client = await createClientFn({ enableAddingActors: false });
110+
const names = getToolNames(await client.listTools());
111+
expect(names.length).toEqual(defaultTools.length + defaults.actors.length);
112+
113+
expectToolNamesToContain(names, DEFAULT_TOOL_NAMES);
114+
expectToolNamesToContain(names, DEFAULT_ACTOR_NAMES);
115+
await client.close();
116+
});
117+
107118
it('should list all default tools and two loaded Actors', async () => {
108119
const actors = ['apify/website-content-crawler', 'apify/instagram-scraper'];
109120
const client = await createClientFn({ actors, enableAddingActors: false });

tests/unit/input.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ describe('processInput', () => {
3939
expect(processed.enableAddingActors).toBe(false);
4040
});
4141

42-
it('should default enableAddingActors to false when not provided', async () => {
42+
it('should default enableAddingActors to true when not provided', async () => {
4343
const input: Partial<Input> = {
4444
actors: ['actor1'],
4545
};
4646
const processed = processInput(input);
47-
expect(processed.enableAddingActors).toBe(false);
47+
expect(processed.enableAddingActors).toBe(true);
4848
});
4949
});

0 commit comments

Comments
 (0)