WebScraping.AI MCP 服务器基于 Model Context Protocol (MCP),可与大型语言模型(LLMs)集成。它实现了 Model Context Protocol,支持任何启用 MCP 的 LLM 平台,为网页数据处理和语言模型交互提供了便利。
WebScraping.AI 提供了一个基于 Model Context Protocol (MCP) 的服务器,用于与大型语言模型(LLMs)集成。要使用该服务器,你可以按照下面的步骤进行操作。
git clone https://github.com/webscraping-ai/webscraping-ai-mcp-server.git
cd webscraping-ai-mcp-server
npm install
创建并编辑 .env 文件,添加以下环境变量:
WEBSCRAPING_AI_API_KEY:你的 WebScraping.AI API 密钥示例 .env 文件内容如下:
WEBSCRAPING_AI_API_KEY=your-api-key
# Optional proxy settings
HTTP_PROXY=http://example.com:1080
HTTPS_PROXY=https://example.com:1080
NO_PROXY=localhost,127.0.0.1
# 日志级别选项:debug, info, warning, error, critical
LOG_LEVEL=info
以下是一个使用 webscraping-ai-mcp 命令行工具的示例:
npx webscraping-ai-mcp --url https://example.com --output json
--url:要爬取的目标 URL(必填)--output:输出格式,支持 text 或 json{
"name": "webscraping_ai_fetch",
"description": "从目标 URL 抓取网页内容。",
"parameters": {
"type": "object",
"properties": {
"url": { "type": "string", "description": "要抓取的 URL" },
"output_format": { "type": "string", "enum": ["text", "json"], "default": "text" }
}
}
}
{
"name": "webscraping_ai_analyze",
"description": "分析目标网站的技术细节。",
"parameters": {
"type": "object",
"properties": {
"url": { "type": "string", "description": "要分析的 URL" }
}
}
}
{
"name": "webscraping_ai_account",
"description": "获取 WebScraping.AI 账户信息。",
"parameters": {
"type": "object",
"properties": {}
}
}
服务器提供强大的错误处理功能,包括:
{
"error": {
"code": "403",
"message": "访问被拒绝",
"details": "请求超过了 API 配额"
}
}
服务器支持通过以下步骤与 LLM 集成:
npm install web-scraping-ai mcp-service
const { MCPService } = require('mcp-service');
const service = new MCPService({
apiKey: 'your-api-key',
provider: 'openai'
});
npm run dev
npm test
本项目遵循 MIT 许可证,具体内容如下: