Skip to content

Commit a4a8638

Browse files
MQ37jirispilka
andauthored
feat(input): allow empty tools and actors to allow greater control of exposed tools (#218)
* feat(input): allow empty tools and actors to allow greater control of exposed tools * revert internals * more robust input processing * fix(docs): update tool categories and add usage notes in README * fix(manifest): update default values for tool categories and dynamic Actor adding * feat: implement the new internal MCP configuration spec (#226) * feat: refactor and unify input handling, remove unnecessary logic * feat: vibe new mcp input spec * fix: remove unnecessary addTool in mcp/server.ts * fix: fix stdio.only add-actor tool related circular dependency cause by import of getActorsAsTools and pass it as internal tool arg instead. * fix test suite, clean up * fix tests and logic to adhere to the new spec * refactor code * lint * rename to fetch-actor-details * improve readme * update stdio help * improve test case names * fix and improve the call-actor generic tool * more spec new spec complience tests * lint * one more test, just in case * address pr comment and refactor the process input func * fix: Delete example clients, update Readme (#239) fix: Delete clients (in examples). They are not used and outdated anyway. Also update README.md * Update tests/unit/input.test.ts Co-authored-by: Jiří Spilka <[email protected]> * Update tests/unit/input.test.ts Co-authored-by: Jiří Spilka <[email protected]> * Update README.md Co-authored-by: Jiří Spilka <[email protected]> * address review comments * clean up imports and update comments for clarity, export functions for internal repo --------- Co-authored-by: Jiří Spilka <[email protected]> * update dxt manifest --------- Co-authored-by: Jiří Spilka <[email protected]>
1 parent 6216fa4 commit a4a8638

31 files changed

+1059
-1201
lines changed

README.md

Lines changed: 80 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -140,43 +140,106 @@ One of the most powerful features of using MCP with Apify is dynamic tool discov
140140
It gives an AI agent the ability to find new tools (Actors) as needed and incorporate them.
141141
Here are some special MCP operations and how the Apify MCP Server supports them:
142142

143-
- **Actor discovery and management**: Search for Actors, view their details, and dynamically add or remove them as available tools for the AI.
143+
- **Apify Actors**: Search for Actors, view their details, and use them as tools for the AI.
144144
- **Apify documentation**: Search the Apify documentation and fetch specific documents to provide context to the AI.
145-
- **Actor runs (*)**: Get lists of your Actor runs, inspect their details, and retrieve logs.
146-
- **Apify storage (*)**: Access data from your datasets and key-value stores.
147-
148-
**Note**: Helper tool categories marked with (*) are not enabled by default in the MCP server and must be explicitly enabled using the `tools` argument (either the `--tools` command line argument for the stdio server or the `?tools` URL query parameter for the remote MCP server). The `tools` argument is a comma-separated list of categories with the following possible values:
149-
150-
- `docs`: Search and fetch Apify documentation tools.
151-
- `runs`: Get Actor run lists, run details, and logs from a specific Actor run.
152-
- `storage`: Access datasets, key-value stores, and their records.
153-
- `preview`: Experimental tools in preview mode.
154-
155-
For example, to enable all tools, use `npx @apify/actors-mcp-server --tools docs,runs,storage,preview` or `https://mcp.apify.com/?tools=docs,runs,storage,preview`.
145+
- **Actor runs**: Get lists of your Actor runs, inspect their details, and retrieve logs.
146+
- **Apify storage**: Access data from your datasets and key-value stores.
156147

157148
### Overview of available tools
158149

159150
Here is an overview list of all the tools provided by the Apify MCP Server.
160151

161152
| Tool name | Category | Description | Enabled by default |
162153
| :--- | :--- | :--- | :---: |
163-
| `get-actor-details` | default | Retrieve detailed information about a specific Actor. ||
164-
| `search-actors` | default | Search for Actors in the Apify Store. ||
165-
| `add-actor` | default | Add an Actor as a new tool for the user to call. ||
166-
| [`apify-slash-rag-web-browser`](https://apify.com/apify/rag-web-browser) | default | An Actor tool to browse the web. ||
154+
| `search-actors` | actors | Search for Actors in the Apify Store. ||
155+
| `fetch-actor-details` | actors | Retrieve detailed information about a specific Actor. ||
156+
| `call-actor` | actors | Call an Actor and get its run results. ||
157+
| [`apify-slash-rag-web-browser`](https://apify.com/apify/rag-web-browser) | Actor (see [tool configuration](#tools-configuration)) | An Actor tool to browse the web. ||
167158
| `search-apify-docs` | docs | Search the Apify documentation for relevant pages. ||
168159
| `fetch-apify-docs` | docs | Fetch the full content of an Apify documentation page by its URL. ||
169-
| `call-actor` | preview | Call an Actor and get its run results. | |
170160
| `get-actor-run` | runs | Get detailed information about a specific Actor run. | |
171161
| `get-actor-run-list` | runs | Get a list of an Actor's runs, filterable by status. | |
172162
| `get-actor-log` | runs | Retrieve the logs for a specific Actor run. | |
173163
| `get-dataset` | storage | Get metadata about a specific dataset. | |
174164
| `get-dataset-items` | storage | Retrieve items from a dataset with support for filtering and pagination. | |
165+
| `get-dataset-schema` | storage | Generate a JSON schema from dataset items. | |
175166
| `get-key-value-store` | storage | Get metadata about a specific key-value store. | |
176167
| `get-key-value-store-keys`| storage | List the keys within a specific key-value store. | |
177168
| `get-key-value-store-record`| storage | Get the value associated with a specific key in a key-value store. | |
178169
| `get-dataset-list` | storage | List all available datasets for the user. | |
179170
| `get-key-value-store-list`| storage | List all available key-value stores for the user. | |
171+
| `add-actor` | experimental | Add an Actor as a new tool for the user to call. | |
172+
173+
### Tools configuration
174+
175+
The `tools` configuration parameter is used to specify loaded tools - either categories or specific tools directly, and Apify Actors. For example, `tools=storage,runs` loads two categories; `tools=add-actor` loads just one tool.
176+
177+
When no query parameters are provided, the MCP server loads the following `tools` by default:
178+
179+
- `actors`
180+
- `docs`
181+
- `apify/rag-web-browser`
182+
183+
If the tools parameter is specified, only the listed tools or categories will be enabled - no default tools will be included.
184+
185+
> **Easy configuration:**
186+
>
187+
> Use the [UI configurator](https://mcp.apify.com/) to configure your server, then copy the configuration to your client.
188+
189+
**Configuring the hosted server:**
190+
191+
The hosted server can be configured using query parameters in the URL. For example, to load the default tools, use:
192+
193+
```
194+
https://mcp.apify.com?tools=actors,docs,apify/rag-web-browser
195+
```
196+
197+
For minimal configuration, if you want to use only a single Actor tool - without any discovery or generic calling tools, the server can be configured as follows:
198+
199+
```
200+
https://mcp.apify.com?tools=apify/my-actor
201+
```
202+
203+
This setup exposes only the specified Actor (`apify/my-actor`) as a tool. No other tools will be available.
204+
205+
**Configuring the CLI:**
206+
207+
The CLI can be configured using command-line flags. For example, to load the same tools as in the hosted server configuration, use:
208+
209+
```bash
210+
npx @apify/actors-mcp-server --tools actors,docs,apify/rag-web-browser
211+
```
212+
213+
The minimal configuration is similar to the hosted server configuration:
214+
215+
```bash
216+
npx @apify/actors-mcp-server --tools apify/my-actor
217+
```
218+
219+
As above, this exposes only the specified Actor (`apify/my-actor`) as a tool. No other tools will be available.
220+
221+
> **⚠️ Important recommendation**
222+
>
223+
> **The default tools configuration may change in future versions.** When no `tools` parameter is specified, the server currently loads default tools, but this behavior is subject to change.
224+
>
225+
> **For production use and stable interfaces, always explicitly specify the `tools` parameter** to ensure your configuration remains consistent across updates.
226+
227+
### Backward compatibility
228+
229+
The v2 configuration preserves backward compatibility with v1 usage. Notes:
230+
231+
- `actors` param (URL) and `--actors` flag (CLI) are still supported.
232+
- Internally they are merged into `tools` selectors.
233+
- Examples: `?actors=apify/rag-web-browser``?tools=apify/rag-web-browser`; `--actors apify/rag-web-browser``--tools apify/rag-web-browser`.
234+
- `enable-adding-actors` (CLI) and `enableAddingActors` (URL) are supported but deprecated.
235+
- Prefer `tools=experimental` or including the specific tool `tools=add-actor`.
236+
- Behavior remains: when enabled with no `tools` specified, the server exposes only `add-actor`; when categories/tools are selected, `add-actor` is also included.
237+
- `enableActorAutoLoading` remains as a legacy alias for `enableAddingActors` and is mapped automatically.
238+
- Defaults remain compatible: when no `tools` are specified, the server loads `actors`, `docs`, and `apify/rag-web-browser`.
239+
- If any `tools` are specified, the defaults are not added (same as v1 intent for explicit selection).
240+
- `call-actor` is now included by default via the `actors` category (additive change). To exclude it, specify an explicit `tools` list without `actors`.
241+
242+
Existing URLs and commands using `?actors=...` or `--actors` continue to work unchanged.
180243

181244
### Prompts
182245

manifest.json

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"dxt_version": "0.1",
33
"name": "apify-mcp-server",
4-
"version": "0.3.9",
4+
"version": "0.4.0",
55
"description": "Extract data from any site with Apify Store, home to thousands of web scrapers.",
66
"long_description": "Apify is the world's largest marketplace of tools for web scraping, data extraction, and web automation. You can extract structured data from social media, e-commerce, search engines, maps, travel sites, or any other website.",
77
"keywords": [
@@ -42,11 +42,7 @@
4242
"args": [
4343
"${__dirname}/dist/stdio.js",
4444
"--tools",
45-
"${user_config.tools}",
46-
"--actors",
47-
"${user_config.actors}",
48-
"--enable-adding-actors",
49-
"${user_config.enable-adding-actors}"
45+
"${user_config.tools}"
5046
],
5147
"env": {
5248
"APIFY_TOKEN": "${user_config.apify_token}"
@@ -64,23 +60,10 @@
6460
},
6561
"tools": {
6662
"type": "string",
67-
"title": "Enabled tool categories",
68-
"description": "A comma-separated list of tool categories to enable. Available options: docs, runs, storage, preview.",
63+
"title": "Enabled tools",
64+
"description": "Comma-separated list of tools to enable. Can be either a tool category, a specific tool, or an Apify Actor. For example: \"actors,docs,apify/rag-web-browser\". For more details visit https://mcp.apify.com.",
6965
"required": false,
70-
"default": "docs"
71-
},
72-
"actors": {
73-
"type": "string",
74-
"title": "Enabled Actors",
75-
"description": "A comma-separated list of full Actor names to add to the server on startup (e.g., apify/rag-web-browser).",
76-
"required": false,
77-
"default": "apify/rag-web-browser"
78-
},
79-
"enable-adding-actors": {
80-
"type": "boolean",
81-
"title": "Enable dynamic Actor adding",
82-
"description": "Allow dynamically adding Actors as tools based on user requests during a session.",
83-
"default": true
66+
"default": "actors,docs,apify/rag-web-browser"
8467
}
8568
},
8669
"compatibility": {

src/actor/server.ts

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,11 @@ import express from 'express';
1212
import log from '@apify/log';
1313

1414
import { ActorsMcpServer } from '../mcp/server.js';
15-
import { parseInputParamsFromUrl } from '../mcp/utils.js';
1615
import { getHelpMessage, HEADER_READINESS_PROBE, Routes, TransportType } from './const.js';
1716
import { getActorRunData } from './utils.js';
1817

1918
export function createExpressApp(
2019
host: string,
21-
mcpServerOptions: {
22-
enableAddingActors?: boolean;
23-
enableDefaultActors?: boolean;
24-
actors?: string[];
25-
},
2620
): express.Express {
2721
const app = express();
2822
const mcpServers: { [sessionId: string]: ActorsMcpServer } = {};
@@ -75,21 +69,13 @@ export function createExpressApp(
7569
rt: Routes.SSE,
7670
tr: TransportType.SSE,
7771
});
78-
const mcpServer = new ActorsMcpServer(mcpServerOptions, false);
72+
const mcpServer = new ActorsMcpServer(false);
7973
const transport = new SSEServerTransport(Routes.MESSAGE, res);
8074

8175
// Load MCP server tools
8276
const apifyToken = process.env.APIFY_TOKEN as string;
83-
const input = parseInputParamsFromUrl(req.url);
84-
if (input.actors || input.enableAddingActors || input.tools) {
85-
log.debug('Loading tools from URL', { sessionId: transport.sessionId, tr: TransportType.SSE });
86-
await mcpServer.loadToolsFromUrl(req.url, apifyToken);
87-
}
88-
// Load default tools if no actors are specified
89-
if (!input.actors) {
90-
log.debug('Loading default tools', { sessionId: transport.sessionId, tr: TransportType.SSE });
91-
await mcpServer.loadDefaultActors(apifyToken);
92-
}
77+
log.debug('Loading tools from URL', { sessionId: transport.sessionId, tr: TransportType.SSE });
78+
await mcpServer.loadToolsFromUrl(req.url, apifyToken);
9379

9480
transportsSSE[transport.sessionId] = transport;
9581
mcpServers[transport.sessionId] = mcpServer;
@@ -166,20 +152,12 @@ export function createExpressApp(
166152
sessionIdGenerator: () => randomUUID(),
167153
enableJsonResponse: false, // Use SSE response mode
168154
});
169-
const mcpServer = new ActorsMcpServer(mcpServerOptions, false);
155+
const mcpServer = new ActorsMcpServer(false);
170156

171157
// Load MCP server tools
172158
const apifyToken = process.env.APIFY_TOKEN as string;
173-
const input = parseInputParamsFromUrl(req.url);
174-
if (input.actors || input.enableAddingActors || input.tools) {
175-
log.debug('Loading tools from URL', { sessionId: transport.sessionId, tr: TransportType.HTTP });
176-
await mcpServer.loadToolsFromUrl(req.url, apifyToken);
177-
}
178-
// Load default tools if no actors are specified
179-
if (!input.actors) {
180-
log.debug('Loading default tools', { sessionId: transport.sessionId, tr: TransportType.HTTP });
181-
await mcpServer.loadDefaultActors(apifyToken);
182-
}
159+
log.debug('Loading tools from URL', { sessionId: transport.sessionId, tr: TransportType.HTTP });
160+
await mcpServer.loadToolsFromUrl(req.url, apifyToken);
183161

184162
// Connect the transport to the MCP server BEFORE handling the request
185163
await mcpServer.connect(transport);

src/const.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export enum HelperTools {
1919
ACTOR_ADD = 'add-actor',
2020
ACTOR_CALL = 'call-actor',
2121
ACTOR_GET = 'get-actor',
22-
ACTOR_GET_DETAILS = 'get-actor-details',
22+
ACTOR_GET_DETAILS = 'fetch-actor-details',
2323
ACTOR_REMOVE = 'remove-actor',
2424
ACTOR_RUNS_ABORT = 'abort-actor-run',
2525
ACTOR_RUNS_GET = 'get-actor-run',

src/examples/clientSse.ts

Lines changed: 0 additions & 120 deletions
This file was deleted.

0 commit comments

Comments
 (0)