
Tetrad
io.github.SamoraDC由 GitHub 账号 SamoraDC 发布v0.1.12更新于 Nov 10, 2026
Quadruple consensus MCP server for code validation using Codex, Gemini, and Qwen
概览
Tetrad 将代码、方案和测试交给 Codex、Gemini、Qwen 三个外部 AI 命令行评估器评审,并在 Claude Code 保存或提交前返回共识结论。
- 可以做什么
- Tetrad 是一个本地 MCP 服务器,提供六个工具:tetrad_review_plan、tetrad_review_code、tetrad_review_tests、tetrad_confirm、tetrad_final_check 和 tetrad_status。它把提交的内容转发给 Codex、Gemini 和 Qwen 命令行工具,收集各自的投票与评分,再按可配置的共识规则(全体一致、强共识或简单多数)返回 PASS 或 BLOCK 以及修改建议。结果会写入 LRU 缓存,并存入基于 SQLite 的 ReasoningBank,跨会话记录良好模式与反模式。
- 适用场景
- 当你希望在 AI 生成的代码被保存或提交前获得自动化的第二意见时使用,尤其适合关键或涉及安全的改动。它也适合已经拥有底层 AI 命令行工具订阅或 API 访问权限、并希望在 Claude Code 内设置评审关卡的团队。
- 运行要求
- 以本地 stdio 进程运行,通常通过 npx @samoradc/tetrad serve 启动;npm 包需要 Node.js。必须至少安装并登录一个外部命令行工具:Codex CLI、Gemini CLI 或 Qwen CLI。凭据可通过 OPENAI_API_KEY、GEMINI_API_KEY、GOOGLE_API_KEY 或 DASHSCOPE_API_KEY 等环境变量提供,也可使用各命令行工具自带的登录流程。需要能访问相应 AI 服务商的网络。
安装
在 SourceWeft 中
- 打开 控制台中的 Tetrad,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
Tetrad
[CI] [MCP Registry] [npm] [Crates.io] [Rust] [License: MIT]
Quadruple Consensus MCP Server for Claude Code
Tetrad is a high-performance MCP (Model Context Protocol) server written in Rust that orchestrates three AI-powered CLI code evaluation tools (Codex, Gemini CLI, Qwen) to validate all code produced by Claude Code.
The system implements a quadruple consensus protocol where no code or plan is accepted without approval from four intelligences: the three external evaluators + Claude Code itself.
Features
- Quadruple Consensus: 4 AI models must agree to approve code
- ReasoningBank: Continuous learning system with RETRIEVE→JUDGE→DISTILL→CONSOLIDATE cycle
- High Performance: Written in Rust with parallel execution via Tokio
- MCP Server: JSON-RPC 2.0 server over stdio for Claude Code integration
- Full CLI: Intuitive commands (
init,serve,status,doctor,config, etc.) - LRU Cache: Result caching with configurable TTL
- Hook System: Pre/post evaluation callbacks for customization
- Extensible: Plugin system for custom executors
- Cross-session: SQLite persistence for patterns and history
Quick Start
1. Install Tetrad
1.1 Initialize in Your Project (Optional)
This will:
- Create
tetrad.tomlconfiguration file - Create
.tetrad/directory for the database - Add
.tetrad/to your.gitignore
2. Install and Configure External CLI Tools
Tetrad requires at least one of the following AI CLI tools. Good news: you don't need separate API keys if you have existing subscriptions!
Codex CLI (OpenAI)
Authentication options:
Note: For headless/remote servers, use
codex login --device-authand follow the device code flow.
📖 Codex CLI Authentication Docs
Gemini CLI (Google)
Authentication options:
Free Tier: With a personal Google account, you get access to Gemini 2.5 Pro with 1M token context window at no cost!
📖 Gemini CLI Authentication Docs
Qwen CLI (Alibaba)
Authentication options:
Regional Endpoints:
- Singapore:
dashscope-intl.aliyuncs.com- Virginia:
dashscope-us.aliyuncs.com- Beijing:
dashscope.aliyuncs.com
3. Verify Installation
4. Add to Claude Code CLI
Alternative installation methods
Note: Tetrad is published on the MCP Registry for discoverability and documentation.
5. Alternative: Manual Configuration
Create or edit .mcp.json in your project root:
Or for global user configuration in ~/.claude.json (mcpServers section):
How It Works
When you ask Claude Code to write code, Tetrad automatically validates it:
When Issues Are Found:
CLI Commands
MCP Tools
When running as MCP server, Tetrad exposes 6 tools:
Workflow Example
Architecture
Executor Specializations
Consensus Rules
ReasoningBank
The ReasoningBank is a continuous learning system that stores and consolidates code patterns:
Learning Cycle
Pattern Types
- AntiPattern: Patterns to avoid (bugs, vulnerabilities, code smells)
- GoodPattern: Patterns to follow (best practices, idiomatic patterns)
- Ambiguous: Patterns with uncertain classification (needs more data)
ReasoningBank Commands
Configuration
The tetrad.toml file is created automatically with tetrad init:
Interactive Configuration
Use tetrad config for interactive configuration:
LRU Cache
The system includes an LRU cache to avoid unnecessary re-evaluations:
- Capacity: Configurable (default: 1000 entries)
- TTL: Configurable time-to-live (default: 5 minutes)
- Key: Hash of code + language + evaluation type
- Invalidation: Automatic by TTL or manual
Hook System
Hooks allow customizing behavior at specific points:
Built-in Hooks
- LoggingHook: Records all evaluations
- MetricsHook: Collects usage statistics
Project Structure
Development
Troubleshooting
"CLI not found"
"stdin is not a terminal" (Codex)
Make sure your config uses exec --json:
"Response does not contain valid JSON" (Gemini)
Make sure your config uses -o json:
Check MCP status in Claude Code
Inside Claude Code, run:
Prerequisites
To use Tetrad, you need at least one of the AI CLIs installed and authenticated:
Check availability with:
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
MIT
Author
SamoraDC
Links:
来源:README.md,提交 dc5874e
工具
0版本历史
1- v0.1.12最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分