From 52f4b735a57c2644babc8f441b8611641342d87f Mon Sep 17 00:00:00 2001 From: Jiri Spilka Date: Fri, 31 Jan 2025 13:41:43 +0100 Subject: [PATCH 1/2] fix: Actor auto loading --- README.md | 4 ++-- src/main.ts | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4c0ddeb..ad6ecc7 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,8 @@ The server provides a set of helper tools to discover available Actors and retri There are also tools to manage the available tools list. However, dynamically adding and removing tools requires the MCP client to have the capability to manage the tools list, which is typically not supported. -You can try this functionality using the [Apify Tester MCP Client](https://apify.com/jiri.spilka/tester-mcp-client) Actor. To enable it, set the `enableActorAutoLoading` parameter. +You can try this functionality using the [Apify Tester MCP Client](https://apify.com/jiri.spilka/tester-mcp-client) Actor. +To enable it, set the `enableActorAutoLoading` parameter. - `add-actor-as-tool`: Adds an Actor by name to the available tools list without executing it, requiring user consent to run later. - `remove-actor-from-tool`: Removes an Actor by name from the available tools list when it's no longer needed. @@ -206,7 +207,6 @@ Alternatively, you can use simple python [client_see.py](https://github.com/apif ### Install -Follow the steps below to set up and run the server on your local machine: First, clone the repository using the following command: ```bash diff --git a/src/main.ts b/src/main.ts index 99fc2c8..00797f9 100644 --- a/src/main.ts +++ b/src/main.ts @@ -45,10 +45,12 @@ async function processParamsAndUpdateTools(url: string) { const input = await processInput(params as unknown as Input); if (input.actors) { await mcpServer.addToolsFromActors(input.actors as string[]); - } else { - log.debug(`Server is running in STANDBY mode with the following Actors (tools): ${mcpServer.getToolNames()}. - To use different Actors, provide them in query parameter "actors" or include them in the Actor Task input.`); } + if (input.enableActorAutoLoading) { + mcpServer.updateTools(getActorAutoLoadingTools()); + } + log.debug(`Server is running in STANDBY mode with the following Actors (tools): ${mcpServer.getToolNames()}. + To use different Actors, provide them in query parameter "actors" or include them in the Actor Task input.`); } app.route(Routes.ROOT) From a8882d7add722116200510c109fa541842dee76e Mon Sep 17 00:00:00 2001 From: Jiri Spilka Date: Fri, 31 Jan 2025 15:07:47 +0100 Subject: [PATCH 2/2] fix: actor to tool name --- src/actors.ts | 9 ++------- src/server.ts | 4 ++-- src/tools.ts | 6 +++--- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/actors.ts b/src/actors.ts index 807edf5..6542227 100644 --- a/src/actors.ts +++ b/src/actors.ts @@ -3,12 +3,7 @@ import { ApifyClient } from 'apify-client'; import { ACTOR_ADDITIONAL_INSTRUCTIONS, defaults, MAX_DESCRIPTION_LENGTH } from './const.js'; import { log } from './logger.js'; -import type { - ActorDefinitionPruned, - ActorDefinitionWithDesc, - SchemaProperties, - Tool, -} from './types.js'; +import type { ActorDefinitionPruned, ActorDefinitionWithDesc, SchemaProperties, Tool } from './types.js'; export function actorNameToToolName(actorName: string): string { return actorName.replace('/', '--'); @@ -59,7 +54,7 @@ export async function getActorDefinition(actorFullName: string): Promise actorNameToToolName(val)), + .transform((val) => toolNameToActorName(val)), }); export const AddActorToToolsArgsSchema = z.object({ actorFullName: z.string() .describe('Full name of the Actor to add as tool. Tool name is always composed from `username--name`' + 'Never use name or username only') - .transform((val) => actorNameToToolName(val)), + .transform((val) => toolNameToActorName(val)), }); export const GetActorDefinition = z.object({