Skip to main content
Glama

ai-consensus-mcp

一个极简的 stdio Model Context Protocol 服务器,将“共识验证协议”公开为单一的 consensus 工具。 为 Claude Code、Cursor、Windsurf 或任何 MCP 主机提供真正的多模型圆桌会议。

npm license

ai-consensus-core 的轻量级封装。一个工具,一个配置文件,零麻烦。

它能为你做什么

  • 一个 MCP 工具:consensus 指向模型和角色列表,即可运行多轮辩论。

  • 任何兼容 OpenAI 的提供商。 xAI Grok、Anthropic(通过 OpenAI 兼容端点)、OpenAI、Groq、Together、Fireworks 或你的私有网关。一个适配器,可针对每个参与者进行配置。

  • 实时进度。 每个结构化的引擎事件都会作为 MCP 进度通知 转发——主机可以实时渲染轮次、参与者、分歧和评分状态。

  • 轻量级依赖。 @modelcontextprotocol/sdkzodai-consensus-core。SSE 解析使用原生 fetch——无需提供商 SDK。

Related MCP server: Claude Code AI Collaboration MCP Server

协议

关于实际协议(轮次、阶段、提示词、评分),请参阅 ai-consensus-core 协议图。本 README 仅涵盖服务器层面。

安装

通过 npm:

# Globally, for use as a binary
npm install -g ai-consensus-mcp

# Or as a project dependency
npm install ai-consensus-mcp

或者克隆并运行:

git clone https://github.com/entropyvortex/ai-consensus-mcp.git
cd ai-consensus-mcp
npm install
npm run build

配置

复制示例并进行编辑:

cp consensus.config.example.json ./consensus.config.json

最小配置结构:

{
  "providers": {
    "xai": {
      "baseUrl": "https://api.x.ai/v1",
      "apiKeyEnv": "GROK_API_KEY"
    },
    "anthropic": {
      "baseUrl": "https://api.anthropic.com/v1",
      "apiKeyEnv": "ANTHROPIC_API_KEY"
    }
  },
  "participants": [
    { "id": "grok",   "provider": "xai",       "modelId": "grok-4",            "personaId": "pessimist" },
    { "id": "domain", "provider": "anthropic", "modelId": "claude-sonnet-4-6", "personaId": "domain-expert" },
    { "id": "devil",  "provider": "xai",       "modelId": "grok-4",            "personaId": "devils-advocate" }
  ],
  "judge": {
    "provider": "xai",
    "modelId": "grok-4"
  }
}

配置参考

providers.<id>.baseUrl         string   OpenAI-compatible base URL. No trailing /chat/completions.
providers.<id>.apiKeyEnv       string   Name of the env var holding the API key.
providers.<id>.extraHeaders    object?  Static headers sent on every request (rarely needed).

participants[].id              string   Stable participant id (appears in events + progress).
participants[].provider        string   Key into providers.
participants[].modelId         string   Opaque model id the provider accepts.
participants[].personaId       enum     One of: pessimist, first-principles, vc-specialist,
                                        scientific-skeptic, optimistic-futurist,
                                        devils-advocate, domain-expert.
participants[].label           string?  Optional display label.

judge.provider                 string?  Key into providers.
judge.modelId                  string?  Opaque judge model id.
judge.temperature              number?  Defaults to 0.3.
judge.maxOutputTokens          number?  Defaults to 1500.

defaults.maxRounds             int?     1–10, defaults 4.
defaults.earlyStop             bool?    Defaults true.
defaults.convergenceDelta      number?  Defaults 3.
defaults.disagreementThreshold number?  Defaults 20.
defaults.blindFirstRound       bool?    Defaults true.
defaults.randomizeOrder        bool?    Defaults true.
defaults.participantTemperature number? Defaults 0.7.
defaults.maxOutputTokens       int?     Defaults 1500.
defaults.useJudge              bool?    Defaults true if `judge` is declared, else false.

配置加载器会拒绝列表中未包含的任何字段——拼写错误会直接报错,而不是静默失败。

独立运行

export GROK_API_KEY=xai-...
export ANTHROPIC_API_KEY=sk-ant-...

ai-consensus-mcp --config ./consensus.config.json

服务器通过 stdio 使用 JSON-RPC 进行通信。启动时,类似以下的一行就绪信息:

ai-consensus-mcp ready — 3 participant(s) from 2 provider(s), judge=grok-4 (config: /abs/consensus.config.json)

会被写入 stderr;stdout 保留给 MCP 协议流。

在 MCP 主机中注册

Claude Desktop

编辑 ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) 或 Windows 等效文件:

{
  "mcpServers": {
    "consensus": {
      "command": "ai-consensus-mcp",
      "args": ["--config", "/absolute/path/to/consensus.config.json"],
      "env": {
        "GROK_API_KEY": "xai-...",
        "ANTHROPIC_API_KEY": "sk-ant-..."
      }
    }
  }
}

(如果你没有全局安装,请将 "command": "ai-consensus-mcp" 替换为 "command": "node",并将 args 指向 /path/to/ai-consensus-mcp/dist/index.js。)

重启 Claude Desktop。你应该会看到一个 consensus 工具可用。

Claude Code

claude mcp add consensus \
  --scope user \
  -- ai-consensus-mcp --config /absolute/path/to/consensus.config.json

或者直接使用相同的 command / args / env 结构编辑 ~/.claude.json

Cursor、Windsurf 及其他主机

将它们指向 ai-consensus-mcp --config <path>/consensus.config.json,并在环境中设置相关的提供商 API 密钥。仅支持 stdio 传输。

consensus 工具

输入

{
  "prompt": "Should an early-stage startup adopt microservices from day one?",
  "maxRounds": 4,            // optional, 1–10
  "participantIds": ["grok", "domain"],  // optional — subset of configured participants
  "earlyStop": true,         // optional
  "judge": true,             // optional — defaults to config.defaults.useJudge
  "blindFirstRound": true,   // optional
  "randomizeOrder": true,    // optional
  "convergenceDelta": 3,     // optional
  "disagreementThreshold": 20, // optional
  "participantTemperature": 0.7, // optional
  "maxOutputTokens": 1500,   // optional
  "randomSeed": 42           // optional — deterministic round-order shuffle
}

prompt 是必需的。其他所有内容都会回退到配置的 defaults,然后再回退到引擎的默认值。

输出

每次成功调用都会产生两个工件:

  1. content[0].text — 人类可读的 Markdown 摘要:

    • 最终得分、持续时间、停止原因

    • 每轮得分表

    • 最终轮回复,按角色 + 模型标记

    • 裁判综合意见(如果 judge: true

  2. structuredContent — 完整的 ConsensusResult JSON,供程序化消费者使用。

进度通知

每个结构化的引擎事件都会作为 MCP notifications/progress 消息转发。Token 级别的流式事件会被故意丢弃——因为它们会淹没通道。

引擎事件

进度消息示例

roundStart

Round 2/4 — Counterarguments (sequential) starting

participantStart

grok (grok-4) thinking…

participantComplete

grok done — confidence=72 (4132ms)

confidenceUpdate

running avg round 2: 74.5 (last: grok=72)

disagreementDetected

⚠ disagreement: Risk Analyst vs Optimistic Futurist (Δ=35)

roundComplete

Round 2 complete — score=71, avg=74.5, σ=7.0, disagreements=1

earlyStop

✓ Early stop at round 3: Consensus score delta 2.0 … is at or below …

synthesisStart

Judge synthesis starting (grok-4)…

synthesisComplete

Judge synthesis complete (confidence=84)

finalResult

Consensus complete — finalScore=76, rounds=3, stopReason=converged

progressroundCompletesynthesisComplete 时单调递增;totalmaxRounds + (judge ? 1 : 0)

错误

  • 配置加载错误 在启动时是致命的,并会打印到 stderr,包含出错的字段路径。

  • 工具输入错误 返回 { isError: true, content: [{ type: "text", text: "…" }] } — 主机可以看到它们,但服务器保持运行。

  • 提供商错误(HTTP 非 2xx,空流)会被捕获到每个参与者的 response.error 字段中,运行将继续处理剩余参与者。错误在进度流和最终结构化结果中均可见。

  • 取消。 当主机取消工具调用时,AbortSignal 会传播到每个正在进行的 fetch,引擎将返回一个 stopReason: "aborted"ConsensusResult

限制与非目标

  • 无持久化。 每次工具调用都是一次全新的运行。如果你需要历史记录,请在主机端记录 structuredContent

  • 无 HTTP 传输。 仅限 stdio。如需 HTTP/SSE,请直接封装 ai-consensus-core

  • 无 Token 预算强制执行。 maxOutputTokens 仅供每次调用参考;请在你的提供商仪表板上设置使用量提醒。

  • 无多运行调度。 每次调用运行一次,如果主机排队则按顺序执行。

如果这些中的任何一个成为你最需要的功能,核心库是进行扩展的正确位置——这个服务器被设计得非常小巧。

开发

git clone https://github.com/entropyvortex/ai-consensus-mcp.git
cd ai-consensus-mcp
npm install
npm run test        # vitest — config loader + MCP handshake integration
npm run build
npm start -- --config ./consensus.config.json

理念

核心库应该能够在任何地方运行——Next.js、CLI、Worker、Durable Object 或其他 MCP 服务器。这就是为什么它不知道什么是 LLM 提供商的原因。

这个包是大多数人首先关心的“任何地方”:一个可以放入 Claude Code、Cursor、Windsurf 或任何支持该协议的主机中的 stdio MCP 服务器。它被刻意保持得很小——加载配置、转发事件,仅此而已。如果你需要更多功能,核心库就在那里。

另请参阅

  • ai-consensus-core — 底层库。如果你需要 HTTP 传输、自定义调度程序或更深层的集成,请直接使用它。

许可证

MIT


entropyvortex 技术栈的一部分 — 由 Marcelo Ceccon 提供的实用、无废话的 AI 开源项目。

在巴西用 ❤️ 制作。

MIT 许可证 • 为交付而生。

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

No tool schema history has been recorded yet.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/entropyvortex/ai-consensus-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server