|
1 | 1 | # Apify Model Context Protocol (MCP) Server |
2 | 2 |
|
| 3 | +> **⚠️ Legacy solution notice** |
| 4 | +> This Actor is legacy implementation of the Apify MCP Server. For the current and actively maintained solution, please visit **[mcp.apify.com](https://mcp.apify.com)** where you'll find the latest server, comprehensive documentation, and setup guides. |
| 5 | +
|
3 | 6 | [](https://apify.com/apify/actors-mcp-server) |
4 | | -[](https://smithery.ai/server/@apify/actors-mcp-server) |
5 | 7 |
|
6 | 8 | Implementation of an MCP server for all [Apify Actors](https://apify.com/store). |
7 | 9 | This server enables interaction with one or more Apify Actors that can be defined in the MCP Server configuration. |
@@ -92,18 +94,13 @@ When a tool is called, the arguments are automatically passed to the Actor by th |
92 | 94 | You can refer to the specific Actor's documentation for a list of available arguments. |
93 | 95 |
|
94 | 96 | ### Helper tools |
| 97 | +One of the powerful features of MCP with Apify is dynamic actor tooling – the ability for an AI agent to find new tools (Actors) as needed and incorporate them. Here are some special MCP operations and how Apify MCP Server supports them: |
95 | 98 |
|
96 | | -The server provides a set of helper tools to discover available Actors and retrieve their details: |
97 | | -- `get-actor-details`: Retrieves documentation, input schema, and details about a specific Actor. |
98 | | -- `discover-actors`: Searches for relevant Actors using keywords and returns their details. |
99 | | - |
100 | | -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 update the tools list (handle `ToolListChangedNotificationSchema`), which is typically not supported. |
101 | | - |
102 | | -You can try this functionality using the [Apify Tester MCP Client](https://apify.com/jiri.spilka/tester-mcp-client) Actor. |
103 | | -To enable it, set the `enableAddingActors` parameter. |
104 | | - |
105 | | -- `add-actor-as-tool`: Adds an Actor by name to the available tools list without executing it, requiring user consent to run later. |
106 | | -- `remove-actor-from-tool`: Removes an Actor by name from the available tools list when it's no longer needed. |
| 99 | +- Actor discovery and management: Search for Actors (`search-actors`), view details (`get-actor-details`), and dynamically add or remove tools (`add-actor`, `remove-actor`). |
| 100 | +- Actor execution and monitoring: Start Actor runs, fetch run results (`get-actor-run`), logs (`get-actor-log`), and abort runs (`abort-actor-run`). |
| 101 | +- Dataset access: List datasets, retrieve dataset info and items (`get-dataset`, `get-dataset-list`, `get-dataset-items`). |
| 102 | +- Key-value store access: List key-value stores, view keys, and retrieve records (`get-key-value-store-list`, `get-key-value-store`, `get-key-value-store-keys`, `get-key-value-store-record`). |
| 103 | +- Built-in help tool: A static helper (`apify-actor-help-tool`) that returns usage info for the Apify MCP Server. |
107 | 104 |
|
108 | 105 | ## Prompt & Resources |
109 | 106 |
|
@@ -157,44 +154,6 @@ In the client settings, you need to provide server configuration: |
157 | 154 | } |
158 | 155 | } |
159 | 156 | ``` |
160 | | -Alternatively, you can use [clientSse.ts](https://github.com/apify/actor-mcp-server/tree/main/src/examples/clientSse.ts) script or test the server using `curl` </> commands. |
161 | | - |
162 | | -1. Initiate Server-Sent-Events (SSE) by sending a GET request to the following URL: |
163 | | - ``` |
164 | | - curl https://actors-mcp-server.apify.actor/sse?token=<APIFY_TOKEN> |
165 | | - ``` |
166 | | - The server will respond with a `sessionId`, which you can use to send messages to the server: |
167 | | - ```shell |
168 | | - event: endpoint |
169 | | - data: /message?sessionId=a1b |
170 | | - ``` |
171 | | -
|
172 | | -2. Send a message to the server by making a POST request with the `sessionId`: |
173 | | - ```shell |
174 | | - curl -X POST "https://actors-mcp-server.apify.actor/message?token=<APIFY_TOKEN>&session_id=a1b" -H "Content-Type: application/json" -d '{ |
175 | | - "jsonrpc": "2.0", |
176 | | - "id": 1, |
177 | | - "method": "tools/call", |
178 | | - "params": { |
179 | | - "arguments": { "searchStringsArray": ["restaurants in San Francisco"], "maxCrawledPlacesPerSearch": 3 }, |
180 | | - "name": "lukaskrivka/google-maps-with-contact-details" |
181 | | - } |
182 | | - }' |
183 | | - ``` |
184 | | - The MCP server will start the Actor `lukaskrivka/google-maps-with-contact-details` with the provided arguments as input parameters. |
185 | | - For this POST request, the server will respond with: |
186 | | -
|
187 | | - ```text |
188 | | - Accepted |
189 | | - ``` |
190 | | -
|
191 | | -3. Receive the response. The server will invoke the specified Actor as a tool using the provided query parameters and stream the response back to the client via SSE. |
192 | | - The response will be returned as JSON text. |
193 | | -
|
194 | | - ```text |
195 | | - event: message |
196 | | - data: {"result":{"content":[{"type":"text","text":"{\"searchString\":\"restaurants in San Francisco\",\"rank\":1,\"title\":\"Gary Danko\",\"description\":\"Renowned chef Gary Danko's fixed-price menus of American cuisine ... \",\"price\":\"$100+\"...}}]}} |
197 | | - ``` |
198 | 157 |
|
199 | 158 | ## ⾕ MCP Server at a local host |
200 | 159 |
|
@@ -402,31 +361,6 @@ export APIFY_TOKEN=your-apify-token |
402 | 361 | npx @modelcontextprotocol/inspector npx -y @apify/actors-mcp-server |
403 | 362 | ``` |
404 | 363 |
|
405 | | -### Installing via Smithery |
406 | | - |
407 | | -To install Apify Actors MCP Server for Claude Desktop automatically via [Smithery](https://smithery.ai/server/@apify/actors-mcp-server): |
408 | | - |
409 | | -```bash |
410 | | -npx -y @smithery/cli install @apify/actors-mcp-server --client claude |
411 | | -``` |
412 | | - |
413 | | -#### Stdio clients |
414 | | - |
415 | | -Create an environment file `.env` with the following content: |
416 | | -```text |
417 | | -APIFY_TOKEN=your-apify-token |
418 | | -``` |
419 | | -In the `examples` directory, you can find an example client to interact with the server via |
420 | | -standard input/output (stdio): |
421 | | - |
422 | | -- [`clientStdio.ts`](https://github.com/apify/actor-mcp-server/tree/main/src/examples/clientStdio.ts) |
423 | | - This client script starts the MCP server with two specified Actors. |
424 | | - It then calls the `apify/rag-web-browser` tool with a query and prints the result. |
425 | | - It demonstrates how to connect to the MCP server, list available tools, and call a specific tool using stdio transport. |
426 | | - ```bash |
427 | | - node dist/examples/clientStdio.js |
428 | | - ``` |
429 | | - |
430 | 364 | # 👷🏼 Development |
431 | 365 |
|
432 | 366 | ## Prerequisites |
|
0 commit comments