by ddipass
一个基于 Crawl4AI 的 Model Context Protocol (MCP) 服务器,为 Amazon Q Developer 和其他 AI 工具提供强大的网页爬取、学术搜索和智能研究功能。
# 1. 克隆项目 git clone https://github.com/ddipass/context-scraper-mcp-server.git cd context-scraper-mcp-server # 2. 使用 uv 同步依赖 uv sync # 3. 激活虚拟环境 source .venv/bin/activate # 4. 运行 Crawl4AI 设置 crawl4ai-setup
# 1. 克隆项目 git clone https://github.com/ddipass/context-scraper-mcp-server.git cd context-scraper-mcp-server # 2. 创建虚拟环境 python -m venv .venv source .venv/bin/activate # Linux/macOS # 或 .venv\Scripts\activate # Windows # 3. 安装项目依赖 pip install -e . # 4. 安装浏览器依赖 python -m playwright install chromium # 5. 运行 Crawl4AI 设置 crawl4ai-setup
我们推荐使用 uv - 这是一个用 Rust 构建的现代 Python 包管理器:
安装 uv:
# macOS/Linux curl -LsSf https://astral.sh/uv/install.sh | sh # Windows powershell -c "irm https://astral.sh/uv/install.ps1 | iex" # 或使用 pip pip install uv
在 ~/.aws/amazonq/mcp.json
文件中添加以下配置:
*Configuration content*
重要: 请将 /absolute/path/to/context-scraper-mcp-server
替换为你的实际项目路径。
cd context-scraper-mcp-server pwd # 将输出的路径复制到配置文件中
启动 Amazon Q Developer 后,你应该能看到 ContextScraper 工具可用。可以使用以下命令测试:
使用 system_status 工具检查服务器状态
academic_search
- 多数据源学术搜索 (Google Scholar, arXiv, PubMed)crawl
- 基础网页爬取crawl_stealth
- 隐身模式爬取crawl_with_geolocation
- 地理位置伪装爬取crawl_with_retry
- 重试机制爬取crawl_with_intelligence
- 智能爬取模式configure_crawl_settings
- 爬取参数配置quick_config_content_limit
- 快速设置内容显示限制quick_config_word_threshold
- 快速设置词数阈值system_status
- 系统状态监控experimental_claude_analysis
- Claude AI 内容分析 (需要API配置)# 在 arXiv 搜索机器学习论文 result = await academic_search("machine learning transformers", "arxiv") # 在 PubMed 搜索医学文献 result = await academic_search("COVID-19 vaccine effectiveness", "pubmed") # 在 Google Scholar 搜索 result = await academic_search("climate change", "google_scholar")
# 基础爬取 result = await crawl("https://example.com") # 隐身模式爬取 result = await crawl_stealth("https://protected-site.com") # 智能爬取 result = await crawl_with_intelligence("https://news-site.com", "smart") # 地理位置伪装爬取 result = await crawl_with_geolocation("https://geo-restricted.com", "newyork") # 重试机制爬取 result = await crawl_with_retry("https://unstable-site.com", max_retries=3)
# 快速设置内容显示限制 result = await quick_config_content_limit(5000) # 快速设置词数阈值 result = await quick_config_word_threshold(100) # 查看系统状态 result = await system_status() # 配置爬取参数 result = await configure_crawl_settings("update", "content_limits", markdown_display_limit=8000)
# Claude AI 内容分析 (需要配置API) result = await experimental_claude_analysis("分析这段文本的主要观点", "general", enable_claude=True)
context-scraper-mcp-server/
├── server_v9.py # 🚀 主服务器文件 (当前版本)
├── server_v8.py # V8 版本服务器
├── server_v7.py # V7 版本服务器
├── v9_core/ # 🧠 V9 核心模块
│ ├── intent_analyzer.py # 🎯 用户意图分析引擎
│ ├── crawl_config_manager.py # ⚙️ 爬取配置管理器
│ └── config_manager.py # 📋 通用配置管理器
├── v9_config/ # 📋 V9 配置文件
│ └── crawl_config.json # 🔧 爬取参数配置
├── config/ # 🗂️ 通用配置目录
│ ├── claude_config_example.json # Claude API 配置示例
│ └── v6_config/ # 历史版本配置
├── docs/ # 📚 文档目录
│ ├── architecture/ # 🏗️ 架构文档
│ ├── development/ # 🔧 开发文档
│ └── versions/ # 📋 版本文档
├── legacy/ # 📦 历史版本和备份
├── .venv/ # 🐍 Python 虚拟环境
├── pyproject.toml # 📋 项目配置文件
├── uv.lock # 🔒 依赖锁定文件
└── README.md # 📖 项目说明文档
server_v9.py (主服务器)
├── v9_core/
│ ├── intent_analyzer.py # 用户意图分析 (独立模块)
│ └── crawl_config_manager.py # 爬取配置管理 (独立模块)
├── v9_config/
│ └── crawl_config.json # 配置文件 (JSON格式)
└── 外部依赖
├── crawl4ai # 网页爬取引擎
├── mcp # Model Context Protocol
└── aiohttp # 异步HTTP客户端
server_v9.py
- 主服务器,集成所有V9功能,提供MCP工具接口intent_analyzer.py
- 分析用户意图,支持搜索、爬取、研究等多种意图类型crawl_config_manager.py
- 管理爬取配置,支持运行时动态调整参数crawl_config.json
- 存储用户偏好和系统配置analyze_user_intent()
(v9_core/intent_analyzer.py)SearchEngineIntent
, IntentType
UserIntent
(包含confidence字段)configure_crawl_settings()
, reload_crawl_config()
get_crawl_config()
(v9_core/crawl_config_manager.py)v9_config/crawl_config.json
quick_config_content_limit()
, quick_config_word_threshold()
activate_virtual_environment()
(server_v9.py)crawl()
, crawl_stealth()
, crawl_with_geolocation()
, crawl_with_retry()
crawl_with_intelligence()
crawl_multiple()
(如果存在)academic_search()
deep_crawl_count
in academic_search()
experimental_claude_analysis()
system_status()
如果需要使用 Claude API 功能,可以配置 config/claude_config_example.json
:
*Configuration content*
编辑 v9_config/crawl_config.json
来调整爬取参数:
*Configuration content*
找不到 mcp 命令
# 确保虚拟环境已激活 source .venv/bin/activate which mcp
路径配置错误
# 获取正确的绝对路径 cd context-scraper-mcp-server pwd
权限问题
# 检查文件权限 ls -la ~/.aws/amazonq/mcp.json chmod 644 ~/.aws/amazonq/mcp.json
# 直接运行服务器测试 cd context-scraper-mcp-server source .venv/bin/activate .venv/bin/mcp run server_v9.py
欢迎提交 Issue 和 Pull Request!
本项目采用 MIT 许可证。
No version information available