项目简介

Conductor Gateway是一个强大的桥接服务,旨在将您的Web应用程序与Conductor智能体执行系统无缝集成。它通过Server-Sent Events (SSE) 提供实时智能体执行的流式更新,并作为MCP服务器,提供一系列Conductor命令行工具作为可调用功能,从而赋能LLM应用。

主要功能点

  • 实时智能体执行: 支持SSE流,实时获取智能体任务的执行状态和结果,支持多种输入格式(如文本、输入指令、直接命令)。
  • 丰富的MCP工具: 封装了13+ Conductor CLI的强大功能,包括智能体列出、详情、验证,无状态/上下文执行,交互式会话,系统管理(备份、恢复、迁移),以及模板安装和配置等。
  • 生产级架构: 基于FastAPI构建,提供高性能异步API和自动OpenAPI文档;支持Docker部署和YAML配置管理。
  • 质量保证: 包含全面的单元、集成和API测试,通过GitHub Actions实现自动化CI/CD。

安装步骤

  1. 克隆仓库:
    git clone https://github.com/primoia/conductor-gateway.git
    cd conductor-gateway
  2. 安装Poetry: 如果尚未安装,请运行:
    curl -sSL https://install.python-poetry.org | python3 -
  3. 安装依赖:
    poetry install
  4. 配置Conductor项目路径: 复制示例配置文件并根据您的Conductor项目路径进行修改。
    cp config.yaml.example config.yaml
    # 编辑 config.yaml 文件,设置 conductor.project_path 为您的 Conductor 项目根路径
    # 例如:
    # conductor:
    #   project_path: "/your/path/to/conductor_project"
  5. 启动服务器:
    poetry run python src/main.py
    或者使用Docker部署:
    docker build -t conductor-gateway .
    docker-compose up -d # 或使用:docker run -p 5006:5006 -p 8006:8006 conductor-gateway

服务器配置(供MCP客户端使用)

Conductor Gateway同时运行一个HTTP API服务器(默认端口5006)和一个MCP服务器(默认端口8006)。您的MCP客户端需要连接到这个MCP服务器以调用其提供的工具。

以下是典型的MCP客户端连接配置,您需要将'<your-gateway-host>'替换为Conductor Gateway运行的实际IP地址或域名,'8006'替换为您的MCP服务器实际端口(如果已修改)。

{
  "mcpServers": {
    "ConductorGatewayMCP": {
      "url": "http://<your-gateway-host>:8006/sse",
      "reconnect": true,
      "reconnectInterval": 1000,
      "maxReconnectAttempts": 5,
      "timeout": 30000,
      "transport": "sse"
    }
  }
}

配置参数说明:

  • 'mcpServers': 定义MCP服务器连接的映射。
  • 'ConductorGatewayMCP': 您可以为这个MCP服务器连接指定任何有意义的名称。
  • 'url': MCP服务器的完整URL,通常是'http://<主机地址>:<MCP端口>/sse'。默认端口为8006。
  • 'reconnect': 如果连接断开,是否尝试重新连接。
  • 'reconnectInterval': 重新连接尝试之间的延迟(毫秒)。
  • 'maxReconnectAttempts': 最大重新连接尝试次数。
  • 'timeout': 连接或请求的超时时间(毫秒)。
  • 'transport': 指定使用的传输协议,此处为Server-Sent Events (SSE)。

基本使用方法

  • 健康检查: 确认Gateway服务正在运行。
    curl http://localhost:5006/health
  • 同步执行命令: 直接向智能体发送命令并等待结果。
    curl -X POST http://localhost:5006/execute \
      -H "Content-Type: application/json" \
      -d '{
        "input": "List available agents"
      }'
  • 流式执行(SSE):
    1. 启动执行,获取任务ID:
      curl -X POST http://localhost:5006/api/v1/stream-execute \
        -H "Content-Type: application/json" \
        -d '{
          "input": "Execute agent with real-time updates"
        }'
      响应会包含一个'job_id'和'stream_url'。
    2. 连接到SSE流: 使用上一步获取的'stream_url'连接,接收实时事件。
      curl -N http://localhost:5006/api/v1/stream/<job_id>
      您将实时收到如'job_started'、'status_update'、'result'等事件。

信息

分类

AI与计算