多智能体任务编排系统

基于Model Context Protocol (MCP)和Ollama的本地多智能体AI编排系统,通过主导编排器将请求分解为依赖感知的任务图,委派给领域专用代理,自动提交结果到Git,并通过对话式REPL全程在本地硬件上运行。

  • by n1wan7ha
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 N1wan7ha/nexus-mcp-agent-system

使用说明

Nexus-MCP多代理系统

A. 本地 基于 模型上下文协议(MCP) 和 奥拉玛。主编排器将您的请求分解为一个依赖关系感知任务图,将工作委托给域专用代理,将结果自动提交给Git,并允许您进行跟进——所有这些都是从会话REPL开始的,100%在您自己的硬件上运行。


特性

  • 精心策划的任务计划 -主编排器对您的请求进行分类,构建子任务的有向无环图(DAG),并按照依赖顺序将每个任务分派给正确的专业代理。
  • 领域专业代理 -五个内置域,每个域都有自己的系统提示和MCP工具集:
    领域 典型任务
    software_development 编写、重构、调试和测试代码
    research 总结主题,撰写报告和论文
    data_analysis 查询SQLite,分析数据集
    version_control 通过MCP Git服务器进行Git操作
    general 一般问答、操作指南、创意写作
  • MCP工具集成 -文件系统、SQLite、Playwright(浏览器自动化)和Git服务器开箱即用。在中添加任何自定义MCP服务器 config/mcp_servers.json.
  • 自固定回路 -每个任务最多重试5次;测试输出(pytest/Playwright)被反馈给代理,以便它可以修复自己的代码。
  • 持续项目 -每个项目都存在 workspace/<slug>/ 具有完整的对话历史记录、任务结果和文件清单。恢复任何项目 /resume.
  • 自动git提交 -每个完成的代理阶段都通过以下方式自动提交 GitManager.
  • 会话式REPL -后续请求保持在相同的项目上下文中。Slash命令: /status, /files, /history, /git, /new, /quit.
  • nexus 聊天助手 -对于不需要完整流程的快速问题,nexus可以直接回答。

需求

依赖性 目的
Python 3.11+ 运行时
奥拉玛 本地LLM推理
Node.js+npx MCP文件系统/SQLite/Playwright服务器
紫外线/紫外线 MCP git服务器
Git 自动提交和版本控制功能

快速开始

1.克隆并安装

git clone https://github.com/N1wan7ha/nexus-mcp-agent-system.git
cd nexus-mcp-agent-system
python -m venv mcp-env
# Windows
mcp-env\Scripts\activate
# macOS / Linux
source mcp-env/bin/activate
pip install -r requirements.txt

2.拉动模型

ollama pull llama3.1:8b

3.配置(可选)

复制 .env.example 到 .env 如果您想指向远程提供商或更改超时,请进行调整:

OLLAMA_API_BASE=http://localhost:11434/v1
OLLAMA_API_KEY=ollama
LLM_TIMEOUT=1200

4.跑步

python run_workflow.py

项目结构

nexus-mcp-agent-system/
├── run_workflow.py          # Main entry point / REPL
├── requirements.txt
├── config/
│   ├── agents_config.json   # Orchestrator + chat assistant config
│   ├── mcp_servers.json     # (optional) Custom MCP server registry
│   └── domains/             # Per-domain agent configs
│       ├── software_development.json
│       ├── research.json
│       ├── data_analysis.json
│       ├── version_control.json
│       └── general.json
├── core/
│   ├── task_graph.py        # DAG-based task dependency engine
│   ├── mcp_connector.py     # MCP server client wrapper
│   ├── project_manager.py   # Persistent project state
│   ├── memory_store.py      # Conversation memory
│   ├── git_manager.py       # Auto-commit integration
│   ├── qa_runner.py         # pytest / Playwright test runner
│   ├── file_writer.py       # Extracts & writes generated files
│   ├── agent_logger.py      # Structured logging
│   └── ui.py                # REPL UI helpers
├── tests/
│   └── test_suite.py
└── workspace/               # Generated project outputs (git-ignored)

运作原理

User input
    │
    ▼
Orchestrator (LLM)
    │  classifies domain, builds task DAG
    ▼
TaskGraph — resolves dependency order
    │
    ├─► Agent A (e.g. business_analyst)
    │       └─► MCP tools (filesystem, git, sqlite, playwright)
    ├─► Agent B (e.g. software_development)  ← depends on A
    │       └─► writes files, runs tests, self-fixes
    └─► Agent C (e.g. version_control)       ← depends on B
            └─► auto-commits via GitManager

斜杠命令

命令 描述
/status 显示当前项目状态和任务进度
/files 列出此项目中写入的所有文件
/history 打印对话历史记录
/git 显示工作区的git日志
/new 启动一个新项目
/quit 退出REPL

添加自定义MCP服务器

创建 config/mcp_servers.json:

{
  "my_server": {
    "command": "npx",
    "args": ["-y", "my-mcp-package"]
  }
}

它将在启动时合并到服务器注册表中。


许可证

麻省理工学院