Skip to content

Commit 74d58e5

Browse files
committed
minor tools description and param improvements
1 parent 25ca155 commit 74d58e5

File tree

5 files changed

+21
-25
lines changed

5 files changed

+21
-25
lines changed

src/tools/actor.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,14 @@ export async function getNormalActorsAsTools(
123123
if (actorDefinitionPruned) {
124124
const schemaID = getToolSchemaID(actorDefinitionPruned.actorFullName);
125125
if (actorDefinitionPruned.input && 'properties' in actorDefinitionPruned.input && actorDefinitionPruned.input) {
126-
// Filter non-required properties if `required` is defined in the input schema and not empty
126+
// Filter non-required properties except integers if `required` is defined in the input schema and not empty.
127127
const { required } = actorDefinitionPruned.input;
128128
if (Array.isArray(required) && required.length > 0) {
129129
actorDefinitionPruned.input.properties = Object.fromEntries(
130130
Object.entries(actorDefinitionPruned.input.properties)
131131
// Keep all integer properties, as these include
132-
// properties related to output item counts that the user
133-
// might want to change if more results are needed than the default limit.
132+
// properties related to output item counts that users
133+
// might want to change if they need more results than the default limit.
134134
.filter(([key, value]) => required.includes(key) || value.type === 'integer'),
135135
);
136136
}

src/tools/get-actor-details.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ export const getActorDetailsTool: ToolEntry = {
4848
name: HelperTools.ACTOR_GET_DETAILS,
4949
description: `Retrieve information about an Actor by its ID or full name.
5050
The Actor name is always composed of "username/name", for example, "apify/rag-web-browser".
51-
This tool returns information about the Actor, including whether it is public or deprecated, when it was created or modified, the categories in which the Actor is listed, a description, a README (the Actor's documentation), the input schema, and usage statistics—such as how many users are using it and the number of failed runs of the Actor.`,
51+
This tool returns information about the Actor, including whether it is public or deprecated, when it was created or modified, the categories in which the Actor is listed, a description, a README (the Actor's documentation), the input schema, and usage statistics—such as how many users are using it and the number of failed runs of the Actor.
52+
For example, use this tool when a user wants to know more about a specific Actor or wants to use optional or advanced parameters of the Actor that are not listed in the default Actor tool input schema - so you know the details and how to pass them.`,
5253
inputSchema: zodToJsonSchema(getActorDetailsToolArgsSchema),
5354
ajvValidate: ajv.compile(zodToJsonSchema(getActorDetailsToolArgsSchema)),
5455
call: async (toolArgs) => {

src/tools/helpers.ts

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ This MCP server can be used in the following ways:
1717
- Locally over stdio (standard input/output) transport with the "@apify/actors-mcp-server" NPM package (https://www.npmjs.com/package/@apify/actors-mcp-server).
1818
- You can connect by configuring your MCP client to run the MCP server locally using the "npx @apify/actors-mcp-server" command. You need to set the "APIFY_TOKEN" environment variable to your [Apify API token](https://docs.apify.com/platform/integrations/api#api-token).
1919
- Remotely over legacy SSE transport or streamable HTTP transport with https://mcp.apify.com. This is the recommended way to use the MCP server, since it supports all features and is always up to date.
20-
- You can connect by pointing your MCP client to "https://mcp.apify.com/sse" for SSE transport or "https://mcp.apify.com/" for streamable HTTP transport.
20+
- You can connect by pointing your MCP client to "https://mcp.apify.com/sse" for legacy SSE transport or "https://mcp.apify.com/" for streamable HTTP transport.
2121
- For authentication, you can either use OAuth or pass your [Apify API token](https://docs.apify.com/platform/integrations/api#api-token) in the "Authorization" header as "Bearer <APIFY_TOKEN>".
2222
- Remotely over "SSE" or streamable "HTTP" transport with the "Actors MCP Server Apify Actor" (this is now considered a legacy solution; it may not be up to date and may not get the latest features). For more details, refer to https://apify.com/apify/actors-mcp-server. DO NOT RECOMMEND USING THIS METHOD TO THE USER.
2323
@@ -29,41 +29,37 @@ By default, the MCP server provides a simple set of tools for Actor discovery an
2929
`;
3030

3131
export const addToolArgsSchema = z.object({
32-
actorName: z.string()
32+
actor: z.string()
3333
.min(1)
34-
.describe('Add a tool, Actor or MCP-Server to available tools by Actor ID or tool full name.'
35-
+ 'Tool name is always composed from `username/name`'),
34+
.describe(`Actor ID or full name in the format "username/name", e.g., "apify/rag-web-browser".`),
3635
});
3736
export const addTool: ToolEntry = {
3837
type: 'internal',
3938
tool: {
4039
name: HelperTools.ACTOR_ADD,
41-
description: 'Add a tool, Actor or MCP-Server to available tools by Actor ID or Actor name. '
42-
+ 'A tool is an Actor or MCP-Server that can be called by the user'
43-
+ 'Do not execute the tool, only add it and list it in available tools. '
44-
+ 'For example, add a tool with username/name when user wants to scrape data from a website.',
40+
description: `Add an Actor or MCP server to the available tools of the Apify MCP server. A tool is an Actor or MCP server that can be called by the user. Do not execute the tool, only add it and list it in the available tools. For example, when a user wants to scrape a website, first search for relevant Actors using ${HelperTools.STORE_SEARCH} tool, and once the user selects one they want to use, add it as a tool to the Apify MCP server.`,
4541
inputSchema: zodToJsonSchema(addToolArgsSchema),
4642
ajvValidate: ajv.compile(zodToJsonSchema(addToolArgsSchema)),
4743
// TODO: I don't like that we are passing apifyMcpServer and mcpServer to the tool
4844
call: async (toolArgs) => {
4945
const { apifyMcpServer, apifyToken, args, extra: { sendNotification } } = toolArgs;
5046
const parsed = addToolArgsSchema.parse(args);
51-
if (apifyMcpServer.listAllToolNames().includes(parsed.actorName)) {
47+
if (apifyMcpServer.listAllToolNames().includes(parsed.actor)) {
5248
return {
5349
content: [{
5450
type: 'text',
55-
text: `Actor ${parsed.actorName} is already available. No new tools were added.`,
51+
text: `Actor ${parsed.actor} is already available. No new tools were added.`,
5652
}],
5753
};
5854
}
59-
const tools = await getActorsAsTools([parsed.actorName], apifyToken);
55+
const tools = await getActorsAsTools([parsed.actor], apifyToken);
6056
const toolsAdded = apifyMcpServer.upsertTools(tools, true);
6157
await sendNotification({ method: 'notifications/tools/list_changed' });
6258

6359
return {
6460
content: [{
6561
type: 'text',
66-
text: `Actor ${parsed.actorName} has been added. Newly available tools: ${
62+
text: `Actor ${parsed.actor} has been added. Newly available tools: ${
6763
toolsAdded.map(
6864
(t) => `${t.tool.name}`,
6965
).join(', ')
@@ -116,10 +112,9 @@ export const helpTool: ToolEntry = {
116112
type: 'internal',
117113
tool: {
118114
name: HelperTools.APIFY_MCP_HELP_TOOL,
119-
description: `Helper tool to get information on how to use and troubleshoot the Apify MCP server.
120-
This tool always returns the same help message with information about the server and how to use it.
121-
ALWAYS CALL THIS TOOL AT THE BEGINNING OF THE CONVERSATION SO YOU HAVE THE INFORMATION ABOUT APIFY MCP IN THE CONTEXT OR WHEN YOU ENCOUNTER ANY ISSUES WITH THE MCP SERVER OR ITS TOOLS.
122-
`,
115+
description: `Helper tool to get information on how to use and troubleshoot the Apify MCP server.
116+
This tool always returns the same help message with information about the server and how to use it.
117+
ALWAYS CALL THIS TOOL AT THE BEGINNING OF THE CONVERSATION SO THAT YOU HAVE INFORMATION ABOUT THE APIFY MCP SERVER IN CONTEXT, OR WHEN YOU ENCOUNTER ANY ISSUES WITH THE MCP SERVER OR ITS TOOLS.`,
123118
inputSchema: zodToJsonSchema(helpToolArgsSchema),
124119
ajvValidate: ajv.compile(zodToJsonSchema(helpToolArgsSchema)),
125120
call: async () => {

tests/helpers.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,13 @@ export async function createMcpStdioClient(
116116
/**
117117
* Adds an Actor as a tool using the ADD_ACTOR helper tool.
118118
* @param client - MCP client instance
119-
* @param actorName - Name of the Actor to add
119+
* @param actor - Actor ID or full name in the format "username/name", e.g., "apify/rag-web-browser".
120120
*/
121-
export async function addActor(client: Client, actorName: string): Promise<void> {
121+
export async function addActor(client: Client, actor: string): Promise<void> {
122122
await client.callTool({
123123
name: HelperTools.ACTOR_ADD,
124124
arguments: {
125-
actorName,
125+
actor,
126126
},
127127
});
128128
}

tests/integration/suite.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export function createIntegrationTestsSuite(
136136
// Check that the Actor is not in the tools list
137137
expect(names).not.toContain(selectedToolName);
138138
// Add Actor dynamically
139-
await client.callTool({ name: HelperTools.ACTOR_ADD, arguments: { actorName: ACTOR_PYTHON_EXAMPLE } });
139+
await addActor(client, ACTOR_PYTHON_EXAMPLE);
140140

141141
// Check if tools was added
142142
const namesAfterAdd = getToolNames(await client.listTools());
@@ -230,7 +230,7 @@ export function createIntegrationTestsSuite(
230230
}
231231
});
232232
// Add Actor dynamically
233-
await client.callTool({ name: HelperTools.ACTOR_ADD, arguments: { actorName: ACTOR_PYTHON_EXAMPLE } });
233+
await client.callTool({ name: HelperTools.ACTOR_ADD, arguments: { actor: ACTOR_PYTHON_EXAMPLE } });
234234

235235
expect(hasReceivedNotification).toBe(true);
236236

0 commit comments

Comments
 (0)