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
4 changes: 2 additions & 2 deletions .actor/input_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"title": "Enable adding Actors based on context and use-case (experimental, check if it supported by your client)",
"type": "boolean",
"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.",
"default": false
"default": true
},
"maxActorMemoryBytes": {
"title": "Limit the maximum memory used by an Actor",
Expand All @@ -48,7 +48,7 @@
"description": "Specify the input for the Actor that will be used for debugging in normal mode",
"editor": "json",
"prefill": {
"query": "hello world"
"query": "hello world"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function processInput(originalInput: Partial<Input>): Input {
log.warning('enableActorAutoLoading is deprecated, use enableAddingActors instead');
input.enableAddingActors = input.enableActorAutoLoading === true || input.enableActorAutoLoading === 'true';
} else {
input.enableAddingActors = false;
input.enableAddingActors = true;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This simple update changes the logic in apify-mcp-server. When the setting is not set, it's enabled by default. If it is set (by URL or config object), it uses the value as before.

}
} else {
input.enableAddingActors = input.enableAddingActors === true || input.enableAddingActors === 'true';
Expand Down
2 changes: 1 addition & 1 deletion src/mcp/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class ActorsMcpServer {

constructor(options: ActorsMcpServerOptions = {}, setupSigintHandler = true) {
this.options = {
enableAddingActors: options.enableAddingActors ?? false,
enableAddingActors: options.enableAddingActors ?? true,
enableDefaultActors: options.enableDefaultActors ?? true, // Default to true for backward compatibility
};
this.server = new Server(
Expand Down
11 changes: 6 additions & 5 deletions src/stdio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ import { getActorsAsTools } from './tools/index.js';
*/
interface CliArgs {
actors?: string;
'enable-adding-actors'?: boolean;
enableActorAutoLoading?: boolean;
enableAddingActors: boolean;
/** @deprecated */
enableActorAutoLoading: boolean;
}

// Configure logging, set to ERROR
Expand All @@ -50,12 +51,12 @@ const argv = yargs(hideBin(process.argv))
})
.option('enable-adding-actors', {
type: 'boolean',
default: false,
default: true,
describe: 'Enable dynamically adding Actors as tools based on user requests',
})
.option('enableActorAutoLoading', {
type: 'boolean',
default: false,
default: true,
hidden: true,
describe: 'Deprecated: use enable-adding-actors instead',
})
Expand All @@ -69,7 +70,7 @@ const argv = yargs(hideBin(process.argv))
.epilogue('For more information, visit https://github.com/apify/actors-mcp-server')
.parseSync() as CliArgs;

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

Expand Down
12 changes: 6 additions & 6 deletions tests/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export async function createMcpSseClient(
if (actors) {
url.searchParams.append('actors', actors.join(','));
}
if (enableAddingActors) {
url.searchParams.append('enableAddingActors', 'true');
if (enableAddingActors !== undefined) {
url.searchParams.append('enableAddingActors', enableAddingActors.toString());
}

const transport = new SSEClientTransport(
Expand Down Expand Up @@ -59,8 +59,8 @@ export async function createMcpStreamableClient(
if (actors) {
url.searchParams.append('actors', actors.join(','));
}
if (enableAddingActors) {
url.searchParams.append('enableAddingActors', 'true');
if (enableAddingActors !== undefined) {
url.searchParams.append('enableAddingActors', enableAddingActors.toString());
}

const transport = new StreamableHTTPClientTransport(
Expand Down Expand Up @@ -94,8 +94,8 @@ export async function createMcpStdioClient(
if (actors) {
args.push('--actors', actors.join(','));
}
if (enableAddingActors) {
args.push('--enable-adding-actors');
if (enableAddingActors !== undefined) {
args.push('--enable-adding-actors', enableAddingActors.toString());
}
const transport = new StdioClientTransport({
command: 'node',
Expand Down
17 changes: 14 additions & 3 deletions tests/integration/suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,19 @@ export function createIntegrationTestsSuite(
describe(suiteName, {
concurrent: false, // Make all tests sequential to prevent state interference
}, () => {
it('should list all default tools and default Actors', async () => {
it('should list all default tools and Actors', async () => {
const client = await createClientFn();
const tools = await client.listTools();
expect(tools.tools.length).toEqual(defaultTools.length + defaults.actors.length);
expect(tools.tools.length).toEqual(defaultTools.length + defaults.actors.length + addRemoveTools.length);

const names = getToolNames(tools);
expectToolNamesToContain(names, DEFAULT_TOOL_NAMES);
expectToolNamesToContain(names, DEFAULT_ACTOR_NAMES);
expectToolNamesToContain(names, addRemoveTools.map((tool) => tool.tool.name));
await client.close();
});

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

it('should list all default tools and Actors, without add/remove tools', async () => {
const client = await createClientFn({ enableAddingActors: false });
const names = getToolNames(await client.listTools());
expect(names.length).toEqual(defaultTools.length + defaults.actors.length);

expectToolNamesToContain(names, DEFAULT_TOOL_NAMES);
expectToolNamesToContain(names, DEFAULT_ACTOR_NAMES);
await client.close();
});

it('should list all default tools and two loaded Actors', async () => {
const actors = ['apify/website-content-crawler', 'apify/instagram-scraper'];
const client = await createClientFn({ actors, enableAddingActors: false });
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/input.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ describe('processInput', () => {
expect(processed.enableAddingActors).toBe(false);
});

it('should default enableAddingActors to false when not provided', async () => {
it('should default enableAddingActors to true when not provided', async () => {
const input: Partial<Input> = {
actors: ['actor1'],
};
const processed = processInput(input);
expect(processed.enableAddingActors).toBe(false);
expect(processed.enableAddingActors).toBe(true);
});
});