@decodo/mcp-server 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -43
- package/build/clients/scraper-api-client.js +78 -16
- package/build/clients/scraper-api-client.js.map +1 -1
- package/build/constants.js +35 -1
- package/build/constants.js.map +1 -1
- package/build/index.js +10 -11
- package/build/index.js.map +1 -1
- package/build/server/sapi-base-server.js +76 -0
- package/build/server/sapi-base-server.js.map +1 -0
- package/build/server/sapi-http-server.js +11 -0
- package/build/server/sapi-http-server.js.map +1 -0
- package/build/server/sapi-stdio-server.js +11 -0
- package/build/server/sapi-stdio-server.js.map +1 -0
- package/build/server.js +53 -0
- package/build/server.js.map +1 -0
- package/build/tools/amazon-bestsellers/amazon-bestsellers-tool.js +55 -0
- package/build/tools/amazon-bestsellers/amazon-bestsellers-tool.js.map +1 -0
- package/build/tools/amazon-bestsellers/index.js +18 -0
- package/build/tools/amazon-bestsellers/index.js.map +1 -0
- package/build/tools/amazon-pricing/amazon-pricing-tool.js +67 -0
- package/build/tools/amazon-pricing/amazon-pricing-tool.js.map +1 -0
- package/build/tools/amazon-pricing/index.js +18 -0
- package/build/tools/amazon-pricing/index.js.map +1 -0
- package/build/tools/amazon-product/amazon-product-tool.js +62 -0
- package/build/tools/amazon-product/amazon-product-tool.js.map +1 -0
- package/build/tools/amazon-product/index.js +18 -0
- package/build/tools/amazon-product/index.js.map +1 -0
- package/build/tools/amazon-search/amazon-search-tool.js +63 -0
- package/build/tools/amazon-search/amazon-search-tool.js.map +1 -0
- package/build/tools/amazon-search/index.js +18 -0
- package/build/tools/amazon-search/index.js.map +1 -0
- package/build/tools/amazon-search-parsed/amazon-search-parsed-tool.js +53 -0
- package/build/tools/amazon-search-parsed/amazon-search-parsed-tool.js.map +1 -0
- package/build/tools/amazon-search-parsed/index.js +18 -0
- package/build/tools/amazon-search-parsed/index.js.map +1 -0
- package/build/tools/amazon-search-parsed-tool.js +8 -2
- package/build/tools/amazon-search-parsed-tool.js.map +1 -1
- package/build/tools/amazon-sellers/amazon-sellers-tool.js +56 -0
- package/build/tools/amazon-sellers/amazon-sellers-tool.js.map +1 -0
- package/build/tools/amazon-sellers/index.js +18 -0
- package/build/tools/amazon-sellers/index.js.map +1 -0
- package/build/tools/bing-search/bing-search-tool.js +64 -0
- package/build/tools/bing-search/bing-search-tool.js.map +1 -0
- package/build/tools/bing-search/index.js +18 -0
- package/build/tools/bing-search/index.js.map +1 -0
- package/build/tools/chatgpt/chatgpt-tool.js +47 -0
- package/build/tools/chatgpt/chatgpt-tool.js.map +1 -0
- package/build/tools/chatgpt/index.js +18 -0
- package/build/tools/chatgpt/index.js.map +1 -0
- package/build/tools/chatgpt-tool.js +43 -0
- package/build/tools/chatgpt-tool.js.map +1 -0
- package/build/tools/constants.js +23 -0
- package/build/tools/constants.js.map +1 -0
- package/build/tools/google-ads/google-ads-tool.js +59 -0
- package/build/tools/google-ads/google-ads-tool.js.map +1 -0
- package/build/tools/google-ads/index.js +18 -0
- package/build/tools/google-ads/index.js.map +1 -0
- package/build/tools/google-ai-mode/google-ai-mode-tool.js +50 -0
- package/build/tools/google-ai-mode/google-ai-mode-tool.js.map +1 -0
- package/build/tools/google-ai-mode/index.js +18 -0
- package/build/tools/google-ai-mode/index.js.map +1 -0
- package/build/tools/google-lens/google-lens-tool.js +52 -0
- package/build/tools/google-lens/google-lens-tool.js.map +1 -0
- package/build/tools/google-lens/index.js +18 -0
- package/build/tools/google-lens/index.js.map +1 -0
- package/build/tools/google-search/google-search-tool.js +60 -0
- package/build/tools/google-search/google-search-tool.js.map +1 -0
- package/build/tools/google-search/index.js +18 -0
- package/build/tools/google-search/index.js.map +1 -0
- package/build/tools/google-search-parsed/google-search-parsed-tool.js +61 -0
- package/build/tools/google-search-parsed/google-search-parsed-tool.js.map +1 -0
- package/build/tools/google-search-parsed/index.js +18 -0
- package/build/tools/google-search-parsed/index.js.map +1 -0
- package/build/tools/google-search-parsed-tool.js +8 -2
- package/build/tools/google-search-parsed-tool.js.map +1 -1
- package/build/tools/google-travel-hotels/google-travel-hotels-tool.js +52 -0
- package/build/tools/google-travel-hotels/google-travel-hotels-tool.js.map +1 -0
- package/build/tools/google-travel-hotels/index.js +18 -0
- package/build/tools/google-travel-hotels/index.js.map +1 -0
- package/build/tools/index.js +30 -5
- package/build/tools/index.js.map +1 -1
- package/build/tools/perplexity/index.js +18 -0
- package/build/tools/perplexity/index.js.map +1 -0
- package/build/tools/perplexity/perplexity-tool.js +46 -0
- package/build/tools/perplexity/perplexity-tool.js.map +1 -0
- package/build/tools/perplexity-tool.js +42 -0
- package/build/tools/perplexity-tool.js.map +1 -0
- package/build/tools/reddit-post/index.js +18 -0
- package/build/tools/reddit-post/index.js.map +1 -0
- package/build/tools/reddit-post/reddit-post-tool.js +51 -0
- package/build/tools/reddit-post/reddit-post-tool.js.map +1 -0
- package/build/tools/reddit-post-tool.js +8 -2
- package/build/tools/reddit-post-tool.js.map +1 -1
- package/build/tools/reddit-subreddit/index.js +18 -0
- package/build/tools/reddit-subreddit/index.js.map +1 -0
- package/build/tools/reddit-subreddit/reddit-subreddit-tool.js +49 -0
- package/build/tools/reddit-subreddit/reddit-subreddit-tool.js.map +1 -0
- package/build/tools/reddit-subreddit-tool.js +8 -2
- package/build/tools/reddit-subreddit-tool.js.map +1 -1
- package/build/tools/reddit-user/index.js +18 -0
- package/build/tools/reddit-user/index.js.map +1 -0
- package/build/tools/reddit-user/reddit-user-tool.js +55 -0
- package/build/tools/reddit-user/reddit-user-tool.js.map +1 -0
- package/build/tools/scrape-as-markdown/index.js +18 -0
- package/build/tools/scrape-as-markdown/index.js.map +1 -0
- package/build/tools/scrape-as-markdown/scrape-as-markdown-tool.js +79 -0
- package/build/tools/scrape-as-markdown/scrape-as-markdown-tool.js.map +1 -0
- package/build/tools/scrape-as-markdown-tool.js +28 -20
- package/build/tools/scrape-as-markdown-tool.js.map +1 -1
- package/build/tools/screenshot/index.js +18 -0
- package/build/tools/screenshot/index.js.map +1 -0
- package/build/tools/screenshot/screenshot-tool.js +48 -0
- package/build/tools/screenshot/screenshot-tool.js.map +1 -0
- package/build/tools/screenshot-tool.js +44 -0
- package/build/tools/screenshot-tool.js.map +1 -0
- package/build/tools/target-product/index.js +18 -0
- package/build/tools/target-product/index.js.map +1 -0
- package/build/tools/target-product/target-product-tool.js +50 -0
- package/build/tools/target-product/target-product-tool.js.map +1 -0
- package/build/tools/target-search/index.js +18 -0
- package/build/tools/target-search/index.js.map +1 -0
- package/build/tools/target-search/target-search-tool.js +56 -0
- package/build/tools/target-search/target-search-tool.js.map +1 -0
- package/build/tools/tiktok-post/index.js +18 -0
- package/build/tools/tiktok-post/index.js.map +1 -0
- package/build/tools/tiktok-post/tiktok-post-tool.js +48 -0
- package/build/tools/tiktok-post/tiktok-post-tool.js.map +1 -0
- package/build/tools/tiktok-shop-product/index.js +18 -0
- package/build/tools/tiktok-shop-product/index.js.map +1 -0
- package/build/tools/tiktok-shop-product/tiktok-shop-product-tool.js +47 -0
- package/build/tools/tiktok-shop-product/tiktok-shop-product-tool.js.map +1 -0
- package/build/tools/tiktok-shop-search/index.js +18 -0
- package/build/tools/tiktok-shop-search/index.js.map +1 -0
- package/build/tools/tiktok-shop-search/tiktok-shop-search-tool.js +54 -0
- package/build/tools/tiktok-shop-search/tiktok-shop-search-tool.js.map +1 -0
- package/build/tools/tiktok-shop-url/index.js +18 -0
- package/build/tools/tiktok-shop-url/index.js.map +1 -0
- package/build/tools/tiktok-shop-url/tiktok-shop-url-tool.js +45 -0
- package/build/tools/tiktok-shop-url/tiktok-shop-url-tool.js.map +1 -0
- package/build/tools/tool.js +7 -0
- package/build/tools/tool.js.map +1 -0
- package/build/tools/walmart-product/index.js +18 -0
- package/build/tools/walmart-product/index.js.map +1 -0
- package/build/tools/walmart-product/walmart-product-tool.js +61 -0
- package/build/tools/walmart-product/walmart-product-tool.js.map +1 -0
- package/build/tools/walmart-search/index.js +18 -0
- package/build/tools/walmart-search/index.js.map +1 -0
- package/build/tools/walmart-search/walmart-search-tool.js +62 -0
- package/build/tools/walmart-search/walmart-search-tool.js.map +1 -0
- package/build/tools/youtube-channel/index.js +18 -0
- package/build/tools/youtube-channel/index.js.map +1 -0
- package/build/tools/youtube-channel/youtube-channel-tool.js +48 -0
- package/build/tools/youtube-channel/youtube-channel-tool.js.map +1 -0
- package/build/tools/youtube-metadata/index.js +18 -0
- package/build/tools/youtube-metadata/index.js.map +1 -0
- package/build/tools/youtube-metadata/youtube-metadata-tool.js +43 -0
- package/build/tools/youtube-metadata/youtube-metadata-tool.js.map +1 -0
- package/build/tools/youtube-search/index.js +18 -0
- package/build/tools/youtube-search/index.js.map +1 -0
- package/build/tools/youtube-search/youtube-search-tool.js +43 -0
- package/build/tools/youtube-search/youtube-search-tool.js.map +1 -0
- package/build/tools/youtube-subtitles/index.js +18 -0
- package/build/tools/youtube-subtitles/index.js.map +1 -0
- package/build/tools/youtube-subtitles/youtube-subtitles-tool.js +48 -0
- package/build/tools/youtube-subtitles/youtube-subtitles-tool.js.map +1 -0
- package/build/tools/youtube-video/index.js +18 -0
- package/build/tools/youtube-video/index.js.map +1 -0
- package/build/tools/youtube-video/youtube-video-tool.js +45 -0
- package/build/tools/youtube-video/youtube-video-tool.js.map +1 -0
- package/build/utils.js +14 -3
- package/build/utils.js.map +1 -1
- package/build/zod/zod-types.js +12 -4
- package/build/zod/zod-types.js.map +1 -1
- package/package.json +26 -13
- package/build/tools/scrape-tool.js +0 -70
- package/build/tools/scrape-tool.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# Decodo MCP Server
|
|
2
2
|
|
|
3
|
+
[](https://discord.gg/Ja8dqKgvbZ)
|
|
4
|
+
[](https://cursor.com/en-US/install-mcp?name=Decodo&config=eyJ1cmwiOiJodHRwczovL21jcC5kZWNvZG8uY29tL21jcCIsImhlYWRlcnMiOnsiQXV0aG9yaXphdGlvbiI6IkJhc2ljIDx3ZWJfYWR2YW5jZWRfdG9rZW4%2BIn19)
|
|
3
5
|
[](https://smithery.ai/server/@Decodo/decodo-mcp-server)
|
|
4
6
|
|
|
5
7
|
<p align="center">
|
|
6
|
-
<a href="https://dashboard.decodo.com/
|
|
7
|
-
|
|
8
|
-
[](https://discord.gg/Ja8dqKgvbZ)
|
|
8
|
+
<a href="https://dashboard.decodo.com/integrations?utm_source=github&utm_medium=social&utm_campaign=mcp_server"> <img src="https://github.com/user-attachments/assets/a1e52a9e-3da1-4081-b3c6-053aafb8f196"/></a>
|
|
9
9
|
|
|
10
10
|
This repository provides a Model Context Protocol (MCP) server that connects LLMs and applications
|
|
11
11
|
to Decodo's platform. The server facilitates integration between MCP-compatible clients and Decodo's
|
|
@@ -20,23 +20,30 @@ services, streamlining access to our tools and capabilities.
|
|
|
20
20
|
- Simple integration. Seamless setup with popular MCP clients like Claude Desktop, Cursor, and
|
|
21
21
|
Windsurf.
|
|
22
22
|
|
|
23
|
-
##
|
|
23
|
+
## Connecting to [Decodo's MCP server](https://mcp.decodo.com/mcp)
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
and generate installation instructions.
|
|
25
|
+
1. Go to [decodo.com](https://decodo.com/scraping/web) and start a Web Scraping API plan (free
|
|
26
|
+
trials available).
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
2. Once your plan has started, obtain a Web Scraping API basic authentication token from the
|
|
29
|
+
[dashboard](https://dashboard.decodo.com/).
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
3. Open your preferred MCP client and add the following configuration:
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
```
|
|
34
|
+
{
|
|
35
|
+
"Decodo": {
|
|
36
|
+
"url": "https://mcp.decodo.com/mcp",
|
|
37
|
+
"headers": {
|
|
38
|
+
"Authorization": "Basic <basic_auth_token>"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
```
|
|
36
43
|
|
|
37
|
-
|
|
44
|
+
## Running the MCP server locally
|
|
38
45
|
|
|
39
|
-
|
|
46
|
+
<details>
|
|
40
47
|
|
|
41
48
|
### Prerequisites
|
|
42
49
|
|
|
@@ -76,53 +83,83 @@ this:
|
|
|
76
83
|
|
|
77
84
|
4. Update your MCP client with the server information:
|
|
78
85
|
|
|
79
|
-
|
|
86
|
+
</details>
|
|
87
|
+
|
|
88
|
+
## Toolsets
|
|
80
89
|
|
|
81
|
-
|
|
82
|
-
|
|
90
|
+
Tools are organized into toolsets. You can selectively enable specific toolsets by passing a
|
|
91
|
+
comma-separated list via the `toolsets` query parameter:
|
|
83
92
|
|
|
84
93
|
```
|
|
85
|
-
{
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
"args": ["/Users/your.user/projects/decodo-mcp/build/index.js"],
|
|
90
|
-
"env": {
|
|
91
|
-
"SCRAPER_API_USERNAME": "your_username",
|
|
92
|
-
"SCRAPER_API_PASSWORD": "your_password"
|
|
94
|
+
"Decodo MCP Server": {
|
|
95
|
+
"url": "https://mcp.decodo.com/mcp?toolsets=web,ai",
|
|
96
|
+
"headers": {
|
|
97
|
+
"Authorization": "Basic <your_auth_token>"
|
|
93
98
|
}
|
|
94
99
|
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
100
|
```
|
|
99
101
|
|
|
100
|
-
|
|
102
|
+
When no toolsets are specified, all tools are registered.
|
|
101
103
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
+
| Toolset | Tools |
|
|
105
|
+
| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
106
|
+
| `web` | `scrape_as_markdown`, `screenshot` |
|
|
107
|
+
| `search` | `google_search`, `google_ads`, `google_lens`, `google_travel_hotels`, `bing_search` |
|
|
108
|
+
| `ecommerce` | `amazon_search`, `amazon_product`, `amazon_pricing`, `amazon_sellers`, `amazon_bestsellers`, `walmart_search`, `walmart_product`, `target_search`, `target_product`, `tiktok_shop_search`, `tiktok_shop_product`, `tiktok_shop_url` |
|
|
109
|
+
| `social_media` | `reddit_post`, `reddit_subreddit`, `reddit_user`, `tiktok_post`, `youtube_video`, `youtube_metadata`, `youtube_channel`, `youtube_subtitles`, `youtube_search` |
|
|
110
|
+
| `ai` | `chatgpt`, `perplexity`, `google_ai_mode` |
|
|
104
111
|
|
|
105
112
|
## Tools
|
|
106
113
|
|
|
107
114
|
The server exposes the following tools:
|
|
108
115
|
|
|
109
|
-
| Tool
|
|
110
|
-
|
|
|
111
|
-
| `scrape_as_markdown`
|
|
112
|
-
| `
|
|
113
|
-
| `
|
|
116
|
+
| Tool | Description | Example prompt |
|
|
117
|
+
| ----------------------- | ------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------- |
|
|
118
|
+
| `scrape_as_markdown` | Scrapes any target URL, expects a URL to be given via prompt. Returns results in Markdown. | Scrape peacock.com from a US IP address and tell me the pricing. |
|
|
119
|
+
| `screenshot` | Captures a screenshot of any webpage and returns it as a PNG image. | Take a screenshot of github.com from a US IP address. |
|
|
120
|
+
| `google_search` | Scrapes Google Search for a given query, and returns parsed results. | Scrape Google Search for shoes and tell me the top position. |
|
|
121
|
+
| `google_ads` | Scrapes Google Ads search results with automatic parsing. | Scrape Google Ads for laptop and show me the top ads. |
|
|
122
|
+
| `google_lens` | Scrapes Google Lens image search results with automatic parsing. | Search Google Lens for this image: https://example.com/image.jpg |
|
|
123
|
+
| `google_ai_mode` | Scrapes Google AI Mode (Search with AI) results with automatic parsing. | Ask Google AI Mode: What are the top three dog breeds? |
|
|
124
|
+
| `google_travel_hotels` | Scrapes Google Travel Hotels search results. | Search Google Travel Hotels for hotels in Paris. |
|
|
125
|
+
| `amazon_search` | Scrapes Amazon Search for a given query, and returns parsed results. | Scrape Amazon Search for wireless keyboard. |
|
|
126
|
+
| `amazon_product` | Scrapes Amazon Product page with automatic parsing. | Scrape Amazon product B09H74FXNW and show me the details. |
|
|
127
|
+
| `amazon_pricing` | Scrapes Amazon Product pricing information with automatic parsing. | Get pricing for Amazon product B09H74FXNW. |
|
|
128
|
+
| `amazon_sellers` | Scrapes Amazon Seller information with automatic parsing. | Get information about Amazon seller A1R0Z7FJGTKESH. |
|
|
129
|
+
| `amazon_bestsellers` | Scrapes Amazon Bestsellers list with automatic parsing. | Show me Amazon bestsellers in electronics. |
|
|
130
|
+
| `walmart_search` | Scrapes Walmart Search for a given query, and returns parsed results. | Scrape Walmart Search for camping tent. |
|
|
131
|
+
| `walmart_product` | Scrapes Walmart Product page with automatic parsing. | Scrape Walmart product 15296401808. |
|
|
132
|
+
| `target_search` | Scrapes Target Search for a given query, and returns parsed results. | Scrape Target Search for kitchen appliances. |
|
|
133
|
+
| `target_product` | Scrapes Target Product page with automatic parsing. | Scrape Target product 92186007. |
|
|
134
|
+
| `tiktok_post` | Scrapes a TikTok post URL for structured data (e.g. engagement, caption, hashtags). | Scrape this TikTok post: https://www.tiktok.com/@nba/video/7393013274725403950 |
|
|
135
|
+
| `tiktok_shop_search` | Scrapes TikTok Shop Search for a given query, and returns parsed results. | Scrape TikTok Shop Search for phone cases. |
|
|
136
|
+
| `tiktok_shop_product` | Scrapes TikTok Shop Product page. | Scrape TikTok Shop product 1731541214379741272. |
|
|
137
|
+
| `tiktok_shop_url` | Scrapes TikTok Shop page by URL. | Scrape this TikTok Shop URL: https://www.tiktok.com/shop/s?q=HEADPHONES |
|
|
138
|
+
| `youtube_video` | Scrapes YouTube video information. | Scrape YouTube video 6Ejga4kJUts. |
|
|
139
|
+
| `youtube_metadata` | Scrapes YouTube video metadata. | Get metadata for YouTube video dFu9aKJoqGg. |
|
|
140
|
+
| `youtube_channel` | Scrapes YouTube channel videos with automatic parsing. | Scrape YouTube channel @decodo_official. |
|
|
141
|
+
| `youtube_subtitles` | Scrapes YouTube video subtitles. | Get subtitles for YouTube video L8zSWbQN-v8. |
|
|
142
|
+
| `youtube_search` | Search YouTube videos. | Search YouTube for "How to care for chinchillas". |
|
|
143
|
+
| `reddit_post` | Scrapes a specific Reddit post for a given query, and returns parsed results. | Scrape the following Reddit post: https://www.reddit.com/r/horseracing/comments/1nsrn3/ |
|
|
144
|
+
| `reddit_subreddit` | Scrapes a specific Reddit subreddit for a given query, and returns parsed results. | Scrape the top 5 posts on r/Python this week. |
|
|
145
|
+
| `reddit_user` | Scrapes a Reddit user profile and their posts or comments. | Scrape Reddit user u/spez's profile. |
|
|
146
|
+
| `bing_search` | Scrapes Bing Search results with automatic parsing. | Search Bing for laptop reviews. |
|
|
147
|
+
| `chatgpt` | Search and interact with ChatGPT for AI-powered responses and conversations. | Ask ChatGPT to explain quantum computing in simple terms. |
|
|
148
|
+
| `perplexity` | Search and interact with Perplexity for AI-powered responses and conversations. | Ask Perplexity what the latest trends in web development are. |
|
|
114
149
|
|
|
115
150
|
## Parameters
|
|
116
151
|
|
|
117
152
|
The following parameters are inferred from user prompts:
|
|
118
153
|
|
|
119
|
-
| Parameter
|
|
120
|
-
|
|
|
121
|
-
| `jsRender`
|
|
122
|
-
| `geo`
|
|
123
|
-
| `locale`
|
|
124
|
-
| `tokenLimit`
|
|
125
|
-
| `
|
|
154
|
+
| Parameter | Description |
|
|
155
|
+
| ------------ | ----------------------------------------------------------------------------------------------------- |
|
|
156
|
+
| `jsRender` | Renders target URL in a headless browser. |
|
|
157
|
+
| `geo` | Sets the country from which the request will originate. |
|
|
158
|
+
| `locale` | Sets the locale of the request. |
|
|
159
|
+
| `tokenLimit` | Truncates the response content up to this limit. Useful if the context window is small. |
|
|
160
|
+
| `prompt` | Prompt to send to AI tools (`chatgpt`, `perplexity`). |
|
|
161
|
+
| `search` | Activates ChatGPT's web search functionality (`chatgpt` only). |
|
|
162
|
+
| `xhr` | When true, includes XHR or fetch responses in the scrape result where supported (e.g. `tiktok_post`). |
|
|
126
163
|
|
|
127
164
|
## Examples
|
|
128
165
|
|
|
@@ -13,35 +13,97 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
13
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
|
+
var _a;
|
|
16
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
18
|
exports.ScraperApiClient = void 0;
|
|
18
19
|
const axios_1 = __importDefault(require("axios"));
|
|
20
|
+
const MAX_RETRIES = Math.max(0, parseInt((_a = process.env.MAX_RETRIES) !== null && _a !== void 0 ? _a : '2', 10) || 2);
|
|
21
|
+
const RETRYABLE_STATUS_CODES = new Set([429, 502, 503, 504]);
|
|
22
|
+
const RETRYABLE_NETWORK_CODES = new Set(['ECONNRESET', 'ETIMEDOUT', 'ECONNABORTED', 'ENOTFOUND']);
|
|
23
|
+
const isRetryable = (error) => {
|
|
24
|
+
var _a;
|
|
25
|
+
if (error.response) {
|
|
26
|
+
return RETRYABLE_STATUS_CODES.has(error.response.status);
|
|
27
|
+
}
|
|
28
|
+
return RETRYABLE_NETWORK_CODES.has((_a = error.code) !== null && _a !== void 0 ? _a : '');
|
|
29
|
+
};
|
|
30
|
+
const getRetryDelay = (attempt, error) => {
|
|
31
|
+
var _a;
|
|
32
|
+
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 429) {
|
|
33
|
+
const retryAfter = error.response.headers['retry-after'];
|
|
34
|
+
if (retryAfter) {
|
|
35
|
+
const seconds = Number(retryAfter);
|
|
36
|
+
if (!isNaN(seconds)) {
|
|
37
|
+
return seconds * 1000;
|
|
38
|
+
}
|
|
39
|
+
const date = Date.parse(retryAfter);
|
|
40
|
+
if (!isNaN(date)) {
|
|
41
|
+
return Math.max(0, date - Date.now());
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const baseMs = 1000 * Math.pow(2, attempt);
|
|
46
|
+
const jitterMs = Math.random() * 500;
|
|
47
|
+
return baseMs + jitterMs;
|
|
48
|
+
};
|
|
49
|
+
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
|
19
50
|
class ScraperApiClient {
|
|
20
|
-
constructor(
|
|
51
|
+
constructor() {
|
|
21
52
|
this.transformScrapingParams = ({ scrapingParams, }) => {
|
|
22
|
-
const { jsRender } = scrapingParams, rest = __rest(scrapingParams, ["jsRender"]);
|
|
23
|
-
const transformed = Object.assign(Object.assign({}, (jsRender && { headless: 'html' })), rest);
|
|
53
|
+
const { jsRender, headless } = scrapingParams, rest = __rest(scrapingParams, ["jsRender", "headless"]);
|
|
54
|
+
const transformed = Object.assign(Object.assign({}, (headless ? { headless } : jsRender && { headless: 'html' })), rest);
|
|
24
55
|
return transformed;
|
|
25
56
|
};
|
|
26
57
|
this.transformResponse = ({ res }) => {
|
|
27
58
|
const content = res.data.results[0].content;
|
|
28
59
|
return Object.assign(Object.assign({}, res), { data: content });
|
|
29
60
|
};
|
|
30
|
-
this.scrape = async ({ scrapingParams }) => {
|
|
61
|
+
this.scrape = async ({ auth, scrapingParams, }) => {
|
|
62
|
+
var _a, _b, _c, _d, _e;
|
|
31
63
|
const transformedParams = this.transformScrapingParams({ scrapingParams });
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
64
|
+
const url = process.env.DECODO_SAPI_HOST || 'https://scraper-api.decodo.com';
|
|
65
|
+
let lastError;
|
|
66
|
+
for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
|
|
67
|
+
try {
|
|
68
|
+
const res = await axios_1.default.request({
|
|
69
|
+
url: `${url}/v2/scrape`,
|
|
70
|
+
method: 'POST',
|
|
71
|
+
headers: {
|
|
72
|
+
authorization: `Basic ${auth}`,
|
|
73
|
+
'x-integration': 'mcp',
|
|
74
|
+
},
|
|
75
|
+
timeout: 180000,
|
|
76
|
+
data: Object.assign({}, transformedParams),
|
|
77
|
+
});
|
|
78
|
+
return this.transformResponse({ res });
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
lastError = error;
|
|
82
|
+
if (attempt < MAX_RETRIES && axios_1.default.isAxiosError(error) && isRetryable(error)) {
|
|
83
|
+
const delayMs = getRetryDelay(attempt, error);
|
|
84
|
+
const reason = error.response
|
|
85
|
+
? `status ${error.response.status}`
|
|
86
|
+
: `network error ${error.code}`;
|
|
87
|
+
console.error(`[scraper-api-client] Retry ${attempt + 1}/${MAX_RETRIES} after ${reason}, waiting ${Math.round(delayMs)}ms`);
|
|
88
|
+
await sleep(delayMs);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (axios_1.default.isAxiosError(lastError)) {
|
|
95
|
+
const status = (_a = lastError.response) === null || _a === void 0 ? void 0 : _a.status;
|
|
96
|
+
let errorMessage = (_d = (_c = (_b = lastError.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : lastError.message;
|
|
97
|
+
if (status === 401) {
|
|
98
|
+
errorMessage = 'Authentication failed.';
|
|
99
|
+
}
|
|
100
|
+
if (status === 429) {
|
|
101
|
+
errorMessage = JSON.stringify((_e = lastError.response) === null || _e === void 0 ? void 0 : _e.data);
|
|
102
|
+
}
|
|
103
|
+
throw new Error(`Scraper API request failed (${status}): ${errorMessage}`);
|
|
104
|
+
}
|
|
105
|
+
throw lastError;
|
|
43
106
|
};
|
|
44
|
-
this.auth = auth;
|
|
45
107
|
}
|
|
46
108
|
}
|
|
47
109
|
exports.ScraperApiClient = ScraperApiClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scraper-api-client.js","sourceRoot":"","sources":["../../src/clients/scraper-api-client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scraper-api-client.js","sourceRoot":"","sources":["../../src/clients/scraper-api-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,kDAAyD;AAIzD,MAAM,WAAW,GAAG,IAAI,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AC,YAAY,CAAC,SAAS,CAAC,EAAE,CAAC;gBAClC,MAAM,MAAM,GAAG,MAAA,SAAS,CAAC,QAAQ,0CAAE,MAAM,CAAC;gBAC1C,IAAI,YAAY,GAAG,MAAA,MAAA,MAAA,SAAS,CAAC,QAAQ,0CAAE,IAAI,0CAAE,OAAO,mCAAI,SAAS,CAAC,OAAO,CAAC;gBAE1E,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;oBACnB,YAAY,GAAG,wBAAwB,CAAC;gBAC1C,CAAC;gBACD,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;oBACnB,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,MAAA,SAAS,CAAC,QAAQ,0CAAE,IAAI,CAAC,CAAC;gBAC1D,CAAC;gBAED,MAAM,IAAI,KAAK,CAAC,+BAA+B,MAAM,MAAM,YAAY,EAAE,CAAC,CAAC;YAC7E,CAAC;YACD,MAAM,SAAS,CAAC;QAClB,CAAC,CAAC;IACJ,CAAC;CAAA;AAxFD,4CAwFC"}
|
package/build/constants.js
CHANGED
|
@@ -1,11 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SCRAPER_API_TARGETS = void 0;
|
|
3
|
+
exports.SCRAPER_API_TARGETS = exports.TOOLSET = void 0;
|
|
4
|
+
var TOOLSET;
|
|
5
|
+
(function (TOOLSET) {
|
|
6
|
+
TOOLSET["WEB"] = "web";
|
|
7
|
+
TOOLSET["SEARCH"] = "search";
|
|
8
|
+
TOOLSET["ECOMMERCE"] = "ecommerce";
|
|
9
|
+
TOOLSET["SOCIAL_MEDIA"] = "social_media";
|
|
10
|
+
TOOLSET["AI"] = "ai";
|
|
11
|
+
})(TOOLSET || (exports.TOOLSET = TOOLSET = {}));
|
|
12
|
+
// todo: utils
|
|
4
13
|
var SCRAPER_API_TARGETS;
|
|
5
14
|
(function (SCRAPER_API_TARGETS) {
|
|
6
15
|
SCRAPER_API_TARGETS["GOOGLE_SEARCH"] = "google_search";
|
|
16
|
+
SCRAPER_API_TARGETS["GOOGLE_TRAVEL_HOTELS"] = "google_travel_hotels";
|
|
17
|
+
SCRAPER_API_TARGETS["GOOGLE_ADS"] = "google_ads";
|
|
18
|
+
SCRAPER_API_TARGETS["GOOGLE_LENS"] = "google_lens";
|
|
19
|
+
SCRAPER_API_TARGETS["GOOGLE_AI_MODE"] = "google_ai_mode";
|
|
7
20
|
SCRAPER_API_TARGETS["AMAZON_SEARCH"] = "amazon_search";
|
|
21
|
+
SCRAPER_API_TARGETS["AMAZON_PRODUCT"] = "amazon_product";
|
|
22
|
+
SCRAPER_API_TARGETS["AMAZON_PRICING"] = "amazon_pricing";
|
|
23
|
+
SCRAPER_API_TARGETS["AMAZON_SELLERS"] = "amazon_sellers";
|
|
24
|
+
SCRAPER_API_TARGETS["AMAZON_BESTSELLERS"] = "amazon_bestsellers";
|
|
25
|
+
SCRAPER_API_TARGETS["WALMART_SEARCH"] = "walmart_search";
|
|
26
|
+
SCRAPER_API_TARGETS["WALMART_PRODUCT"] = "walmart_product";
|
|
27
|
+
SCRAPER_API_TARGETS["TARGET_SEARCH"] = "target_search";
|
|
28
|
+
SCRAPER_API_TARGETS["TARGET_PRODUCT"] = "target_product";
|
|
29
|
+
SCRAPER_API_TARGETS["TIKTOK_POST"] = "tiktok_post";
|
|
30
|
+
SCRAPER_API_TARGETS["TIKTOK_SHOP_SEARCH"] = "tiktok_shop_search";
|
|
31
|
+
SCRAPER_API_TARGETS["TIKTOK_SHOP_PRODUCT"] = "tiktok_shop_product";
|
|
32
|
+
SCRAPER_API_TARGETS["TIKTOK_SHOP_URL"] = "tiktok";
|
|
33
|
+
SCRAPER_API_TARGETS["YOUTUBE_VIDEO"] = "youtube_video";
|
|
34
|
+
SCRAPER_API_TARGETS["YOUTUBE_METADATA"] = "youtube_metadata";
|
|
35
|
+
SCRAPER_API_TARGETS["YOUTUBE_CHANNEL"] = "youtube_channel";
|
|
36
|
+
SCRAPER_API_TARGETS["YOUTUBE_SUBTITLES"] = "youtube_subtitles";
|
|
37
|
+
SCRAPER_API_TARGETS["YOUTUBE_SEARCH"] = "youtube_search";
|
|
8
38
|
SCRAPER_API_TARGETS["REDDIT_POST"] = "reddit_post";
|
|
9
39
|
SCRAPER_API_TARGETS["REDDIT_SUBREDDIT"] = "reddit_subreddit";
|
|
40
|
+
SCRAPER_API_TARGETS["REDDIT_USER"] = "reddit_user";
|
|
41
|
+
SCRAPER_API_TARGETS["BING_SEARCH"] = "bing_search";
|
|
42
|
+
SCRAPER_API_TARGETS["CHATGPT"] = "chatgpt";
|
|
43
|
+
SCRAPER_API_TARGETS["PERPLEXITY"] = "perplexity";
|
|
10
44
|
})(SCRAPER_API_TARGETS || (exports.SCRAPER_API_TARGETS = SCRAPER_API_TARGETS = {}));
|
|
11
45
|
//# sourceMappingURL=constants.js.map
|
package/build/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAA,IAAY,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAA,IAAY,OAMX;AAND,WAAY,OAAO;IACjB,sBAAW,CAAA;IACX,4BAAiB,CAAA;IACjB,kCAAuB,CAAA;IACvB,wCAA6B,CAAA;IAC7B,oBAAS,CAAA;AACX,CAAC,EANW,OAAO,uBAAP,OAAO,QAMlB;AAED,cAAc;AACd,IAAY,mBAsCX;AAtCD,WAAY,mBAAmB;IAC7B,sDAA+B,CAAA;IAC/B,oEAA6C,CAAA;IAC7C,gDAAyB,CAAA;IACzB,kDAA2B,CAAA;IAC3B,wDAAiC,CAAA;IAEjC,sDAA+B,CAAA;IAC/B,wDAAiC,CAAA;IACjC,wDAAiC,CAAA;IACjC,wDAAiC,CAAA;IACjC,gEAAyC,CAAA;IAEzC,wDAAiC,CAAA;IACjC,0DAAmC,CAAA;IAEnC,sDAA+B,CAAA;IAC/B,wDAAiC,CAAA;IAEjC,kDAA2B,CAAA;IAC3B,gEAAyC,CAAA;IACzC,kEAA2C,CAAA;IAC3C,iDAA0B,CAAA;IAE1B,sDAA+B,CAAA;IAC/B,4DAAqC,CAAA;IACrC,0DAAmC,CAAA;IACnC,8DAAuC,CAAA;IACvC,wDAAiC,CAAA;IAEjC,kDAA2B,CAAA;IAC3B,4DAAqC,CAAA;IACrC,kDAA2B,CAAA;IAE3B,kDAA2B,CAAA;IAE3B,0CAAmB,CAAA;IACnB,gDAAyB,CAAA;AAC3B,CAAC,EAtCW,mBAAmB,mCAAnB,mBAAmB,QAsC9B"}
|
package/build/index.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
require("dotenv/config");
|
|
4
|
-
const process_1 = require("process");
|
|
5
4
|
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
import('mcps-logger/console');
|
|
9
|
-
}
|
|
5
|
+
const sapi_stdio_server_1 = require("./server/sapi-stdio-server");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
10
7
|
const parseEnvsOrExit = () => {
|
|
11
8
|
const envs = ['SCRAPER_API_USERNAME', 'SCRAPER_API_PASSWORD'];
|
|
12
9
|
for (const envKey of envs) {
|
|
13
10
|
if (!process.env[envKey]) {
|
|
14
|
-
|
|
11
|
+
console.error(`env ${envKey} missing`);
|
|
12
|
+
process.exit(1);
|
|
15
13
|
}
|
|
16
14
|
}
|
|
17
15
|
return {
|
|
@@ -19,17 +17,18 @@ const parseEnvsOrExit = () => {
|
|
|
19
17
|
sapiPassword: process.env['SCRAPER_API_PASSWORD'],
|
|
20
18
|
};
|
|
21
19
|
};
|
|
22
|
-
async
|
|
20
|
+
const main = async () => {
|
|
23
21
|
const transport = new stdio_js_1.StdioServerTransport();
|
|
24
22
|
// if there are no envs, some MCP clients will fail silently
|
|
25
23
|
const { sapiUsername, sapiPassword } = parseEnvsOrExit();
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
const auth = Buffer.from(`${sapiUsername}:${sapiPassword}`).toString('base64');
|
|
25
|
+
const sapiMcpServer = new sapi_stdio_server_1.ScraperAPIStdioServer({
|
|
26
|
+
auth,
|
|
27
|
+
toolsets: (0, utils_1.resolveToolsets)(process.env.TOOLSETS),
|
|
29
28
|
});
|
|
30
29
|
await sapiMcpServer.connect(transport);
|
|
31
30
|
console.error('MCP Server running on stdio');
|
|
32
|
-
}
|
|
31
|
+
};
|
|
33
32
|
main().catch(error => {
|
|
34
33
|
console.error('Fatal error in main():', error);
|
|
35
34
|
process.exit(1);
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,yBAAuB;AAEvB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,yBAAuB;AAEvB,wEAAiF;AACjF,kEAAmE;AACnE,mCAA0C;AAE1C,MAAM,eAAe,GAAG,GAA2B,EAAE;IACnD,MAAM,IAAI,GAAG,CAAC,sBAAsB,EAAE,sBAAsB,CAAC,CAAC;IAE9D,KAAK,MAAM,MAAM,IAAI,IAAI,EAAE,CAAC;QAC1B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YACzB,OAAO,CAAC,KAAK,CAAC,OAAO,MAAM,UAAU,CAAC,CAAC;YACvC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAED,OAAO;QACL,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAW;QAC3D,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAW;KAC5D,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,IAAI,GAAG,KAAK,IAAI,EAAE;IACtB,MAAM,SAAS,GAAG,IAAI,+BAAoB,EAAE,CAAC;IAE7C,4DAA4D;IAC5D,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,GAAG,eAAe,EAAE,CAAC;IAEzD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,YAAY,IAAI,YAAY,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAE/E,MAAM,aAAa,GAAG,IAAI,yCAAqB,CAAC;QAC9C,IAAI;QACJ,QAAQ,EAAE,IAAA,uBAAe,EAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;KAChD,CAAC,CAAC;IACH,MAAM,aAAa,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAEvC,OAAO,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;AAC/C,CAAC,CAAC;AAEF,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;IAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ScraperAPIBaseServer = void 0;
|
|
4
|
+
const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
5
|
+
const scraper_api_client_1 = require("../clients/scraper-api-client");
|
|
6
|
+
const tools_1 = require("../tools");
|
|
7
|
+
class ScraperAPIBaseServer {
|
|
8
|
+
constructor({ auth, toolsets = [] }) {
|
|
9
|
+
this.auth = '';
|
|
10
|
+
this.server = new mcp_js_1.McpServer({
|
|
11
|
+
name: 'decodo',
|
|
12
|
+
version: '1.1.0',
|
|
13
|
+
});
|
|
14
|
+
this.sapiClient = new scraper_api_client_1.ScraperApiClient();
|
|
15
|
+
this.auth = auth;
|
|
16
|
+
this.registerTools({ toolsets });
|
|
17
|
+
this.registerResources();
|
|
18
|
+
}
|
|
19
|
+
connect(transport) {
|
|
20
|
+
this.server.connect(transport);
|
|
21
|
+
}
|
|
22
|
+
registerTools({ toolsets }) {
|
|
23
|
+
if (toolsets.length === 0) {
|
|
24
|
+
this.registerAllTools();
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
for (const toolset of toolsets) {
|
|
28
|
+
const tools = ScraperAPIBaseServer.allTools.filter(tool => tool.toolset === toolset);
|
|
29
|
+
for (const tool of tools) {
|
|
30
|
+
tool.register({ server: this.server, sapiClient: this.sapiClient, auth: this.auth });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
registerAllTools() {
|
|
35
|
+
for (const tool of ScraperAPIBaseServer.allTools) {
|
|
36
|
+
tool.register({ server: this.server, sapiClient: this.sapiClient, auth: this.auth });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
registerResources() {
|
|
40
|
+
// todo: expose info about all targets available
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.ScraperAPIBaseServer = ScraperAPIBaseServer;
|
|
44
|
+
ScraperAPIBaseServer.allTools = [
|
|
45
|
+
new tools_1.ScrapeAsMarkdownTool(),
|
|
46
|
+
new tools_1.ScreenshotTool(),
|
|
47
|
+
new tools_1.GoogleSearchTool(),
|
|
48
|
+
new tools_1.GoogleAdsTool(),
|
|
49
|
+
new tools_1.GoogleLensTool(),
|
|
50
|
+
new tools_1.GoogleAiModeTool(),
|
|
51
|
+
new tools_1.GoogleTravelHotelsTool(),
|
|
52
|
+
new tools_1.AmazonSearchTool(),
|
|
53
|
+
new tools_1.AmazonProductTool(),
|
|
54
|
+
new tools_1.AmazonPricingTool(),
|
|
55
|
+
new tools_1.AmazonSellersTool(),
|
|
56
|
+
new tools_1.AmazonBestsellersTool(),
|
|
57
|
+
new tools_1.WalmartSearchTool(),
|
|
58
|
+
new tools_1.WalmartProductTool(),
|
|
59
|
+
new tools_1.TargetSearchTool(),
|
|
60
|
+
new tools_1.TargetProductTool(),
|
|
61
|
+
new tools_1.TiktokPostTool(),
|
|
62
|
+
new tools_1.TiktokShopSearchTool(),
|
|
63
|
+
new tools_1.TiktokShopProductTool(),
|
|
64
|
+
new tools_1.TiktokShopUrlTool(),
|
|
65
|
+
new tools_1.YoutubeMetadataTool(),
|
|
66
|
+
new tools_1.YoutubeChannelTool(),
|
|
67
|
+
new tools_1.YoutubeSubtitlesTool(),
|
|
68
|
+
new tools_1.YoutubeSearchTool(),
|
|
69
|
+
new tools_1.RedditPostTool(),
|
|
70
|
+
new tools_1.RedditSubredditTool(),
|
|
71
|
+
new tools_1.RedditUserTool(),
|
|
72
|
+
new tools_1.BingSearchTool(),
|
|
73
|
+
new tools_1.ChatGPTTool(),
|
|
74
|
+
new tools_1.PerplexityTool(),
|
|
75
|
+
];
|
|
76
|
+
//# sourceMappingURL=sapi-base-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sapi-base-server.js","sourceRoot":"","sources":["../../src/server/sapi-base-server.ts"],"names":[],"mappings":";;;AAAA,oEAAoE;AAEpE,sEAAiE;AACjE,oCA+BkB;AAKlB,MAAa,oBAAoB;IAO/B,YAAY,EAAE,IAAI,EAAE,QAAQ,GAAG,EAAE,EAAyC;QAF1E,SAAI,GAAW,EAAE,CAAC;QAGhB,IAAI,CAAC,MAAM,GAAG,IAAI,kBAAS,CAAC;YAC1B,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,OAAO;SACjB,CAAC,CAAC;QACH,IAAI,CAAC,UAAU,GAAG,IAAI,qCAAgB,EAAE,CAAC;QAEzC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAEjB,IAAI,CAAC,aAAa,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;QAEjC,IAAI,CAAC,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IAAI,wBAAgB,EAAE;IACtB,IAAI,yBAAiB,EAAE;IACvB,IAAI,yBAAiB,EAAE;IACvB,IAAI,yBAAiB,EAAE;IACvB,IAAI,6BAAqB,EAAE;IAC3B,IAAI,yBAAiB,EAAE;IACvB,IAAI,0BAAkB,EAAE;IACxB,IAAI,wBAAgB,EAAE;IACtB,IAAI,yBAAiB,EAAE;IACvB,IAAI,sBAAc,EAAE;IACpB,IAAI,4BAAoB,EAAE;IAC1B,IAAI,6BAAqB,EAAE;IAC3B,IAAI,yBAAiB,EAAE;IACvB,IAAI,2BAAmB,EAAE;IACzB,IAAI,0BAAkB,EAAE;IACxB,IAAI,4BAAoB,EAAE;IAC1B,IAAI,yBAAiB,EAAE;IACvB,IAAI,sBAAc,EAAE;IACpB,IAAI,2BAAmB,EAAE;IACzB,IAAI,sBAAc,EAAE;IACpB,IAAI,sBAAc,EAAE;IACpB,IAAI,mBAAW,EAAE;IACjB,IAAI,sBAAc,EAAE;CACrB,AA/Bc,CA+Bb"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ScraperAPIHttpServer = void 0;
|
|
4
|
+
const sapi_base_server_1 = require("./sapi-base-server");
|
|
5
|
+
class ScraperAPIHttpServer extends sapi_base_server_1.ScraperAPIBaseServer {
|
|
6
|
+
constructor({ toolsets = [], auth }) {
|
|
7
|
+
super({ auth, toolsets });
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.ScraperAPIHttpServer = ScraperAPIHttpServer;
|
|
11
|
+
//# sourceMappingURL=sapi-http-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sapi-http-server.js","sourceRoot":"","sources":["../../src/server/sapi-http-server.ts"],"names":[],"mappings":";;;AAEA,yDAA0D;AAG1D,MAAa,oBAAqB,SAAQ,uCAAoB;IAK5D,YAAY,EAAE,QAAQ,GAAG,EAAE,EAAE,IAAI,EAAyC;QACxE,KAAK,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC5B,CAAC;CACF;AARD,oDAQC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ScraperAPIStdioServer = void 0;
|
|
4
|
+
const sapi_base_server_1 = require("./sapi-base-server");
|
|
5
|
+
class ScraperAPIStdioServer extends sapi_base_server_1.ScraperAPIBaseServer {
|
|
6
|
+
constructor({ auth, toolsets = [] }) {
|
|
7
|
+
super({ auth, toolsets });
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.ScraperAPIStdioServer = ScraperAPIStdioServer;
|
|
11
|
+
//# sourceMappingURL=sapi-stdio-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sapi-stdio-server.js","sourceRoot":"","sources":["../../src/server/sapi-stdio-server.ts"],"names":[],"mappings":";;;AAEA,yDAA0D;AAG1D,MAAa,qBAAsB,SAAQ,uCAAoB;IAK7D,YAAY,EAAE,IAAI,EAAE,QAAQ,GAAG,EAAE,EAAyC;QACxE,KAAK,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC5B,CAAC;CACF;AARD,sDAQC"}
|
package/build/server.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
require("dotenv/config");
|
|
7
|
+
const express_1 = __importDefault(require("express"));
|
|
8
|
+
const streamableHttp_js_1 = require("@modelcontextprotocol/sdk/server/streamableHttp.js");
|
|
9
|
+
const sapi_http_server_1 = require("./server/sapi-http-server");
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
const app = (0, express_1.default)();
|
|
12
|
+
app.use(express_1.default.json());
|
|
13
|
+
app.get('/mcp', (_req, res) => {
|
|
14
|
+
res.status(200).send('server up, use POST /mcp to see available tools');
|
|
15
|
+
});
|
|
16
|
+
app.post('/mcp', async (req, res) => {
|
|
17
|
+
const auth = req.headers.authorization;
|
|
18
|
+
if (!auth) {
|
|
19
|
+
res.status(401).send('Unauthorized');
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const parts = auth.split(' ');
|
|
23
|
+
if (parts.length !== 2 || parts[0] !== 'Basic') {
|
|
24
|
+
res.status(401).send("Valid 'Basic' authorization required");
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const token = parts[1];
|
|
28
|
+
const toolsets = (0, utils_1.resolveToolsets)(req.query.toolsets);
|
|
29
|
+
const server = new sapi_http_server_1.ScraperAPIHttpServer({ toolsets, auth: token });
|
|
30
|
+
const transport = new streamableHttp_js_1.StreamableHTTPServerTransport({
|
|
31
|
+
sessionIdGenerator: undefined,
|
|
32
|
+
enableJsonResponse: true,
|
|
33
|
+
});
|
|
34
|
+
res.on('close', () => {
|
|
35
|
+
transport.close();
|
|
36
|
+
});
|
|
37
|
+
await server.connect(transport);
|
|
38
|
+
await transport.handleRequest(req, res, req.body);
|
|
39
|
+
});
|
|
40
|
+
app.get('/healthz', (_req, res) => {
|
|
41
|
+
res.status(200).send('ok');
|
|
42
|
+
});
|
|
43
|
+
const port = parseInt(process.env.PORT || '3000');
|
|
44
|
+
app
|
|
45
|
+
.listen(port, () => {
|
|
46
|
+
console.log(`Demo MCP Server running on http://localhost:${port}/mcp`);
|
|
47
|
+
console.log(`API host: ${process.env.DECODO_SAPI_HOST}`);
|
|
48
|
+
})
|
|
49
|
+
.on('error', (error) => {
|
|
50
|
+
console.error('Server error:', error);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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