MD MCP网络爬虫项目
基于Python的MCP(https://modelcontextprotocol.io/introduction)用于提取和保存网站内容的网络爬虫。
特性
- 提取网站内容并另存为markdown文件
- 地图网站结构和链接
- 批量处理多个URL
- 可配置的输出目录
安装
- 克隆存储库:
git clone https://github.com/yourusername/webcrawler.git
cd webcrawler- 安装依赖项:
pip install -r requirements.txt- 可选:配置环境变量:
export OUTPUT_PATH=./output # Set your preferred output directory输出
爬网内容以markdown格式保存在指定的输出目录中。
配置
服务器可以通过环境变量进行配置:
OUTPUT_PATH:保存文件的默认输出目录MAX_CONCURRENT_REQUESTS:最大并行请求数(默认值:5)REQUEST_TIMEOUT:请求超时(秒)(默认值:30)
克劳德设置
使用FastMCP进行安装 fastmcp install server.py
或用户自定义设置,直接使用fastmcp运行
"Crawl Server": {
"command": "fastmcp",
"args": [
"run",
"/Users/mm22/Dev_Projekte/servers-main/src/Webcrawler/server.py"
],
"env": {
"OUTPUT_PATH": "/Users/user/Webcrawl"
}发展
现场开发
fastmcp dev server.py --with-editable .调试
它有助于使用https://modelcontextprotocol.io/docs/tools/inspector用于调试
例子
示例1:提取并保存内容
mcp call extract_content --url "https://example.com" --output_path "example.md"示例2:创建内容索引
mcp call scan_linked_content --url "https://example.com" | \
mcp call create_index --content_map - --output_path "index.md"贡献
- 分叉存储库
- 创建要素分支(
git checkout -b feature/AmazingFeature) - 提交您的更改(
git commit -m 'Add some AmazingFeature') - 推到分支(
git push origin feature/AmazingFeature) - 打开拉取请求
许可证
根据MIT许可证分发。看 LICENSE 了解更多信息。
需求
- Python 3.7+
- FastMCP(紫外线管安装FastMCP)
- requirements.txt中列出的依赖项
