⚡ AarnXen Multi-AI MCP Server
The most powerful multi-model AI orchestration server for Claude Code
Quick Start • 31 Tools • 25+ Models • Architecture • Memory Flywheel
______________________________________________________________________
AarnXen是什么?
AarnXen (ax)是a 多模型AI编排MCP服务器 这使Claude Code能够访问多个提供商的25个以上的AI模型。它超越了简单的聊天——它提供 对抗性辩论, 验证链, 陪审团投票, 自我完善, 网接地和a 持久知识库 从每一次互动中学习。
没有其他MCP服务器将多模型编排模式与持久内存和生产基础设施相结合。
关键差异点
| 功能 | PAL(11k⭐) | AI顾问 | AarnXen 的 |
|---|---|---|---|
| 型号 | 5个供应商 | 2个型号 | 25+型号,2家供应商 |
| 共识 | 顺序 | ❌ | 并行 asyncio.gather |
| 辩论 | ❌ | ✅ | ✅ + 判断综合 |
| 验证 | ❌ | ❌ | ✅ 验证链 |
| 陪审团投票❌ | ❌ | ✅ N-模型评分 | |
| 自我完善 | ❌ | ❌ | ✅ 迭代改进 |
| 网络搜索 | ❌ | ❌ | ✅ DuckDuckGo+AI总结 |
| 知识库 | ❌ | ❌ | ✅ SQLite+FTS5 |
| 自动学习 | ❌ | ❌ | ✅ 记忆飞轮 |
| 成本跟踪 | ❌ | ❌ | ✅ 按请求美元 |
| 断路器 | ❌ | ❌ | ✅ 三态滑动窗 |
| 护栏 | ❌ | ❌ | ✅ 内容过滤 |
| 仪表板 | ❌ | ❌ | ✅ 实时网络用户界面 |
______________________________________________________________________
建筑
graph TB
subgraph Claude Code
CC[Claude Code / MCP Client]
end
subgraph "AarnXen MCP Server (ax)"
CC -->|MCP Protocol| MW[Tool Middleware]
MW -->|rate limit, guardrails, events| TOOLS
subgraph TOOLS["31 Tools"]
direction LR
AI["AI Tools
chat, consensus, compare
think, codereview, precommit
challenge, swarm, pipeline
debate, verify, jury, refine"]
WEB["Web Tools
web_search
web_fetch"]
KB["KB Tools
kb_store, kb_search
kb_get, kb_remember
kb_recall, kb_relate
kb_search_index
kb_timeline
kb_get_observations
kb_stats"]
SYS["System Tools
costs, list_models
provider_health
health, events
kb_consolidate"]
end
TOOLS --> ROUTER[Smart Router]
ROUTER -->|tier selection| REG[Provider Registry]
ROUTER |learns from| KBD[(Knowledge DB)]
subgraph Providers
direction LR
GEM[Gemini API
2.5 Pro, 2.5 Flash
3.1 Pro, 3 Flash]
OLL[Ollama Cloud
DeepSeek, Kimi
Qwen, GLM, MiniMax
GPT-OSS, Mistral
Cogito, Devstral]
end
REG --> GEM
REG --> OLL
subgraph Infrastructure
direction LR
CACHE[Response Cache
TTL + LRU]
CB[Circuit Breaker
3-state]
COST[Cost Tracker
per-request USD]
EVENTS[Event Bus
async pub/sub]
GUARD[Guardrails
content filter]
RATE[Rate Limiter
per-tool]
end
end
style TOOLS fill:#1a1a2e,stroke:#16213e,color:#fff
style Providers fill:#0f3460,stroke:#16213e,color:#fff
style Infrastructure fill:#533483,stroke:#16213e,color:#fff记忆飞轮
其他MCP服务器所没有的独特的自我改进循环:
graph LR
A[AI Tool Called] -->|auto-learn middleware| B[Store Performance
latency, tokens, cost]
B --> C[(Knowledge DB
SQLite + FTS5)]
C -->|memory-informed routing| D[Smart Router
reorders by real perf]
D -->|picks fastest model| A
style A fill:#e94560,stroke:#16213e,color:#fff
style B fill:#533483,stroke:#16213e,color:#fff
style C fill:#0f3460,stroke:#16213e,color:#fff
style D fill:#1a1a2e,stroke:#16213e,color:#fff每个AI工具调用都会自动存储模型性能指标。智能路由器查询此数据以选择最快的可用型号-- 每次交互,系统都会变得更智能.
______________________________________________________________________
快速开始
先决条件
- Python 3.11+
- 紫外线 (推荐)或pip
- 至少一个API密钥(Gemini免费层效果很好)
安装
# Clone
git clone https://github.com/Abhishek-Kraj/AarnXen-MultiAI-MCP.git
cd AarnXen-MultiAI-MCP
# Install (pick one)
uv sync # recommended
pip install -e . # alternative
# Configure
mkdir -p ~/.aarnxen
cp config.example.yaml ~/.aarnxen/config.yaml
# Edit config.yaml — add your API keys
# Verify
uv run pytest tests/ -q # 269 tests should pass添加到克劳德代码
选项A-CLI(推荐):
claude mcp add ax -s user -- uv --directory /path/to/AarnXen-MultiAI-MCP run ax选项B——手动配置 (~/.claude/settings.json):
{
"mcpServers": {
"ax": {
"command": "uv",
"args": ["--directory", "/path/to/AarnXen-MultiAI-MCP", "run", "ax"],
"env": {
"GEMINI_API_KEY": "your-gemini-key",
"OLLAMA_CLOUD_KEY": "your-ollama-cloud-key"
}
}
}
}提示: 服务器注册为ax--所有工具显示为mcp__ax__chat,mcp__ax__consensus等等。
______________________________________________________________________
工具
人工智能编排工具(15)
| 工具 | 描述 | 图案 |
|---|---|---|
chat | 与任何单一AI模型聊天 | 单一模型 |
consensus | 并行查询3+个模型,综合协议 | 并行扇出 |
compare | 两款车型的A/B并排比较 | A/B测试 |
think | 深度逐步推理(轻/中/深) | 思维链 |
codereview | 代码审查(一般/安全/性能/错误) | 专家分析 |
precommit | 提交前审查,通过/失败判定 | 关卡检查 |
challenge | 魔鬼的拥护者——反对你的立场 | |
swarm | 将任务分解为子任务,并行运行 | 扇出/扇入 |
pipeline | 按顺序链接多个工具 | 按顺序链接 |
debate | 两个模型争论对立双方+法官判决 | 对抗性辩论 |
verify | 验证链——基于证据的事实核查 | CoVe(4步) |
jury | N个模型独立评分内容(1-10) | 投票集合 |
refine | 生成→ 批评→ 优化N次迭代 | 自我优化 |
web_search | DuckDuckGo搜索,可选AI摘要 | 网络基础 |
web_fetch | 以markdown格式获取URL(Jina Reader+回退) | 网络基础 |
知识库工具(10)
| 工具 | 说明 |
|---|---|
kb_store | 存储关于实体的观察结果 |
kb_search | 对所有观察结果进行全文搜索 |
kb_get | 获取特定实体的所有观察结果 |
kb_remember | 快速自然语言存储 |
kb_recall | 按主题回忆往事 |
kb_relate | 在两个实体之间创建关系 |
kb_search_index | 轻量级搜索仅返回ID(约50个令牌/结果) |
kb_timeline | 获取特定观察的时间背景 |
kb_get_observations | 获取特定观察ID的完整详细信息 |
kb_stats | 知识库统计 |
系统工具(6)
| 工具 | 说明 |
|---|---|
costs | 按型号细分的会话成本汇总 |
list_models | 列出跨提供商的所有可用型号 |
provider_health | 提供商状态和延迟指标 |
health | 服务器整体健康检查 |
events | 最近事件日志(按类型筛选) |
kb_consolidate | 整合和消除重复的KB条目 |
______________________________________________________________________
模型
Gemini(本地API)
| 型号 | 类型 | 上下文 |
|---|---|---|
gemini-3.1-pro-preview | 高级推理+代码 | 1M代币 |
gemini-3-flash-preview | 快速平衡 | 1M代币 |
gemini-2.5-pro | 稳定的溢价 | 100万代币 |
gemini-2.5-flash | 稳定快速 | 1M代币 |
gemini-2.5-flash-lite | 超快速预算 | 100万代币 |
Ollama Cloud(20多种型号,免费)
| 模型 | 参数 | 上下文 |
|---|---|---|
deepseek-v3.2 | 671B | 128K |
kimi-k2:1t-cloud | 1吨 | 256K |
kimi-k2.5 | --128K | |
kimi-k2-thinking | --128K | |
qwen3.5:397b-cloud | 397B | 128K |
qwen3-coder-next:latest | --128K | |
qwen3-next:80b-cloud | 80B | 128K |
qwen3-vl:235b-cloud | 235B | 256K |
glm-5 | --128K | |
glm-4.7 | --128K | |
minimax-m2.5 | --128K | |
minimax-m2 | --128K | |
cogito-2.1:671b-cloud | 671B | 128K |
devstral-2:123b-cloud | 123B | 128K |
devstral-small-2:24b-cloud | 24B | 128K |
mistral-large-3:675b-cloud | 675B | 256K |
deepseek-v3.1:671b-cloud | 671B | 128K |
gpt-oss:20b-cloud | 20B | 128K |
gpt-oss:120b-cloud | 120B | 128K |
所有Ollama Cloud型号均 自由 -无API成本。Smart Router会根据预算级别的任务对它们进行优先级排序。
智能路由层
graph LR
subgraph Budget["💰 Budget Tier"]
B1[gemini-3.1-flash-lite]
B2[gemini-3-flash]
B3[gpt-oss:20b]
B4[qwen3.5:397b]
end
subgraph Balanced["⚖️ Balanced Tier"]
M1[kimi-k2:1t]
M2[deepseek-v3.2]
M3[glm-5]
M4[mistral-large-3:675b]
end
subgraph Premium["👑 Premium Tier"]
P1[gemini-3.1-pro]
P2[kimi-k2-thinking]
P3[minimax-m2.5]
P4[cogito-2.1:671b]
end
Q[Query] --> R{Smart Router}
R -->|simple task| Budget
R -->|general task| Balanced
R -->|complex reasoning| Premium
style Budget fill:#2d6a4f,stroke:#1b4332,color:#fff
style Balanced fill:#e85d04,stroke:#dc2f02,color:#fff
style Premium fill:#7b2cbf,stroke:#5a189a,color:#fff______________________________________________________________________
用法示例
基本聊天
"Use ax chat to ask gemini-2.5-flash about Python async patterns"多模型共识
"Use ax consensus to get opinions from 3 models on microservices vs monolith"对抗性辩论
"Use ax debate with topic='Is Rust better than Go for backend services?' rounds=3"事实核查
"Use ax verify with claim='Python is the most popular programming language' web_check=true"评审团评价
"Use ax jury to score this code with criteria=code and num_jurors=5"自我精炼
"Use ax refine with prompt='Write a Redis connection pool in Python' iterations=3"代码审查
"Use ax codereview with focus=security on this authentication handler"预提交检查
"Use ax precommit to review my staged changes"网络研究
"Use ax web_search for 'best practices for MCP server development'"
"Use ax web_fetch url='https://docs.anthropic.com/en/docs/agents-and-tools/mcp'"知识库
"Use ax kb_remember 'Always use connection pooling for PostgreSQL in production'"
"Use ax kb_recall 'PostgreSQL'"
"Use ax kb_search 'database optimization'"管道(链式工具)
"Use ax pipeline with steps:
1. web_search for 'Python GIL changes in 3.13'
2. think about the implications
3. codereview on our threading code"______________________________________________________________________
工具交互模式
graph TD
subgraph "Single Model"
chat[chat]
think[think]
codereview[codereview]
end
subgraph "Multi-Model Parallel"
consensus[consensus]
jury[jury]
swarm[swarm]
end
subgraph "Multi-Model Sequential"
debate[debate
FOR ↔ AGAINST → Judge]
verify[verify
Draft → Questions → Answers → Verdict]
refine[refine
Generate → Critique → Refine × N]
pipeline[pipeline
Tool₁ → Tool₂ → Tool₃]
end
subgraph "Web Grounding"
web_search[web_search]
web_fetch[web_fetch]
end
verify -.->|optional web_check| web_search
style chat fill:#2d6a4f,color:#fff
style think fill:#2d6a4f,color:#fff
style codereview fill:#2d6a4f,color:#fff
style consensus fill:#e85d04,color:#fff
style jury fill:#e85d04,color:#fff
style swarm fill:#e85d04,color:#fff
style debate fill:#7b2cbf,color:#fff
style verify fill:#7b2cbf,color:#fff
style refine fill:#7b2cbf,color:#fff
style pipeline fill:#7b2cbf,color:#fff
style web_search fill:#1d3557,color:#fff
style web_fetch fill:#1d3557,color:#fff______________________________________________________________________
配置
最小配置(~/.aarnxen/config.yaml)
default_model: "auto"
default_temperature: 0.7
providers:
- name: gemini
api_key_env: GEMINI_API_KEY
priority: 1
models:
- gemini-2.5-pro
- gemini-2.5-flash
- gemini-3.1-pro-preview
- gemini-3-flash-preview
cache:
enabled: true
ttl_seconds: 3600
memory:
enabled: true
path: "~/.aarnxen/conversations.db"
cost_tracking: trueOllama Cloud的完整配置
providers:
- name: gemini
api_key_env: GEMINI_API_KEY
priority: 1
models:
- gemini-3.1-pro-preview
- gemini-3-flash-preview
- gemini-2.5-pro
- gemini-2.5-flash
- gemini-2.5-flash-lite
- name: ollama-cloud
base_url: "https://ollama.com"
api_key_env: OLLAMA_CLOUD_KEY
priority: 2
models:
- deepseek-v3.2
- kimi-k2:1t-cloud
- kimi-k2.5
- kimi-k2-thinking
- qwen3.5:397b-cloud
- glm-5
- minimax-m2.5
# ... see config.example.yaml for full list______________________________________________________________________
仪表盘
AarnXen包括一个 零依赖web仪表板 该自动程序从MCP服务器启动。
http://localhost:8765特征:
- 实时模型状态和延迟
- 每个型号/供应商的成本跟踪
- 事件流查看器
- 知识库统计
独立运行: aarnxen-dashboard 或 ax (仪表板自动启动)
______________________________________________________________________
基础设施
中间件管道
每个工具调用都通过中间件堆栈:
sequenceDiagram
participant C as Claude Code
participant MW as Middleware
participant RL as Rate Limiter
participant GR as Guardrails
participant T as Tool Handler
participant AL as Auto-Learn
participant EB as Event Bus
C->>MW: tool call
MW->>RL: check rate limit
RL-->>MW: ✅ allowed
MW->>GR: validate input
GR-->>MW: ✅ safe
MW->>EB: emit tool.start
MW->>T: execute handler
T-->>MW: result
MW->>AL: store model performance
MW->>EB: emit tool.complete
MW-->>C: response断路器
三态断路器可防止供电中断:
CLOSED → (3 failures) → OPEN → (30s cooldown) → HALF_OPEN → (1 success) → CLOSED
→ (1 failure) → OPEN三层知识库搜索
针对代币效率进行了优化:
| 层 | 工具 | 令牌/结果 | 使用 |
|---|---|---|---|
| 1 | kb_search_index | ~50 | 获取ID,扫描标题 |
| 2 | kb_timeline | ~200 | ID周围的上下文 |
| 3 | kb_get_observations | 完整 | 获取特定ID |
10倍代币节省 vs提前获取所有东西。
______________________________________________________________________
发展
# Install dev dependencies
uv sync --group dev
# Run tests
uv run pytest tests/ -q # all 269 tests
uv run pytest tests/test_router.py -q # specific module
uv run pytest tests/ -q -x # stop on first failure
# Run server locally
uv run ax
# Run dashboard standalone
uv run aarnxen-dashboard项目结构
src/aarnxen/
├── server.py # FastMCP server + tool registration
├── config.py # YAML config loader
├── dashboard.py # Web dashboard (auto-starts)
├── core/
│ ├── router.py # Smart 3-tier routing + memory-informed
│ ├── tool_middleware.py # Rate limit, guardrails, events, auto-learn
│ ├── knowledge.py # SQLite + FTS5 knowledge base
│ ├── circuit_breaker.py # 3-state circuit breaker
│ ├── events.py # Async event bus
│ ├── guardrails.py # Content filtering
│ ├── rate_limit.py # Per-tool rate limiting
│ ├── cost.py # USD cost tracking
│ ├── cache.py # TTL + LRU response cache
│ ├── retry.py # Exponential backoff + fallback
│ ├── conversation.py # Persistent conversation memory
│ ├── extractor.py # Entity extraction
│ └── validation.py # Input validation
├── providers/
│ ├── registry.py # Provider registry + model resolution
│ ├── base.py # Base provider interface
│ ├── gemini.py # Google Gemini (native SDK)
│ ├── ollama.py # Ollama Local + Cloud
│ └── openai_compat.py # OpenAI-compatible endpoints
├── tools/
│ ├── chat.py # Single model chat
│ ├── consensus.py # Parallel multi-model
│ ├── compare.py # A/B comparison
│ ├── think.py # Deep reasoning
│ ├── codereview.py # Code review
│ ├── precommit.py # Pre-commit gate
│ ├── challenge.py # Devil's advocate
│ ├── debate.py # Adversarial debate
│ ├── verify.py # Chain of Verification
│ ├── jury.py # N-model jury voting
│ ├── refine.py # Self-Refine
│ ├── web_search.py # DuckDuckGo search
│ ├── web_fetch.py # URL → markdown
│ ├── swarm.py # Parallel sub-tasks
│ └── pipeline.py # Sequential tool chain
└── pricing/
└── models.py # Per-model pricing data______________________________________________________________________
分支
| 分支 | 状态 | 描述 |
|---|---|---|
main | 稳定 | 生产就绪版本 |
develop | 活动 | 最新功能(31个工具,25+个型号,记忆飞轮) |
______________________________________________________________________
许可证
麻省理工学院——见 许可证
______________________________________________________________________
Built by Abhishek
Making AI orchestration accessible, powerful, and self-improving.
