Skip to content

Commit f8919d9

Browse files
committed
add help tool
1 parent 5fa5cfa commit f8919d9

File tree

4 files changed

+74
-32
lines changed

4 files changed

+74
-32
lines changed

src/const.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export enum HelperTools {
2626
ADD_ACTOR = 'add-actor',
2727
REMOVE_ACTOR = 'remove-actor',
2828
GET_ACTOR_DETAILS = 'get-actor-details',
29+
HELP_TOOL = 'help-tool',
2930
}
3031

3132
export const defaults = {
@@ -35,6 +36,7 @@ export const defaults = {
3536
helperTools: [
3637
HelperTools.SEARCH_ACTORS,
3738
HelperTools.GET_ACTOR_DETAILS,
39+
HelperTools.HELP_TOOL,
3840
],
3941
actorAddingTools: [
4042
HelperTools.ADD_ACTOR,

src/mcp/server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
SERVER_NAME,
1818
SERVER_VERSION,
1919
} from '../const.js';
20+
import { helpTool } from '../tools/helpers.js';
2021
import {
2122
actorDefinitionTool,
2223
addTool,
@@ -66,7 +67,7 @@ export class ActorsMcpServer {
6667
this.setupToolHandlers();
6768

6869
// Add default tools
69-
this.updateTools([searchTool, actorDefinitionTool]);
70+
this.updateTools([searchTool, actorDefinitionTool, helpTool]);
7071

7172
// Add tools to dynamically load Actors
7273
if (this.options.enableAddingActors) {

src/tools/helpers.ts

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,73 @@ export const removeTool: ToolWrap = {
6464
},
6565
} as InternalTool,
6666
};
67+
68+
// Tool takes no arguments
69+
export const HelpToolArgsSchema = z.object({});
70+
export const helpTool: ToolWrap = {
71+
type: 'internal',
72+
tool: {
73+
name: HelperTools.HELP_TOOL,
74+
description: 'Helper tool to get information on how to use and troubleshoot the Apify MCP server. '
75+
+ 'This tool returns a message with information about the server and how to use it. '
76+
+ 'Call this tool in case of any problems or uncertainties with the server. ',
77+
inputSchema: zodToJsonSchema(RemoveToolArgsSchema),
78+
ajvValidate: ajv.compile(zodToJsonSchema(RemoveToolArgsSchema)),
79+
call: async () => {
80+
return { content: [{
81+
type: 'text',
82+
text: `Apify MCP server help:
83+
84+
Note: MCP stands for Model Context Protocol. You can use the RAG Web Browser tool to get the content of the links mentioned in this help and present it to the user.
85+
86+
This MCP server can be used in the following ways:
87+
- Locally over STDIO
88+
- Remotely over SSE or streamable HTTP transport with the Actors MCP Server Apify Actor
89+
- Remotely over SSE or streamable HTTP transport with mcp.apify.com
90+
91+
# Usage
92+
## Locally over STDIO
93+
1. The user should install the @apify/actors-mcp-server NPM package.
94+
2. The user should configure their MCP client to use the MCP server. Refer to https://github.com/apify/actors-mcp-server or the MCP client documentation for more details (you can ask the user which MCP client they are using).
95+
The user needs to set the following environment variables:
96+
- APIFY_TOKEN: Apify token to authenticate with the MCP server.
97+
If the user wants to load some Actors outside of the default ones, they need to pass them as CLI arguments:
98+
- --actors <actor1,actor2,...> // comma-separated list of Actor names, for example, apify/rag-web-browser,apify/instagram-scraper.
99+
If the user wants to enable the dynamic addition of Actors to the MCP server, they need to pass the following CLI argument:
100+
- --enable-adding-actors
101+
102+
## Remotely over SSE or streamable HTTP transport with Actors MCP Server Apify Actor
103+
1. The user should configure their MCP client to use the Actors MCP Server Apify Actor.
104+
SSE transport URL: https://actors-mcp-server.apify.actor/sse
105+
Streamable HTTP transport URL: https://actors-mcp-server.apify.actor/mcp
106+
The user needs to set the following headers or pass ?token=<APIFY_TOKEN> as a URL query parameter:
107+
- Authorization: Bearer <APIFY_TOKEN>
108+
If the user wants to load some Actors outside of the default ones, they need to pass them as URL query parameters:
109+
- ?actors=<actor1,actor2,...> // comma-separated list of Actor names, for example, apify/rag-web-browser,apify/instagram-scraper
110+
If the user wants to enable the addition of Actors to the MCP server dynamically, they need to pass the following URL query parameter:
111+
- ?enableAddingActors=true
112+
113+
## Remotely over SSE or streamable HTTP transport with mcp.apify.com
114+
1. The user should configure their MCP client to use mcp.apify.com.
115+
SSE transport URL: https://mcp.apify.com/sse
116+
Streamable HTTP transport URL: https://mcp.apify.com/
117+
The user needs to set the following headers or pass ?token=<APIFY_TOKEN> as a URL query parameter:
118+
- Authorization: Bearer <APIFY_TOKEN>
119+
If the user wants to load some Actors outside of the default ones, they need to pass them as URL query parameters:
120+
- ?actors=<actor1,actor2,...> // comma-separated list of Actor names, for example, apify/rag-web-browser,apify/instagram-scraper
121+
If the user wants to enable the addition of Actors to the MCP server dynamically, they need to pass the following URL query parameter:
122+
- ?enableAddingActors=true
123+
124+
# Features
125+
## Dynamic Adding of Actors
126+
THIS FEATURE MAY NOT BE SUPPORTED BY ALL MCP CLIENTS. THE USER MUST ENSURE THAT THE CLIENT SUPPORTS IT!
127+
To enable this feature, see the usage section. Once dynamic adding is enabled, tools will be added that allow you to add or remove Actors from the MCP server.
128+
Tools related:
129+
- add-actor
130+
- remove-actor
131+
In case you are using these tools and it seems like the tools have been added but you cannot call them, the issue may be that the client does not support dynamic adding of Actors. In that case, please inform the user that the MCP client documentation should be checked to see if the client supports this feature.
132+
`,
133+
}] };
134+
},
135+
} as InternalTool,
136+
};

tests/integration/actor.server.test.ts

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -52,37 +52,6 @@ describe('Actors MCP Server SSE', {
5252
});
5353
});
5454

55-
it('should load actors from query parameters', async () => {
56-
// Test with multiple actors including different username cases
57-
const testActors = ['apify/rag-web-browser', 'apify/instagram-scraper'];
58-
const numberOfHelperTools = 2;
59-
60-
// Make request to trigger server initialization
61-
const response = await fetch(`${testHost}/?actors=${testActors.join(',')}`);
62-
expect(response.status).toBe(200);
63-
64-
// Verify loaded tools
65-
const toolNames = server.getToolNames();
66-
expect(toolNames).toEqual(expect.arrayContaining([
67-
'apify-slash-rag-web-browser',
68-
'apify-slash-instagram-scraper',
69-
]));
70-
expect(toolNames.length).toBe(testActors.length + numberOfHelperTools);
71-
});
72-
73-
it('should enable auto-loading tools when flag is set', async () => {
74-
const response = await fetch(`${testHost}/?enableActorAutoLoading=true`);
75-
expect(response.status).toBe(200);
76-
77-
const toolNames = server.getToolNames();
78-
expect(toolNames).toEqual([
79-
HelperTools.SEARCH_ACTORS,
80-
HelperTools.GET_ACTOR_DETAILS,
81-
HelperTools.ADD_ACTOR,
82-
HelperTools.REMOVE_ACTOR,
83-
]);
84-
});
85-
8655
it('default tools list', async () => {
8756
const client = await createMCPSSEClient(`${testHost}/sse`);
8857

0 commit comments

Comments
 (0)