-
Notifications
You must be signed in to change notification settings - Fork 78
feat: MCP server implementation #1
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
Changes from 20 commits
959e421
9b06472
672d79e
1d27199
cbc172a
7dd8fb2
b4d3bd9
e1984a0
0c792d5
65f6e41
552cedd
5cf7c00
ff4ec05
f516fe2
76bf0fb
1655d70
259e1c4
8a9cad3
405f70c
af4d696
1c92990
19bb130
22ac5ed
147f7a8
7e975e5
d2bc65a
c6128c3
c676bc2
7ced4a4
5cbf12c
8355f3a
1f5c841
a857a74
472be0c
036c6b3
e1a0c6a
34ecf25
50e3d85
364f49d
1e7d6f8
5233088
5c9d89d
57af156
0aae5c6
c8b2da4
e12cf8e
2d474ce
ca69a88
b84651e
479e9be
f39dfc5
d6e03fc
3a5be34
fc40b59
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| APIFY_API_TOKEN= | ||
| APIFY_TOKEN= | ||
| # ANTHROPIC_API_KEY is only required when you want to run examples/clientStdioChat.js | ||
| ANTHROPIC_API_KEY= |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,23 +11,26 @@ The server can be used in two ways: | |
|
|
||
| The MCP Server Actor allows an AI assistant to use any [Apify Actor](https://apify.com/store) as a tool to perform a specific task. | ||
| For example it can: | ||
| - [Facebook Posts Scraper](https://apify.com/apify/facebook-posts-scraper) extracts data from Facebook posts from multiple pages/profiles | ||
| - [Google Maps Email Extractor](https://apify.com/lukaskrivka/google-maps-with-contact-details) extracts Google Maps contact details | ||
| - [Google Search Results Scraper](https://apify.com/apify/google-search-scraper) scrapes Google Search Engine Results Pages (SERPs) | ||
| - [Instagram Scraper](https://apify.com/apify/instagram-scraper) scrapes Instagram posts, profiles, places, hashtags, photos, and comments | ||
| - [RAG Web Browser](https://apify.com/apify/web-scraper) performs web search, scrape the top N URLs from the results, and return content | ||
| - use [Facebook Posts Scraper](https://apify.com/apify/facebook-posts-scraper) to extract data from Facebook posts from multiple pages/profiles | ||
| - use [Google Maps Email Extractor](https://apify.com/lukaskrivka/google-maps-with-contact-details) to extract Google Maps contact details | ||
| - use [Google Search Results Scraper](https://apify.com/apify/google-search-scraper) to scrape Google Search Engine Results Pages (SERPs) | ||
| - use [Instagram Scraper](https://apify.com/apify/instagram-scraper) to scrape Instagram posts, profiles, places, hashtags, photos, and comments | ||
| - use [RAG Web Browser](https://apify.com/apify/web-scraper) to perform a web search, scrape the top N URLs from the results, and return content | ||
|
|
||
| To interact with the Apify MCP server, you can use MCP clients such as [Claude Desktop](https://claude.ai/download), [Superinference.ai](https://superinterface.ai/), or [LibreChat](https://www.librechat.ai/). | ||
| Additionally, you can use simple example clients found in the [examples](https://github.com/apify/actor-mcp-server/tree/main/src/examples) directory. | ||
|
|
||
| When you have Actors integrated with the MCP server, you can ask: | ||
| - Search web and summarize recent trends about AI Agents | ||
| - Find top 10 best Italian restaurants in San Francisco | ||
| - Find and analyze Instagram profile of The Rock | ||
| - Provide a step-by-step guide on using the Model Context Protocol with source URLs. | ||
| - What Apify Actors I can use? | ||
| - "Search web and summarize recent trends about AI Agents" | ||
| - "Find top 10 best Italian restaurants in San Francisco" | ||
| - "Find and analyze Instagram profile of The Rock" | ||
| - "Provide a step-by-step guide on using the Model Context Protocol with source URLs." | ||
| - "What Apify Actors I can use?" | ||
|
|
||
| # 🔄 What is model context protocol? | ||
| In the future, we plan to load Actors dynamically and provide Apify's dataset and key-value store as resources. | ||
| See the [Roadmap](#-roadmap-january-2025) for more details. | ||
|
|
||
| # 🔄 What is the Model Context Protocol? | ||
|
|
||
| The Model Context Protocol (MCP) allows AI applications (and AI agents), such as Claude Desktop, to connect to external tools and data sources. | ||
| MCP is an open protocol that enables secure, controlled interactions between AI applications, AI Agents, and local or remote resources. | ||
|
|
@@ -37,18 +40,12 @@ MCP is an open protocol that enables secure, controlled interactions between AI | |
| ## Tools | ||
|
|
||
| Any [Apify Actor](https://apify.com/store) can be used as a tool. | ||
| By default, the server is pre-configured with the Actors specified below, but it can be overridden by providing a list of Actor names in the `actors` query parameter. | ||
| By default, the server is pre-configured with the Actors specified below, but it can be overridden by providing Actor input. | ||
|
|
||
| ```text | ||
| 'apidojo/tweet-scraper', | ||
| 'apify/facebook-posts-scraper', | ||
| 'apify/google-search-scraper', | ||
| 'apify/instagram-scraper', | ||
| 'apify/rag-web-browser', | ||
| 'clockworks/free-tiktok-scraper', | ||
| 'compass/crawler-google-places', | ||
| 'lukaskrivka/google-maps-with-contact-details', | ||
| 'voyager/booking-scraper' | ||
| ``` | ||
| The MCP server loads the Actor input schema and creates MCP tools corresponding to the Actors. | ||
| See this example of input schema for the [RAG Web Browser](https://apify.com/apify/rag-web-browser/input-schema). | ||
|
|
@@ -86,14 +83,17 @@ The Actor runs in [**Standby mode**](https://docs.apify.com/platform/actors/runn | |
| Start server with default Actors. To use the Apify MCP Server with set of default Actors, | ||
|
Member
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. This is a bit problematic, Actor Standby doesn't have a concept of "starting a server". It just starts an Actor run when it receives the first requests to its Standby URL, the run will run until the idle timeout, and then it's shut down. So with this scenario this could happen:
Or, if the user uses the MCP server a lot, an additional run is started to handle the requests, and that is not prepared with the specific Actors. It also doesn't give the user an option how to load different Actors after the run is started. What would work is one of these two options:
Collaborator
Author
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. Ohhh 💡, this didn't occur to me. Thanks Franto!
This is a bit problematic as it depends on the MCP client (e.g., Claude Desktop, LibreChat). These clients do not pass parameters to the SSE endpoint
This seems to be the easiest and quickest solution. There is one more option.
|
||
| send an HTTP GET request with your [Apify API token](https://console.apify.com/settings/integrations) to the following URL. | ||
| ``` | ||
| https://mcp-server.apify.actor?token=<APIFY_API_TOKEN> | ||
| ``` | ||
| It is also possible to start MCP server with a different set of tools by providing a list of Actor names in the `actors` query parameter. | ||
| Provide a comma-separated list of Actors in the `actors` query parameter: | ||
| https://actors-mcp-server.apify.actor?token=<APIFY_TOKEN> | ||
| ``` | ||
| https://mcp-server.apify.actor?token=<APIFY_API_TOKEN>&actors=junglee/free-amazon-product-scraper,lukaskrivka/google-maps-with-contact-details | ||
| It is also possible to start the MCP server with a different set of Actors. | ||
| To do this, create a [task](https://docs.apify.com/platform/actors/running/tasks) and specify the list of Actors you want to use. | ||
|
|
||
| Then, run task in Standby mode with the selected Actors using your Apify API token. | ||
| ```shell | ||
| https://actors-mcp-server-task.apify.actor?token=<APIFY_TOKEN> | ||
| ``` | ||
| Find list of all available Actors in the [Apify Store](https://apify.com/store). | ||
|
|
||
| You can find a list of all available Actors in the [Apify Store](https://apify.com/store). | ||
|
|
||
| #### 💬 Interact with the MCP Server | ||
|
|
||
|
|
@@ -107,9 +107,9 @@ In the client settings you need to provide server configuration: | |
| "mcpServers": { | ||
| "apify": { | ||
| "type": "sse", | ||
| "url": "https://mcp-server.apify.actor/sse", | ||
| "url": "https://actors-mcp-server.apify.actor/sse", | ||
| "env": { | ||
| "APIFY-API-TOKEN": "your-apify-api-token" | ||
| "APIFY_TOKEN": "your-apify-token" | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -119,7 +119,7 @@ Alternatively, you can use simple python [client_see.py](https://github.com/apif | |
|
|
||
| 1. Initiate Server-Sent-Events (SSE) by sending a GET request to the following URL: | ||
| ``` | ||
| curl https://mcp-server.apify.actor/sse?token=<APIFY_API_TOKEN> | ||
| curl https://actors-mcp-server.apify.actor/sse?token=<APIFY_TOKEN> | ||
| ``` | ||
| The server will respond with a `sessionId`, which you can use to send messages to the server: | ||
| ```shell | ||
|
|
@@ -129,7 +129,7 @@ Alternatively, you can use simple python [client_see.py](https://github.com/apif | |
|
|
||
| 2. Send a message to the server by making a POST request with the `sessionId`: | ||
| ```shell | ||
| curl -X POST "https://mcp-server.apify.actor?token=<APIFY_API_TOKEN>&session_id=a1b" -H "Content-Type: application/json" -d '{ | ||
| curl -X POST "https://actors-mcp-server.apify.actor?token=<APIFY_TOKEN>&session_id=a1b" -H "Content-Type: application/json" -d '{ | ||
| "jsonrpc": "2.0", | ||
| "id": 1, | ||
| "method": "tools/call", | ||
|
|
@@ -161,7 +161,7 @@ Alternatively, you can use simple python [client_see.py](https://github.com/apif | |
| - MacOS or Windows | ||
| - The latest version of Claude Desktop must be installed (or another MCP client) | ||
| - [Node.js](https://nodejs.org/en) (v18 or higher) | ||
| - [Apify API Token](https://docs.apify.com/platform/integrations/api#api-token) (`APIFY_API_TOKEN`) | ||
| - [Apify API Token](https://docs.apify.com/platform/integrations/api#api-token) (`APIFY_TOKEN`) | ||
|
|
||
| ### Install | ||
|
|
||
|
|
@@ -201,7 +201,7 @@ Configure Claude Desktop to recognize the MCP server. | |
| "/path/to/actor-mcp-server/dist/index.js" | ||
| ] | ||
| "env": { | ||
| "APIFY-API-TOKEN": "your-apify-api-token" | ||
| "APIFY_TOKEN": "your-apify-token" | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -217,7 +217,7 @@ Configure Claude Desktop to recognize the MCP server. | |
| "lukaskrivka/google-maps-with-contact-details,apify/instagram-scraper" | ||
| ] | ||
| "env": { | ||
| "APIFY-API-TOKEN": "your-apify-api-token" | ||
| "APIFY_TOKEN": "your-apify-token" | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -242,7 +242,7 @@ Configure Claude Desktop to recognize the MCP server. | |
|
|
||
| Create environment file `.env` with the following content: | ||
| ```text | ||
| APIFY_API_TOKEN=your-apify-api-token | ||
| APIFY_TOKEN=your-apify-token | ||
| # ANTHROPIC_API_KEY is only required when you want to run examples/clientStdioChat.js | ||
| ANTHROPIC_API_KEY=your-anthropic-api-token | ||
| ``` | ||
|
|
@@ -274,7 +274,7 @@ standard input/output (stdio): | |
|
|
||
| Create environment file `.env` with the following content: | ||
| ```text | ||
| APIFY_API_TOKEN=your-apify-api-token | ||
| APIFY_TOKEN=your-apify-token | ||
| # ANTHROPIC_API_KEY is only required when you want to run examples/clientStdioChat.js | ||
| ANTHROPIC_API_KEY=your-anthropic-api-token | ||
| ``` | ||
|
|
@@ -302,7 +302,15 @@ npm run build | |
| You can launch the MCP Inspector via [`npm`](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) with this command: | ||
|
|
||
| ```bash | ||
| npx @modelcontextprotocol/inspector node /path/to/actor-mcp-server/dist/index.js --env APIFY_API_TOKEN=your-apify-api-token | ||
| npx @modelcontextprotocol/inspector node /path/to/actor-mcp-server/dist/index.js --env APIFY_TOKEN=your-apify-token | ||
| ``` | ||
|
|
||
| Upon launching, the Inspector will display a URL that you can access in your browser to begin debugging. | ||
|
|
||
| # 🚀 Roadmap (January 2025) | ||
|
|
||
| - Document examples for [Superinference.ai](https://superinterface.ai/) and [LibreChat](https://www.librechat.ai/). | ||
| - Provide tools to search for Actors and load them as needed. | ||
| - Add Apify's dataset and key-value store as resources. | ||
| - Add tools such as Actor logs and Actor runs for debugging. | ||
| - Prune Actors input schema to reduce context size. | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.