hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
Integrations
The MCP server provides integration with Docker, allowing users to run the server in a containerized environment and integrate it with existing Crawlab Docker Compose setups.
The MCP server documentation uses Mermaid for architecture diagrams, illustrating the communication flow between components.
The MCP server integrates with OpenAI as an LLM provider, allowing AI applications to interact with Crawlab through the MCP protocol. The architecture shows OpenAI as one of the supported LLM providers for processing natural language queries.
Crawlab MCP 服务器
这是 Crawlab 的模型上下文协议 (MCP) 服务器,允许 AI 应用程序与 Crawlab 的功能进行交互。
概述
MCP 服务器为 AI 应用程序访问 Crawlab 的功能提供了标准化的方式,包括:
- 蜘蛛管理(创建、读取、更新、删除)
- 任务管理(运行、取消、重启)
- 文件管理(读、写)
- 资源访问(蜘蛛、任务)
建筑学
MCP 服务器/客户端架构促进了 AI 应用程序和 Crawlab 之间的通信:
通信流程
- 用户查询:用户向 MCP 客户端发送自然语言查询
- LLM 处理:客户端将查询转发给 LLM 提供商(例如 Claude、OpenAI)
- 工具选择:LLM 识别必要的工具并生成工具调用
- 工具执行:客户端向 MCP 服务器发送工具调用
- API 交互:服务器执行相应的 Crawlab API 请求
- 响应生成:结果通过服务器流回到客户端,再到 LLM
- 用户响应:客户端向用户提供最终的可读响应
安装和使用
选项 1:作为 Python 包安装
您可以将 MCP 服务器安装为 Python 包,它提供了方便的 CLI:
安装后,您可以使用 CLI:
选项 2:本地运行
先决条件
- Python 3.8+
- Crawlab 实例正在运行并可访问
- 来自 Crawlab 的 API 令牌
配置
- 将
.env.example
文件复制到.env
:Copy - 使用您的 Crawlab API 详细信息编辑
.env
文件:Copy
本地运行
- 安装依赖项:Copy
- 运行服务器:Copy
使用 Docker 运行
- 构建 Docker 镜像:Copy
- 运行容器:Copy
与 Docker Compose 集成
要将 MCP 服务器添加到您现有的 Crawlab Docker Compose 设置中,请将以下服务添加到您的docker-compose.yml
中:
与 AI 应用程序一起使用
MCP 服务器使 AI 应用能够通过自然语言与 Crawlab 进行交互。按照上面的架构图,MCP 系统的使用方法如下:
建立连接
- 启动 MCP 服务器:确保您的 MCP 服务器正在运行并且可以访问
- 配置 AI 客户端:将您的 AI 应用程序连接到 MCP 服务器
示例:与 Claude Desktop 一起使用
- 打开 Claude 桌面
- 前往“设置”>“MCP 服务器”
- 使用您的 MCP 服务器的 URL 添加新服务器(例如
http://localhost:8000
) - 在与 Claude 的对话中,您现在可以通过用自然语言描述您想要做的事情来使用 Crawlab 功能
交互示例
根据我们的架构,以下是与系统交互的示例:
创建一个蜘蛛:
运行任务:
可用命令
您可以使用自然语言命令与系统进行交互,例如:
- “列出我所有的蜘蛛”
- “根据这些规格创建一个新的蜘蛛……”
- “向我展示名为 X 的蜘蛛的代码”
- “使用此代码更新 spider X 中的 main.py 文件...”
- “运行 Spider X 并在完成后通知我”
- “向我展示 Spider X 上次运行的结果”
可用资源和工具
这些是支持自然语言交互的底层工具:
资源
spiders
:列出所有蜘蛛tasks
:列出所有任务
工具
蜘蛛管理
get_spider
:获取特定蜘蛛的详细信息create_spider
:创建一个新的蜘蛛update_spider
:更新现有的蜘蛛delete_spider
:删除蜘蛛
任务管理
get_task
:获取特定任务的详细信息run_spider
:运行蜘蛛cancel_task
:取消正在运行的任务restart_task
:重新启动任务get_task_logs
:获取任务日志
文件管理
get_spider_files
:列出蜘蛛的文件get_spider_file
:获取特定文件的内容save_spider_file
:将内容保存到文件
This server cannot be installed
模型上下文协议服务器允许AI应用程序通过自然语言与Crawlab的功能进行交互,实现蜘蛛管理、任务执行和文件操作。
- Overview
- Architecture
- Installation and Usage
- Integration with Docker Compose
- Using with AI Applications
- Available Resources and Tools