-
Notifications
You must be signed in to change notification settings - Fork 135
docs: update mcp.md #1583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
docs: update mcp.md #1583
Changes from 35 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
b03e5ca
Update mcp.md
vystrcild be76c13
Update sources/platform/integrations/ai/mcp.md
vystrcild 92217c7
Update sources/platform/integrations/ai/mcp.md
vystrcild be821af
Update sources/platform/integrations/ai/mcp.md
vystrcild a99eb47
Update sources/platform/integrations/ai/mcp.md
vystrcild 1207230
Update sources/platform/integrations/ai/mcp.md
vystrcild 672d703
Update sources/platform/integrations/ai/mcp.md
vystrcild 4d3d304
Update sources/platform/integrations/ai/mcp.md
vystrcild 36d3624
Update sources/platform/integrations/ai/mcp.md
vystrcild 8a834b0
Update sources/platform/integrations/ai/mcp.md
vystrcild 0340669
Update sources/platform/integrations/ai/mcp.md
vystrcild 0ce013f
Update mcp.md
vystrcild 9540863
Added images to MCP docs
d061f36
Added info about SSE
f17955b
fix: lint
jirispilka 3ee3b25
Update mcp.md
vystrcild 9e7c370
Update mcp.md
vystrcild 75ef6f9
Update sources/platform/integrations/ai/mcp.md
vystrcild adcb648
Update mcp.md
vystrcild 9426d97
Update sources/platform/integrations/ai/mcp.md
vystrcild e78dcbd
Update mcp.md
vystrcild 56cf225
Update mcp.md
vystrcild a10461f
Update mcp.md
vystrcild 11a5425
Update mcp.md
vystrcild b374ff6
Update mcp.md
vystrcild e3b68bf
Update mcp.md
vystrcild a69a0c0
Update mcp.md
vystrcild aea0a5c
Update mcp.md
vystrcild 52f0647
Update mcp.md
vystrcild 2e17507
Update mcp.md
vystrcild b1c05b9
Update mcp.md
vystrcild d6b5c77
Update mcp.md
vystrcild d02475e
Update mcp.md
vystrcild 75d2d51
Update mcp.md
vystrcild d758259
Update mcp.md
vystrcild 6310733
Update sources/platform/integrations/ai/mcp.md
vystrcild 1ec3534
Update sources/platform/integrations/ai/mcp.md
vystrcild 5fd1ee1
Update sources/platform/integrations/ai/mcp.md
vystrcild 34d3a18
Update sources/platform/integrations/ai/mcp.md
vystrcild File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -8,178 +8,128 @@ slug: /integrations/mcp | |||||
|
|
||||||
| <!-- markdownlint-disable MD024 --> | ||||||
|
|
||||||
| The Apify Model Context Protocol (MCP) server allows AI agents and frameworks compatible with the MCP standard to connect with the extensive library of Actors available on [Apify Store](https://apify.com/store). | ||||||
| The _Apify Model Context Protocol (MCP) Server_ allows AI applications to connect to Apify’s extensive library of Actors as tools to perform web scraping, data extraction, or other automation tasks in real time. | ||||||
|
|
||||||
| ## Why use MCP with Apify? | ||||||
|  | ||||||
|
|
||||||
| - _Access a vast tool library_: Provide AI agents access to thousands of pre-built Actors for web scraping, data extraction, and automation. | ||||||
| - _Dynamic tool discovery_: Unlike static OpenAPI definitions, MCP enables agents to dynamically find and add relevant Actors to their context during runtime. Agents can use MCP operations like `discover-actors` and `add-actor-to-tools`. | ||||||
| - _Scalability_: Efficiently manage access to a large and growing number of tools, which is challenging with single, static API definitions. | ||||||
| - _Flexible integration_: Connect to the MCP server using HTTP Server-Sent Events (SSE) or local standard input/output (stdin/stdout). Compatible clients include Claude Desktop, LibreChat, and [Apify’s Tester MCP Client](https://apify.com/jiri.spilka/tester-mcp-client). | ||||||
| ## Quickstart | ||||||
|
|
||||||
| ## Common use cases | ||||||
| You can use the Apify MCP Server in two ways: | ||||||
|
|
||||||
| - Standard Input/Output (stdio): Ideal for local integrations and command-line tools such as the Claude desktop client. | ||||||
| - Set MCP client server command to `npx @apify/actors-mcp-server` and environment variable `APIFY_TOKEN` to your Apify API token | ||||||
| - See `npx @apify/actors-mcp-server --help` for more options | ||||||
| - HTTPS Endpoint [mcp.apify.com](https://mcp.apify.com): Connect your MCP client by including `Authorization: Bearer <APIFY_TOKEN>` header in your requests. | ||||||
| - `https://mcp.apify.com` for streamable transport | ||||||
| - `https://mcp.apify.com/sse` for legacy SSE transport | ||||||
vystrcild marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| _(You could also use legacy option by running [Apify Actors MCP Server](https://apify.com/apify/actors-mcp-server) as Actor.)_ | ||||||
vystrcild marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| - Extract data from websites, such as social media posts, search engine results, or specific URLs. | ||||||
| - Summarize web content or identify trends. | ||||||
| - Run automated web workflows without direct user interaction. | ||||||
|
|
||||||
| ## Prerequisites | ||||||
|
|
||||||
| Before you start, make sure you have the following: | ||||||
|
|
||||||
| 1. _Apify account_: You need an active account on the Apify platform. | ||||||
| 2. _API Token_: Get your personal API token from the **Integrations** section in [Apify Console](https://console.apify.com/account#/integrations). | ||||||
| 1. _An Apify account:_ Sign up for a free Apify account if you don’t have one. | ||||||
| 1. _Apify API Token:_ Get your personal API token from the **Integrations** section in [Apify Console](https://console.apify.com/account#/integrations). This token will be used to authorize the MCP server to run Actors on your behalf. | ||||||
| 1. _MCP client:_ You will also need an AI agent or client that supports MCP. This could be Anthropic Claude desktop, a VS Code extension with MCP support, Apify’s web-based Tester MCP Client, or any custom client implementation. See supported MCP clients in [official documentation](https://modelcontextprotocol.io/clients). | ||||||
vystrcild marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| ## Connection methods | ||||||
| ## Example usage (local stdio with Claude desktop) | ||||||
|
|
||||||
| Apify provides two main ways to connect your MCP client to Actors: | ||||||
| Let’s walk through an example of using Claude desktop with the Apify MCP Server: | ||||||
|
|
||||||
| 1. Main Actors MCP Server: Access _all_ public Actors. Requires dynamic discovery or specifying Actors via URL parameters. | ||||||
| 2. Actor-specific MCP Server: A dedicated endpoint for a _single_ Actor, which is pre-registered and ready for immediate use. | ||||||
| 1. _Configure Claude desktop:_ Claude desktop supports MCP servers via the **Developer settings**. You need to add an entry for the Apify MCP server. For instance, in Claude’s config file, under `mcpServers`, add an entry like: | ||||||
|
|
||||||
| ### Option 1: Use the main Actors MCP server | ||||||
| ```json | ||||||
| { | ||||||
| "mcpServers": { | ||||||
| "actors-mcp-server": { | ||||||
| "command": "npx", | ||||||
| "args": ["-y", "@apify/actors-mcp-server"], | ||||||
| "env": { | ||||||
| "APIFY_TOKEN": "YOUR_APIFY_TOKEN" | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| ``` | ||||||
|
|
||||||
| This method offers the most flexibility, allowing access to all of Apify Store dynamically or by specifying Actors at connection time. | ||||||
| This tells Claude to spawn the Apify MCP Server (via the [Actors MCP Server](https://www.npmjs.com/package/@apify/actors-mcp-server) NPM package with your API token (on the first run, it will download the package automatically). | ||||||
|
|
||||||
| ```text title="Server endpoint" | ||||||
| https://actors-mcp-server.apify.actor/sse?token=<YOUR_API_TOKEN> | ||||||
| ``` | ||||||
| 1. _Launch Claude and connect:_ After updating the config, restart Claude desktop. If successful, Claude will show a “plugin” (often indicated by a plug icon 🔌) signifying it connected to the Apify Actors MCP server. | ||||||
|
|
||||||
| Key features: | ||||||
| 1. _Use the Actors in conversation:_ You can chat with Claude and ask it to use Apify Actors. For example: _“What Apify Actors can I use?”_ Claude will list available tools via the MCP server. If none are pre-loaded, it may show defaults or guide you to find more. | ||||||
|
|
||||||
| - Dynamic discovery: Agents can use MCP operations like `discover-actors` to search Apify Store for tools. | ||||||
| - Dynamic registration: Agents can use the `add-actor-to-tools` operation to add discovered Actors to their available toolset for the current session. | ||||||
| - Pre-registration via URL: You can make specific Actors available immediately by adding the `&actors=` query parameter to the connection URL (for example, `&actors=apify/rag-web-browser`). | ||||||
| _(If you prefer not to set up Claude desktop, you can achieve a similar result using [Apify’s Tester MCP Client](https://apify.com/jiri.spilka/tester-mcp-client), which provides a web UI to test the MCP server.)_ | ||||||
|
|
||||||
| The following example demonstrates connecting to the main server while pre-registering the `apify/rag-web-browser` Actor. | ||||||
|  | ||||||
|
|
||||||
| #### Step 1: Start the SSE connection | ||||||
| ## Interact with the MCP server over SSE | ||||||
|
|
||||||
| Use `curl` or another SSE client to establish the connection. Append `&actors=apify/rag-web-browser` to pre-register the tool. Replace `<YOUR_API_TOKEN>` with your actual Apify API token. | ||||||
| You can interact with the server through Server-Sent Events (SSE) to send messages and receive responses. | ||||||
|
|
||||||
| ```bash | ||||||
| # Start the Server-Sent Events (SSE) session and keep it active | ||||||
| curl "https://actors-mcp-server.apify.actor/sse?token=<YOUR_API_TOKEN>&actors=apify/rag-web-browser" | ||||||
| In the client settings, you need to provide server configuration: | ||||||
|
|
||||||
| # The server responds with the session endpoint. Note the sessionId. | ||||||
| # event: endpoint | ||||||
| # data: /message?sessionId=9d820491-38d4-4c7d-bb6a-3b7dc542f1fa | ||||||
| ```json | ||||||
| { | ||||||
| "mcpServers": { | ||||||
| "apify": { | ||||||
| "type": "sse", | ||||||
| "url": "https://mcp.apify.com/sse", | ||||||
| "headers": { | ||||||
| "Authorization": "Bearer your-apify-token" | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| ``` | ||||||
|
|
||||||
| #### Step 2: Send a tool call request | ||||||
|
|
||||||
| Use the `sessionId` obtained in Step 1 to send a POST request to the `/message` endpoint. This request invokes the pre-registered `apify/rag-web-browser` tool. Replace `<YOUR_API_TOKEN>` and `<SESSION_ID>` with your actual values. | ||||||
|
|
||||||
| ```bash | ||||||
| curl -X POST "https://actors-mcp-server.apify.actor/message?token=<YOUR_API_TOKEN>&session_id=<SESSION_ID>" \ | ||||||
| -H "Content-Type: application/json" \ | ||||||
| -d '{ | ||||||
| "jsonrpc": "2.0", | ||||||
| "id": 1, | ||||||
| "method": "tools/call", | ||||||
| "params": { | ||||||
| "arguments": { | ||||||
| "query": "web browser for RAG pipelines -site:reddit.com", | ||||||
| "proxyConfiguration": { | ||||||
| "useApifyProxy": true | ||||||
| }, | ||||||
| "removeElementsCssSelector": "nav, footer, script, style, noscript, svg, img[src^='\''data:'\''],\\n[role=\\"alert\\"],\\n[role=\\"banner\\"],\\n[role=\\"dialog\\"],\\n[role=\\"alertdialog\\"],\\n[role=\\"region\\"][aria-label*=\\"skip\\" i],\\n[aria-modal=\\"true\\"]", | ||||||
| "htmlTransformer": "none" | ||||||
| }, | ||||||
| "name": "apify/rag-web-browser" | ||||||
| } | ||||||
| }' | ||||||
|
|
||||||
| # The server immediately confirms receipt of the request: | ||||||
| # Accepted | ||||||
| ``` | ||||||
| ## Adding Multiple Actors | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| #### Step 3: Receive the result via SSE | ||||||
| By default, the main Actors MCP Server starts with a single default [RAG Web Browser Actor](https://apify.com/apify/rag-web-browser). However, you can fully customize which Actors are available: | ||||||
|
|
||||||
| The Actor's result is sent back asynchronously over the SSE connection established in Step 1. | ||||||
| - **Dynamic adding during a session:** If your client supports it, the agent itself can add Actors dynamically by name (using the `add-actor` operation) at runtime. For example, after using `search-actors` to find an Actor’s name, calling `add-actor` with that name will load it. Note that not all MCP client frameworks allow dynamic tool addition at runtime, but Apify’s own tester client does, if `enableAddingActors` is enabled—either via `?enableAddingActors=true` in the MCP Server URL, or with the CLI flag `--enable-adding-actors` (can also be set in Claude Desktop config args as `--enable-adding-actors`). | ||||||
| - **Via config file (for Claude desktop):** When using Claude desktop, you can specify which Actors should be immediately available by configuring your `mcpServers` settings. Add the Actors as a comma-separated list in the `--actors` parameter, as shown in the example below. This pre-loads your selected tools without requiring discovery during conversations, ideal for workflows with predictable tool needs. | ||||||
vystrcild marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| ```json | ||||||
| event: message | ||||||
| data: { | ||||||
| "result": { | ||||||
| "content": [ | ||||||
| { | ||||||
| "type": "text", | ||||||
| "text": "[{\"searchResult\":{\"title\":\"... RAG Web Browser Result ...\",\"description\":\"... Content extracted by the Actor ...\"}}]" // Example structure | ||||||
| { | ||||||
| "mcpServers": { | ||||||
| "actors-mcp-server": { | ||||||
| "command": "npx", | ||||||
| "args": [ | ||||||
| "-y", "@apify/actors-mcp-server", | ||||||
| "--actors", "lukaskrivka/google-maps-with-contact-details,apify/instagram-scraper" | ||||||
| ], | ||||||
| "env": { | ||||||
| "APIFY_TOKEN": "YOUR_APIFY_TOKEN" | ||||||
| } | ||||||
| } | ||||||
| ] | ||||||
| } | ||||||
| } | ||||||
| ``` | ||||||
|
|
||||||
| ### Option 2: Use an Actor-specific MCP server | ||||||
|
|
||||||
| Certain Actors, such as `apify/rag-web-browser`, offer their own dedicated MCP server endpoint. This simplifies integration when you only need to interact with that specific Actor. | ||||||
|
|
||||||
| ```text title="Endpoint example for `apify/rag-web-browser`" | ||||||
| https://rag-web-browser.apify.actor/sse?token=<YOUR_API_TOKEN> | ||||||
| } | ||||||
| } | ||||||
| ``` | ||||||
|
|
||||||
| :::note | ||||||
|
|
||||||
| The hostname typically matches the Actor's name. | ||||||
| In summary, you can start with a broad set (everything open and discoverable) or a narrow set (just what you need) and even expand tools on the fly, giving your agent a lot of flexibility without overwhelming it initially. | ||||||
|
|
||||||
| ::: | ||||||
| ## Dynamic Actor tooling | ||||||
|
|
||||||
| This method is ideal for integrating a specific tool directly into an application (like Claude Desktop) or a custom client without needing the dynamic discovery capabilities of the main server. | ||||||
| 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: | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| The following example demonstrates use of `rag-web-browser` server. | ||||||
| - _Actor discovery and management:_ Search for [Actors](https://docs.apify.com/platform/actors) (`search-actors`), view details (`get-actor-details`), and dynamically add or remove tools (`add-actor`, `remove-actor`). | ||||||
| - _Actor execution and monitoring:_ Start [Actor runs](https://docs.apify.com/platform/actors/running/runs-and-builds#runs), fetch run results (`get-actor-run`), logs (`get-actor-log`), and abort runs (`abort-actor-run`). | ||||||
| - _Dataset access:_ List [datasets](https://docs.apify.com/platform/storage/dataset), retrieve dataset info and items (`get-dataset`, `get-dataset-list`, `get-dataset-items`). | ||||||
| - _Key-value store access:_ List [key-value stores](https://docs.apify.com/platform/storage/key-value-store), view keys, and retrieve records (`get-key-value-store-list`, `get-key-value-store`, `get-key-value-store-keys`, `get-key-value-store-record`). | ||||||
| - _Built-in help tool:_ A static helper (`apify-actor-help-tool`) that returns usage info for the Apify MCP Server. | ||||||
|
|
||||||
| #### Step 1: Start the SSE connection | ||||||
|
|
||||||
| Connect directly to the Actor's specific MCP endpoint. Replace `<YOUR_API_TOKEN>` with your actual Apify API token. | ||||||
|
|
||||||
| ```bash | ||||||
| # Start the Server-Sent Events (SSE) session and keep it active | ||||||
| curl "https://rag-web-browser.apify.actor/sse?token=<YOUR_API_TOKEN>" | ||||||
|
|
||||||
| # The server responds with the session endpoint. Note the sessionId. | ||||||
| # event: endpoint | ||||||
| # data: /message?sessionId=5b2a... | ||||||
| ``` | ||||||
|
|
||||||
| #### Step 2: Send a tool call request | ||||||
|
|
||||||
| Use the `sessionId` from Step 1 to send a POST request to the Actor's `/message` endpoint. Replace `<YOUR_API_TOKEN>` and `<SESSION_ID>` with your actual values. The tool `name` in the parameters typically matches the Actor name. | ||||||
|
|
||||||
| ```bash | ||||||
| curl -X POST "https://rag-web-browser.apify.actor/message?session_id=<SESSION_ID>&token=<YOUR_API_TOKEN>" \ | ||||||
| -H "Content-Type: application/json" \ | ||||||
| -d '{ | ||||||
| "jsonrpc": "2.0", | ||||||
| "id": 1, | ||||||
| "method": "tools/call", | ||||||
| "params": { | ||||||
| "arguments": { "query": "recent news about LLMs", "maxResults": 1 }, | ||||||
| "name": "rag-web-browser" | ||||||
| } | ||||||
| }' | ||||||
|
|
||||||
| # The server immediately confirms receipt of the request: | ||||||
| # Accepted | ||||||
| ``` | ||||||
|
|
||||||
| #### Step 3: Receive the result via SSE | ||||||
|
|
||||||
| The result is sent back over the SSE connection established in Step 1. | ||||||
|
|
||||||
| ```json | ||||||
| event: message | ||||||
| data: {"result":{"content":[{"type":"text","text":"[{\"searchResult\":{\"title\":\"Language models recent news\",\"description\":\"Amazon Launches New Generation of LLM Foundation Model...\"}}]"}]}} | ||||||
| ``` | ||||||
| ## Troubleshooting | ||||||
|
|
||||||
| ## Testing and resources | ||||||
| - _Authorization (API Token):_ If the MCP server isn’t executing Actors, ensure you provided a correct Apify API token. Without a valid `APIFY_TOKEN`, the server cannot start Actor runs. Always set the `APIFY_TOKEN` environment variable when running locally. | ||||||
| - _Ensure latest version:_ If running via NPM, always use the latest version of `@apify/actors-mcp-server` for the newest features and fixes. You can append `@latest` when installing or in your config args to ensure this. | ||||||
| - _Node.js environment:_ If running the server locally, make sure Node.js is installed and up to date (`node -v`). The MCP server requires Node.js v18+. | ||||||
| - _No response or long delay:_ Keep in mind that when an Actor tool is called, it may take some time to complete (depending on the task). If nothing is coming back, check the Actor’s logs in Apify console — the Actor might be waiting on a long operation or input. | ||||||
|
|
||||||
| - Testing: | ||||||
| - Tester MCP Client: Use the [Tester MCP Client](https://apify.com/jiri.spilka/tester-mcp-client) on Apify to interact with either MCP server type. Enter the appropriate server URL (for example, `https://actors-mcp-server.apify.actor/sse` or `https://rag-web-browser.apify.actor/sse`) in the Actor input field, configure your API token, run the client Actor, and interact through its user interface. | ||||||
| - Protocol information: | ||||||
| - MCP documentation: For details on the protocol, see the [MCP Introduction](https://modelcontextprotocol.io/introduction). | ||||||
| - MCP client examples: Find example client implementations at [MCP Clients](https://modelcontextprotocol.io/clients). | ||||||
| - Further reading: | ||||||
| - Apify Blog: Read more about Apify's implementation in the post: [What is Anthropic's Model Context Protocol?](https://blog.apify.com/what-is-model-context-protocol/) | ||||||
| ## Learn more | ||||||
|
|
||||||
| - [Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction): Learn about the open standard on the official MCP website – understanding the protocol can help you build custom agents. | ||||||
| - [Apify Actors MCP Server](https://apify.com/apify/actors-mcp-server): The README for the Apify MCP Server actor (available on Apify Store as `apify/actors-mcp-server`) provides technical details on implementation and advanced usage. | ||||||
| - [Apify Tester MCP Client](https://apify.com/jiri.spilka/tester-mcp-client): A specialized client actor (`jiri.spilka/tester-mcp-client`) that you can run to simulate an AI agent in your browser. Useful for testing your setup with a chat UI. | ||||||
| - [How to use MCP with Apify Actors](https://blog.apify.com/how-to-use-mcp/): Learn how to expose over 5,000 Apify Actors to AI agents with Claude and LangGraph, and configure MCP clients and servers. | ||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.