
magpie-council
io.github.JohnWangggg/magpie-council
Anonymous multi-model adversarial debate MCP server and CLI for your local Magpie gateway.
Documentation
Magpie Council
Multi-model anonymous debate engine, MCP server, CLI, and native sidebar page for Magpie.
简体中文 · Quick Start · How It Works · MCP Tools · Magpie Plugin · Security · Publishing
Convene 3 to 12 models already configured in your local Magpie gateway to independently analyze hard bugs, architecture trade-offs, security audits, or product roadmaps — then cross-examine each other anonymously, score peers with Borda ranking, and synthesize an actionable verdict.
Every request goes strictly through your local Magpie gateway (http://127.0.0.1:3425 or discovered MAGPIE_ADDR), so your existing accounts, quota pacing, routing groups, failover, and usage ledger work out of the box with zero extra API keys.
Highlights
- Anti-sycophancy 3-phase debate engine — Parallel blind opening prevents anchoring bias; anonymous cross-examination (
Participant A/B/C…) enforces concrete critiques, calibrated confidence (1–10), and Borda peer ranking before Judge synthesis. - Unleash each model's full capacity — Session ingestion scales to the strongest participating model's
context_window(up to 160k runes indeepmode); only smaller-window seats get per-call 70%/30% head+tail smart slicing instead of dragging down the entire council. - Deep Magpie-native integration — Zero-config gateway discovery (
MAGPIE_BASE_URL→MAGPIE_ADDR→~/.config/magpie/gateway.json), quota-pacing smart selection (/v1/magpie/quotas?kept=1), custom Chinese/English provider display-name matching (e.g.自建中转),all_models(up to 12 seats), per-seatX-Magpie-Sessionroute/failover tracing, and automatic compatibility retries (400/422params &502reasoning-budget exhaustion). - Live SSE spectator & 2x PNG share cards — Debates launched from any terminal or MCP agent appear automatically in the built-in dark/light dashboard and native Magpie sidebar page (
Council / 议会), complete with sub-second SSE progress, live interim Borda leaderboard, provider right-click quick launch, and zero-dependency Canvas 2D 2x Retina PNG export. - Crash-safe single binary — Pure Go (zero CGO), OS-level per-session
flock, atomicfsync+renamepersistence (session.json,transcript.md, standalonereport.html), orphan-runner detection, and seamless--sessioncontinuation.
How It Works
flowchart LR
U["Terminal / Agent (MCP) / Magpie Sidebar"] --> S["Magpie Discovery & Quota Selector"]
S --> R1["Phase 1: Blind Opening\n(Parallel, Isolated Seats)"]
R1 --> R2["Phase 2: Cross-Examination\n(Anonymous Critique + Borda Ranking)"]
R2 -->|Supermajority or Max Rounds| J["Phase 3: Judge Synthesis\n(Consensus · Disagreements · Actions)"]
J --> A["Atomic Store + SSE Live UI\n(session.json · transcript.md · report.html · 2x PNG)"]
- Zero-config gateway & quota awareness: Reads
GET /v1/models,GET /v1/magpie/quotas?kept=1, andGET /v1/magpie/limit, aligning seat selection with Magpie's smart pacing (resetsAt,runsOutAt,outlasts,pricing) and routing groups (group/*). - Problem-solving-first adversarial debate: Round 1 collects independent opening positions with zero peer visibility. Round 2..N anonymizes seats (
Participant A,B,C…) so models critique claims rather than brand names, absorb strong peer evidence, and converge promptly once a solid solution emerges. - Verdict & continuation: A Judge model synthesizes concise Consensus, unresolved Disagreements (Pro / Con), and concrete Recommendations (with an enriched deterministic fallback if every judge candidate fails). Continue any session anytime with
session_id+follow_upreusing the exact same seats.
Quick Start
1. Build & Install the Binary
# Apple Silicon macOS (remove first to ensure a fresh AMFI inode)
rm -f /opt/homebrew/bin/magpie-council && \
go build -o /opt/homebrew/bin/magpie-council ./cmd/magpie-council
# Intel macOS / Linux
go build -o /usr/local/bin/magpie-council ./cmd/magpie-council
2. Connect to Magpie MCP Router + Skill (Recommended for Agents)
Register magpie-council once in Magpie's Library so every agent behind Magpie (OMP, Claude Code, Codex, Devin, Cursor, Antigravity…) can convene debates natively:
magpie library mcp add council \
/opt/homebrew/bin/magpie-council mcp \
env=MAGPIE_BASE_URL=http://127.0.0.1:3425 \
call-timeout=300 idle=never
Add the companion workflow skill (skills/magpie-council/SKILL.md) or import MCP + Skill together:
magpie library plugin import /path/to/magpie-council
Then just ask your agent naturally in any terminal:
"Use all models under Magpie provider
my-relayin deep mode to review this project for concurrency bugs, optimization opportunities, and roadmap priorities."
Most meetings start mid-session, not from the page: the agent already holds the context, so it writes
the brief and calls council_debate in one step. The playbook for that (what context to hand over,
which preset, when to go async, what to do with the verdict) is in
docs/agent-usage.md.
3. Add the Native Magpie Sidebar Page (Council / 议会)
magpie plugin add /path/to/magpie-council/magpie-plugin
- Opens a Council / 议会 tab under Plugins in Magpie Desktop and
magpie web. - Adds Convene Council / 召开多模型议会 to every provider's right-click menu in Magpie's Providers list — click it to open Quick Run pre-filled with that provider.
4. Run Directly from the Terminal (CLI)
# Inspect live providers, custom display names, models, and quota health
magpie-council providers
magpie-council providers -p "my-relay"
# Fast cross-provider debate (subscription-first pacing)
magpie-council run -p auto -m fast --cost subscription_first "Evaluate SQLite vs file-backed session storage"
# Deep code review using ALL healthy models under one provider + exact line ranges
magpie-council run -p "my-relay" --all-models -m deep --preset code_review \
--context-file "/abs/path/server.go:1-240,/abs/path/engine.go" \
"Audit concurrency races, edge-case bugs, and high-ROI optimizations"
# Continue or recover an existing debate with new constraints
magpie-council run --session <session_id> --follow-up "New constraint: zero CGO; dig deeper into Disagreement #1"
# Inspect saved sessions, specific rounds, or standalone HTML report path
magpie-council session --list
magpie-council session <session_id> --transcript --round 2
magpie-council session <session_id> --report
# Manage persistent defaults (~/.config/magpie-council/config.json)
magpie-council config show
magpie-council config set mode=deep language=zh
# Launch the standalone spectator dashboard (default 127.0.0.1:3497)
magpie-council ui --addr 127.0.0.1:3497
MCP Tools & Presets
Tools Exposed by magpie-council mcp
| Tool | Purpose | Key Parameters |
|---|---|---|
council_providers | List enabled Magpie providers, custom display names, routing groups, models, context windows, and quota health | provider (ID, display name, or substring) |
council_debate | Convene a new debate or continue an existing session_id (supports 12s progress heartbeats and async: true background execution) | topic, provider, all_models, seats, models, mode, preset, cost_preference, context, context_files (supports :start-end), max_context_runes, session_id, follow_up, async |
council_session | Poll running progress (including live lock & orphan recovery hints) or fetch the final verdict, report.html path, and optional verbatim transcript | session_id, include_transcript, round |
Modes & Presets
| Mode / Preset | Behavior |
|---|---|
fast (default) | Up to 3 rounds, concise structured responses, X-Magpie-Fallback: 1, 60s per-call budget |
deep | Up to 5 rounds, unrestricted high-density reasoning (max_tokens up to 16,384, context up to 160k runes), 150s per-call budget |
architecture (default) | Architect · RedTeam · Pragmatist (+ Evolution / Security / Systems / DX / Testing seats when seats > 3) |
code_review | BugHunter · Maintainability · Performance |
security | Attacker · Defender · Compliance |
product | UserAdvocate · Skeptic · Delivery |
Native Magpie Page Plugin
The native page plugin in magpie-plugin/ follows Magpie's kind: "page" specification:
- Launcher (
magpie-plugin/page/index.html+boot.js): Runs in Magpie's strict CSP sandbox (connect-src 'none', zero inline scripts), negotiates theme/language/options/provider actions over_magpie/bridge.js, and navigates towindow.magpie.service(proxied remotemagpie web) orhttp://127.0.0.1:3493/(with SSH tunnel guidance on older remote setups). - Host part (
magpie-plugin/index.mjs): OpenCode v1{ id, server }export loaded by Magpie's Bun host. Adopts a runningmagpie-council uior spawns and supervises one withstderrdraining and bounded backoff restarts. - Plugin options (Plugins › Installed › Magpie Council › Options or
magpie plugin options):
{
"port": 3493,
"binary": "",
"gatewayUrl": ""
}
Environment Variables
| Variable | Default | Description |
|---|---|---|
MAGPIE_BASE_URL | Auto-discovered | Explicit Magpie gateway URL (overrides MAGPIE_ADDR and gateway.json) |
MAGPIE_ADDR | Set by Magpie host | Gateway host:port (auto-inherited inside Magpie's plugin host and sandboxes) |
MAGPIE_API_KEY | (empty) | Optional Magpie gateway API key (for LAN/remote or key-restricted setups) |
MAGPIE_COUNCIL_DATA_DIR | ~/.local/share/magpie-council/sessions | Directory where session.json, transcript.md, and report.html are stored |
MAGPIE_COUNCIL_CONFIG | ~/.config/magpie-council/config.json | Persistent user defaults shared by CLI, MCP, and Web UI |
MAGPIE_COUNCIL_LANG | auto | Output language override (zh or en); takes precedence over config.json |
MAGPIE_COUNCIL_ALLOWED_ROOTS | (unrestricted) | Optional colon-separated allowlist restricting which root directories context_files may read |
MAGPIE_COUNCIL_BIN | Auto-resolved | Explicit path to the magpie-council binary used by magpie-plugin/index.mjs |
Data and Security
- Zero external telemetry or credential storage:
magpie-councilregisters no provider, stores no upstream API keys, and sends zero telemetry. All model inference goes exclusively through your configured Magpie gateway. - Zero bridge reads:
magpie-plugin/package.jsondeclares"permissions": []— the sandboxed page reads no private Magpie bridge data. - Hardened loopback UI service (
127.0.0.1, default3493in the plugin /3497standalone):- Validates loopback
Hostheaders (127.0.0.1,localhost,::1,*.localhost) to block DNS rebinding. - Guards every JSON API, SSE stream, and HTML report route with a 256-bit
X-Council-Token(created atomically with0600permissions) embedded only inGET /withCache-Control: no-storeand no permissive CORS. - Blocks unauthenticated cross-origin and
Sec-Fetch-Site: cross-siterequests while supporting same-originmagpie webreverse proxying. - Sets
Referrer-Policy: no-referrerandX-Content-Type-Options: nosniffon responses.
- Validates loopback
- Safe server-side file ingestion:
context_filesopens paths with UnixO_NONBLOCK+ regular-filefstat(never blocks on FIFOs/devices), rejects binary NUL files before truncation, trims cleanly on UTF-8 rune boundaries, and resolves symlinks viaos.SameFilewhenMAGPIE_COUNCIL_ALLOWED_ROOTSis set.
Scope & Known Limits
- Why stdio MCP instead of Magpie's
toolhook: Magpie's plugintoolhook enforces a hard 55-second timeout and has no MCPnotifications/progresschannel. Running the 3 tools through stdio MCP (magpie-council mcp) supports multi-minutedeepdebates, 12s progress heartbeats, andasync: truebackground sessions without duplicating tools in Magpie Library. - Default ports: The page plugin's service defaults to
3493(3497is@magpie-community/page-amp-usage,page-window-warmupuses3492,page-usage-tree3494,page-harnessweight3496). The standalonemagpie-council uiCLI defaults to3497; pass--addror change"port"in Plugin Options if needed. - Quota usage: Every debate sends live chat completion requests through your Magpie gateway and consumes the selected provider/account quota.
Project Structure
magpie-council/
├── assets/icon.svg # Brand SVG icon (128x128 viewBox)
├── cmd/magpie-council/ # Single-binary CLI / MCP / UI entrypoint
├── internal/
│ ├── config/ # Shared defaults & MAGPIE_COUNCIL_LANG override
│ ├── debate/ # 3-phase debate engine, prompts, context_files
│ ├── magpie/ # Magpie gateway client, route/quota/limit, compat retry
│ ├── mcpserver/ # Official Go MCP SDK stdio server
│ ├── selector/ # Quota-pacing model selector & display-name matcher
│ ├── store/ # Atomic persistence, flock, stat cache, report.html
│ └── webui/ # Hardened HTTP/SSE server & embedded dashboard.html
├── magpie-plugin/ # Native Magpie page plugin (index.mjs, page/, registry-entry.json)
├── docs/agent-usage.md # Mid-session playbook: brief, presets, async, verdict handoff
├── npm/ # Zero-dependency npx Go binary launcher (SHA-256 verified)
├── skills/magpie-council/SKILL.md # Canonical agent workflow skill
├── server.json # Official MCP Registry manifest
└── PUBLISHING.md # Release & Magpie Market publishing guide
Development & Verification
go vet ./...
go test -race -count=3 ./...
go build -o ./bin/magpie-council ./cmd/magpie-council
node --check magpie-plugin/index.mjs magpie-plugin/page/boot.js npm/bin/magpie-council.js
See PUBLISHING.md for GoReleaser, npm launcher, Official MCP Registry (server.json), magpie library plugin import, npx skills add, and magpie-community/plugins submission steps.
License
MIT © 2026 magpie-council contributors. See LICENSE.
magpie-councilnpm install magpie-council