MCP Go Colly 爬虫
](https://smithery.ai/server/@bneil/mcp-go-colly)
概述
MCP Go Colly是一个复杂的网络爬虫框架,它将模型上下文协议(MCP)与功能强大的Colly网络抓取库相结合。该项目旨在为大型语言模型(LLM)应用提供一种灵活且可扩展的网页内容提取解决方案。
功能
- 可配置深度和域名限制的并发网页爬取
- 工具爬取的MCP服务器集成
- 优雅关闭处理
- 强大的错误处理和结果格式化
- 支持单个URL和批量URL爬取
从源代码构建
前提条件
- Go 1.21或更高版本
- 使用Makefile命令的Make
安装
- 克隆仓库:
git clone https://github.com/yourusername/mcp-go-colly.git
cd mcp-go-colly- 安装依赖项:
make deps建筑
该项目包含一个Makefile,其中包含几个有用的命令:
# Build the binary (outputs to bin/mcp-go-colly)
make build
# Build for all platforms (Linux, Windows, macOS)
make build-all
# Run tests
make test
# Clean build artifacts
make clean
# Format code
make fmt
# Run linter
make lint所有二进制文件都将生成在 bin/ 目录。
然后你需要在(配置文件)中添加以下配置 claude_desktop_config.json 根据上面的信息,执行如下指令:
{
"mcpServers": {
"web-scraper": {
"command": "/mcp-go-colly/bin/mcp-go-colly"
}
}
}用法
作为MCP工具
爬虫被实现为一个MCP工具,可以通过以下参数进行调用:
{
"urls": ["https://example.com"], // Single URL or array of URLs
"max_depth": 2 // Optional: Maximum crawl depth (default: 2)
}示例MCP工具调用
result, err := crawlerTool.Call(ctx, mcp.CallToolRequest{
Params: struct{ Arguments map[string]interface{} }{
Arguments: map[string]interface{}{
"urls": []string{"https://example.com"},
"max_depth": 2,
},
},
})配置选项
max_depth设置最大抓取深度(默认:2)urls要抓取的单个URL字符串或URL数组- 根据提供的URL,会自动应用域限制
贡献
- 克隆仓库
- 创建你的功能分支
- 提交您的更改
- 推送到分支
- 创建拉取请求
许可证
麻省理工
致谢
- Colly 网络爬虫框架
- Mark3 Labs MCP 项目
