数据抓取器维护 MCP
一个全面的模型上下文协议(MCP)服务器,通过智能浏览器检查、选择器生成和代码更新来自动化网页抓取器的维护。
📁 项目结构
mcp/
├── src/ # TypeScript source files
│ ├── server.ts # Main MCP server implementation
│ ├── browser-manager.ts # Browser automation and management
│ ├── selector-generator.ts # Selector generation and scoring
│ └── types.ts # Type definitions
├── dist/ # Compiled JavaScript files
│ ├── server.js # Main MCP server (executable)
│ ├── browser-manager.js # Browser automation
│ ├── selector-generator.js # Selector intelligence
│ └── types.js # Type definitions
├── config/ # Configuration files
│ ├── test-config.json # Test configuration
│ ├── claude-desktop-config.json # Claude Desktop setup
│ └── *.json # Various scraper configurations
├── examples/ # Usage examples and documentation
├── docs/ # Documentation files
├── scripts/ # Build and utility scripts
├── package.json # Project configuration
└── tsconfig.json # TypeScript configuration🚀 快速入门
安装依赖项
cd mcp
npm install2. 构建项目
npm run build3. 运行服务器
npm start🛠️ 可用的MCP工具
配置管理
load_scraper_config加载爬虫配置文件update_config更新配置,使用新的选择器映射
浏览器操作
initialize_browser- 启动浏览器(无头/可见模式)navigate_to_page导航至目标网址take_screenshot捕获调试截图close_browser清理浏览器资源
元素检查
inspect_field_manually交互式视觉元素选择auto_detect_fieldAI驱动的自动元素检测validate_selectors测试选择器的可靠性和性能generate_selectors创建多个带有评分的选项器变体test_extraction使用当前选择器进行测试数据提取
维护与代码生成
run_maintenance_check全面的抓取器健康分析generate_extractor_code多语言代码生成
📖 使用方法
为Claude Desktop
添加到您的Claude桌面配置中:
{
"mcpServers": {
"scraper-maintenance": {
"command": "node",
"args": ["/path/to/mcp/dist/server.js"],
"env": {
"NODE_ENV": "production"
}
}
}
}对于Cursor
添加到你的Cursor MCP配置中:
{
"mcpServers": {
"scraper-maintenance": {
"command": "node",
"args": ["/path/to/mcp/dist/server.js"],
"env": {
"NODE_ENV": "production"
}
}
}
}🔧 开发
构建
npm run build开发模式
npm run dev测试
npm test