一个基于Python的MCP(https://modelcontextprotocol.io/introduction)网络爬虫项目,用于提取并保存网站内容。
git clone https://github.com/yourusername/webcrawler.git
cd webcrawler
pip install -r requirements.txt
export OUTPUT_PATH=./output # 设置您首选的输出目录
爬取的内容将以markdown格式保存在指定的输出目录中。
服务器可以通过环境变量进行配置:
OUTPUT_PATH:已保存文件的默认输出目录MAX_CONCURRENT_REQUESTS:最大并发请求数(默认值:5)REQUEST_TIMEOUT:请求超时时间(秒,默认值:330)使用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
mcp call extract_content --url "https://example.com" --output_path "example.md"
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 文件。