WebcrawlerAPI MCP服务器
WebcrawlerAPI 是一个强大的网络抓取和网站爬行服务,允许您轻松地从任何网站提取数据。
此MCP(模型上下文协议)服务器将WebcrawlerAPI的抓取功能直接集成到与MCP兼容的应用程序(如Claude Code)中,从而实现了AI工作流中的集成。在开始使用您的免费API密钥 WebcrawlerAPI仪表板.
设置
- 从获取API密钥 WebcrawlerAPI仪表板
- 设置环境变量:```bash
export WEBCRAWLER_API_KEY="your-api-key-here"
## 使用Claude代码
使用npx将此服务器添加到您的Claude Code配置中:```bash
npx webcrawler-mcp
或者添加到MCP设置配置中:```json
{
"mcpServers": {
"webcrawler": {
"command": "npx",
"args": ["-y", "webcrawler-mcp"],
"env": {
"WEBCRAWLER_API_KEY": "your-api-key-here"
}
}
}
}
## 可用工具
### webcrawler刮
从任何网页中抓取内容并将其作为markdown返回。
**参数:**
- `url` (必填):要抓取的网页的URL
- `prompt` (可选):从页面提取特定信息的可选提示
**示例用法:**```
Use the webcrawler-scrape tool to get the content from https://example.com
提示进行目标提取:```
Use the webcrawler-scrape tool to scrape https://news.ycombinator.com with the prompt "Extract all article titles and their corresponding URLs"
该工具将抓取的内容作为markdown返回,同时返回页面标题和HTTP状态代码。当使用提示时,API将重点提取您请求的特定信息。
## 作为独立应用程序运行
您还可以将服务器作为独立应用程序运行:
### 通过npm```bash
npm install
npm run build
npm start
通过npx```bash
npx webcrawler-mcp
### HTTP模式
要在HTTP模式而不是stdio下运行,请执行以下操作:```bash
USE_HTTP=true npx webcrawler-mcp
# or
npm run start:http
默认情况下,HTTP服务器将在端口8080上启动,端点为:
- 健康检查:
http://localhost:8080/health - MCP端点:
http://localhost:8080/mcp
环境变量
WEBCRAWLER_API_KEY:您的WebcrawlerAPI.com API密钥(必需)USE_HTTP:设置为“true”以使用HTTP传输而不是stdioPORT:HTTP服务器端口(默认值:8080)
发展```bash
npm install
npm run dev # Watch mode
npm run build
```
