tim101010101/arena

GitHub: tim101010101/arena

一个支持多AI模型协作与对抗的MCP服务器,可用于代码审查、技术辩论和红队安全测试。

Stars: 0 | Forks: 0

# Arena MCP ``` █████╗ ██████╗ ███████╗███╗ ██╗ █████╗ ██╔══██╗██╔══██╗██╔════╝████╗ ██║██╔══██╗ ███████║██████╔╝█████╗ ██╔██╗ ██║███████║ ██╔══██║██╔══██╗██╔══╝ ██║╚██╗██║██╔══██║ ██║ ██║██║ ██║███████╗██║ ╚████║██║ ██║ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═══╝╚═╝ ╚═╝ ``` [![CI](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/ae2bd37984223501.svg)](https://github.com/tim101010101/arena/actions/workflows/ci.yml) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Version](https://img.shields.io/github/v/release/tim101010101/arena)](https://github.com/tim101010101/arena/releases) 一个支持多智能体 AI 竞争与协作的 Model Context Protocol (MCP) 服务器。可在不同的 AI 模型(Claude、OpenAI、Gemini、Codex)之间运行辩论、代码审查、红队挑战和评估。 ## 功能特性 ### 🎭 arena_debate 多智能体辩论,AI 智能体在多轮对话中针对不同立场进行辩论。 - 为每个智能体分配特定立场 - 支持顺序或并行执行模式 - 完整的对话历史追踪 ### 🔍 arena_review 从多个 AI 视角进行并行代码审查。 - 关注领域:bug、安全性、性能或综合审查 - 支持 git refs、文件列表、补丁和原始代码 - 支持 JSON 或文本输出格式 ### ⚔️ arena_challenge 红队风格的挑战,多个智能体攻击一个断言。 - 可选的防御智能体保护断言 - 多轮对抗测试 - 发现边缘情况和反例 ### ⚖️ arena_judge 对已完成的竞技场会话进行公正评估。 - 对每个智能体的表现进行评分 - 识别优势、劣势和共识 - 支持自定义评估标准 ### 🏥 arena_health 检查所有已注册 AI agent CLI 的健康状态。 ## 安装说明 ### 前置条件 安装你想使用的 AI CLI 工具: ``` # Claude CLI (claude agent 必需) npm install -g @anthropic-ai/claude-cli # Codex CLI (codex agent 必需) npm install -g @codex-ai/cli # 注意:OpenAI 和 Gemini agents 使用 codex CLI 作为适配器 # 无需单独安装 openai-cli 或 gemini-cli ``` ### 安装 Arena MCP #### 从 GitHub 安装(推荐) ``` # 直接从 GitHub 安装 bun install -g github:tim101010101/arena # 或使用 bunx (无需安装) bunx --bun github:tim101010101/arena ``` #### 从源码安装 ``` git clone https://github.com/tim101010101/arena.git cd arena bun install bun run build bun install -g . ``` ### 配置 MCP Client Arena MCP 兼容任何支持 MCP 的客户端。配置示例如下: #### Claude Desktop 编辑配置文件: - **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json` - **Windows**: `%APPDATA%\Claude\claude_desktop_config.json` - **Linux**: `~/.config/Claude/claude_desktop_config.json` 或使用:Settings > Developer > Edit Config ``` { "mcpServers": { "arena": { "command": "bunx", "args": ["--bun", "github:tim101010101/arena"], "env": { "ARENA_TIMEOUT_MS": "120000", "ARENA_DEFAULT_ROUNDS": "3", "ARENA_DEFAULT_MODE": "parallel" } } } } ``` #### Claude Code CLI 使用 CLI 命令添加 MCP 服务器: ``` # 若全局安装 claude mcp add arena arena-mcp # 或指定 dist/index.js 的完整路径 claude mcp add arena bun /path/to/arena-mcp/dist/index.js ``` 要配置环境变量,请手动编辑 Claude Code 配置文件: - **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json` - **Windows**: `%APPDATA%\Claude\claude_desktop_config.json` - **Linux**: `~/.config/Claude/claude_desktop_config.json` 配置格式与 Claude Desktop 相同。 #### 其他 MCP 客户端 对于其他 MCP 客户端,请参考其文档进行 MCP 服务器配置。服务器命令为 `arena-mcp`,通过环境变量进行配置(见下文配置部分)。 重启你的 MCP 客户端以加载服务器。 ## 配置 所有配置均通过 MCP 客户端配置中的环境变量完成。可用选项: | Variable | Description | Default | Valid Range | |----------|-------------|---------|-------------| | `ARENA_TIMEOUT_MS` | 智能体执行超时时间(毫秒) | `120000` | 1000-600000 | | `ARENA_DEFAULT_ROUNDS` | 辩论/挑战的默认轮数 | `3` | 1-10 | | `ARENA_DEFAULT_MODE` | 执行模式 | `parallel` | `sequential`, `parallel` | | `ARENA_MAX_CONTEXT_SIZE` | 最大上下文大小 | `1000000` | 100000-10000000 | | `ARENA_CLAUDE_MODEL` | Claude 模型覆盖 | (CLI 默认值) | 参见 Claude CLI 文档了解当前模型 | | `ARENA_CODEX_MODEL` | Codex 模型覆盖 | (CLI 默认值) | 参见 Codex CLI 文档了解当前模型 | | `ARENA_GEMINI_MODEL` | Gemini 模型覆盖 | (CLI 默认值) | 参见 Gemini 文档了解当前模型 | | `ARENA_OPENAI_MODEL` | OpenAI 模型覆盖 | (CLI 默认值) | 参见 OpenAI 文档了解当前模型 | ### 配置示例 ``` { "mcpServers": { "arena": { "command": "arena-mcp", "env": { "ARENA_TIMEOUT_MS": "180000", "ARENA_DEFAULT_ROUNDS": "5", "ARENA_DEFAULT_MODE": "sequential" } } } } ``` ### 故障排除 - **构建失败**:确保已安装 `bun` (`curl -fsSL https://bun.sh/install | bash`) - **工具未显示**:配置更改后重启 MCP 客户端 - **找不到 Agent CLI**:安装所需的 CLI 工具(参见前置条件) - **配置无效**:查看错误信息了解验证详情 ## 使用示例 ### 辩论:架构决策 ``` // Ask multiple AI agents to debate a technical decision arena_debate({ topic: "Should we use microservices or monolith for our new project?", agents: ["claude", "openai", "gemini"], positions: { "claude": "Advocate for microservices architecture", "openai": "Advocate for monolithic architecture", "gemini": "Neutral evaluator focusing on trade-offs" }, rounds: 3, context: "Team size: 5 developers, Expected scale: 10k users in year 1", mode: "sequential" }) ``` ### 代码审查:多视角 ``` // Get code reviews from multiple AI agents arena_review({ sources: [{ type: "git_ref", ref: "feature/new-auth", root: "/path/to/repo" }], agents: ["claude", "codex", "openai"], focus: "security", output_format: "json" }) ``` ### 挑战:安全断言 ``` // Red-team test a security claim arena_challenge({ assertion: "Our authentication system is immune to timing attacks", evidence: "We use constant-time comparison for all password checks", challengers: ["claude", "codex"], defender: "openai", rounds: 2, context: "Node.js backend with bcrypt password hashing" }) ``` ### 裁决:评估辩论 ``` // Have a neutral agent evaluate the debate arena_judge({ session_id: "debate_abc123", judge: "gemini", criteria: ["evidence quality", "logical coherence", "practical feasibility"] }) ``` ## 架构 ``` src/ ├── index.ts # MCP server entry point ├── types.ts # Zod schemas and TypeScript types ├── orchestrator.ts # Multi-agent execution orchestration ├── session.ts # Session management and history ├── context.ts # Code context acquisition (git, files) ├── prompts.ts # System and user prompts for each mode ├── output.ts # Response formatting ├── utils.ts # Utilities (timeout, env, binary checks) ├── constants.ts # Configuration constants └── adapters/ ├── base.ts # AgentAdapter interface ├── registry.ts # Adapter registry ├── claude.ts # Claude CLI adapter ├── codex.ts # Codex CLI adapter ├── openai.ts # OpenAI CLI adapter └── gemini.ts # Gemini CLI adapter ``` ## 开发 ``` # 安装依赖 bun install # 运行测试 bun test # 构建 bun run build # 启动服务器 (用于测试) bun run start ``` ## 应用场景 ### 1. 增强代码审查 获取多个 AI 视角对代码变更的看法,以发现更多问题并提高代码质量。 ### 2. 技术决策制定 使用结构化辩论探讨权衡取舍,做出更好的架构决策。 ### 3. 安全测试 利用对抗性 AI 智能体对安全假设进行红队测试。 ### 4. AI 模型对比 在同一任务上对比不同 AI 模型的能力。 ### 5. 集体智能 利用多个 AI 智能体解决能从多元视角中受益的复杂问题。 ## 局限性 - 需要为每个 AI 提供商安装 CLI 工具 - API 成本随智能体数量和轮数增加而增加 - 对于大规模使用,并行模式可能成本较高 - 响应质量取决于底层的 AI 模型 ## 贡献指南 欢迎贡献!请: 1. Fork 本仓库 2. 创建一个功能分支 3. 为新功能添加测试 4. 提交 pull request ## 许可证 MIT ## 路线图 - [ ] 用于可视化的 Web UI - [ ] 结果持久化和分析 - [ ] 支持更多 AI 提供商 - [ ] 流式响应 - [ ] 成本追踪和优化 - [ ] 自定义智能体角色和专业领域
标签:AES-256, AI安全, AI竞技场, AI辩论, Chat Copilot, Claude, CVE检测, DevSecOps, Gemini, LLM评估, MCP, Model Context Protocol, Ollama, OpenAI, PyRIT, Python, 上游代理, 人工智能, 代码审查, 内存规避, 多智能体系统, 提示词工程, 无后门, 智能助手, 模型对比, 漏洞评估, 用户模式Hook绕过, 策略决策点, 自动化代码审计, 自动化攻击