Skip to content

Commit fa5a747

Browse files
MQ37jirispilka
andauthored
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]>
1 parent fee4ff7 commit fa5a747

29 files changed

+955
-1146
lines changed

README.md

Lines changed: 79 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -140,47 +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` | actor-discovery | Retrieve detailed information about a specific Actor. ||
164-
| `search-actors` | actor-discovery | Search for Actors in the Apify Store. ||
165-
| `add-actor` | default (see note below) | 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) | Actor (see note below) | 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`.
180241

181-
> **Note:**
182-
> The `add-actor` tool is always enabled by default and does not explicitly belong to any category. Currently, it can be disabled by setting `?enableAddingActors=false` or `--enable-adding-actors false`.
183-
> The `apify-slash-rag-web-browser` is an Apify Actor tool loaded by default. You can disable it by loading a different set of Actors using `?actors=other/actor` or `--actors other/actor`, or you can disable pre-loading of Actors by setting `?actors=` or `--actors=` (to an empty string).
242+
Existing URLs and commands using `?actors=...` or `--actors` continue to work unchanged.
184243

185244
### Prompts
186245

src/actor/server.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ import { getActorRunData } from './utils.js';
1717

1818
export function createExpressApp(
1919
host: string,
20-
mcpServerOptions: {
21-
enableAddingActors?: boolean;
22-
enableDefaultActors?: boolean;
23-
actors?: string[];
24-
},
2520
): express.Express {
2621
const app = express();
2722
const mcpServers: { [sessionId: string]: ActorsMcpServer } = {};
@@ -74,7 +69,7 @@ export function createExpressApp(
7469
rt: Routes.SSE,
7570
tr: TransportType.SSE,
7671
});
77-
const mcpServer = new ActorsMcpServer(mcpServerOptions, false);
72+
const mcpServer = new ActorsMcpServer(false);
7873
const transport = new SSEServerTransport(Routes.MESSAGE, res);
7974

8075
// Load MCP server tools
@@ -157,7 +152,7 @@ export function createExpressApp(
157152
sessionIdGenerator: () => randomUUID(),
158153
enableJsonResponse: false, // Use SSE response mode
159154
});
160-
const mcpServer = new ActorsMcpServer(mcpServerOptions, false);
155+
const mcpServer = new ActorsMcpServer(false);
161156

162157
// Load MCP server tools
163158
const apifyToken = process.env.APIFY_TOKEN as string;

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.

src/examples/clientStdio.ts

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

0 commit comments

Comments
 (0)