mcp-cocktail
Provides a framework to benchmark, evaluate, and inject real-time guardrails across competing MCP servers, CLIs, and AI agent tools. It enables recursive self-improvement by mining failures and synthesizing weakest valid guardrails.
README
mcp-cocktail
A domain-agnostic, Recursive Self-Improvement (RSI) framework for benchmarking, evaluating, and injecting real-time guardrails across competing MCP servers, CLIs, and AI agent tools.
When software vendors take months or years to release official Model Context Protocol (MCP) servers or command-line tools, open-source communities fill the vacuum with unofficial MCPs, wrappers, and CLIs. This fragmentation leads to competing tools ("arms") with varying degrees of stability, silent failures, and trap behavior.
mcp-cocktail provides the machinery to:
- Inject Real-Time PreToolUse Guardrails: Intercept tool calls right before a known trap is sprung (
mcp-cocktail check/install-hook). - Benchmark Multi-Arm Ecosystems: Run subagents in unison across all available MCPs and CLIs (
mcp-cocktail run). - Log & Mine Friction: Capture real-time friction notes (
mcp-cocktail note) and mine subagent transcripts for failure patterns P1-P5 (mcp-cocktail mine). - Drive Weakness-Maximizing RSI Loops: Synthesize scorecards (
mcp-cocktail scorecard --rsi) and auto-derive Weakest Valid Guardrails (traps.json) based on Bennett (2023).
⚡ Quickstart (30 Seconds)
# 1. Install mcp-cocktail
pip install -e .
# 2. Automated Setup & Doctor Health Check for your domain (e.g. unity)
mcp-cocktail setup --preset unity
# 3. Test Guardrail Execution (< 5ms interception)
mcp-cocktail check --selftest
🤝 Zero-Friction Collaborator Setup (Committing Rules to Git)
By committing mcp-cocktail.json, traps.json, and harness configuration files (.claude/settings.json, .omp/settings.json, mcp.json) directly to your project's Git repository, every teammate and AI agent on your team inherits the guardrails automatically:
# Inside your project repo:
git add mcp-cocktail.json traps.json .claude/ .omp/ docs/
git commit -m "chore: add mcp-cocktail guardrails and tool manifest"
git push
When a collaborator clones or pulls the repository:
- Their agent harness (Claude Code, Oh My Pi, Cursor, VS Code) automatically detects the guardrails and configuration files on startup.
- Teammates enjoy real-time trap shielding without needing any manual setup!
📖 Progressive Walkthrough
1. Initialize or Discover Workspace Manifests
Create a workspace config (mcp-cocktail.json) manually or auto-discover candidate MCPs and CLIs from GitHub and registries:
# Auto-discover open-source MCPs & CLIs for a domain (non-destructive merge)
mcp-cocktail discover --domain postgres
# Generate an agentic scout subagent task for deep web discovery
mcp-cocktail discover --domain unity --agentic
mcp-cocktail.json structure:
{
"name": "unity-ecosystem",
"description": "Multi-arm evaluation manifest for Unity CLI and MCP servers",
"arms": [
{
"id": "unity-cli",
"name": "Official Unity CLI",
"type": "cli",
"command": "unity",
"health_check": "unity status --json"
},
{
"id": "official-mcp",
"name": "Official Unity MCP",
"type": "mcp",
"mcp_server": "unity-editor-mcp",
"tool_prefix": "mcp__unity-editor-mcp__",
"health_check": "unity status --json"
},
{
"id": "coplay-mcp",
"name": "CoplayDev Unity MCP",
"type": "mcp",
"mcp_server": "UnityMCP",
"tool_prefix": "mcp__UnityMCP__",
"setup_script": "tools/three-way-setup.sh"
}
],
"trial_defaults": {
"concurrency": "serial",
"scene_strategy": "auto",
"timeout_seconds": 300
}
}
2. Validate Arm Health (mcp-cocktail doctor)
Probe CLI binary PATHs, stdio MCP initialize capabilities, and HTTP endpoints to report an honest status summary:
mcp-cocktail doctor
Reports:
- 🟢
[READY](CLI active or stdio MCP server initialized with tool count) - 🟡
[BOUND_ONLY (P4)](Socket bound but session unauthenticated / unregistered) - 🟠
[UNCONFIGURED](Setup script missing or parameter unconfigured) - 🔴
[OFFLINE](Process or port unreachable)
3. Native MCP Server Interface (mcp-cocktail serve) & Transparent Proxy (mcp-cocktail proxy)
Mount mcp-cocktail directly into your agent's MCP config (.claude/settings.json or mcp.json) to expose native tools or wrap target MCP servers:
{
"mcpServers": {
"mcp-cocktail": {
"command": "mcp-cocktail",
"args": ["serve"]
},
"unity-editor-mcp": {
"command": "mcp-cocktail",
"args": ["proxy", "--", "unity-editor-mcp"]
}
}
}
Exposes:
mcp__mcp-cocktail-server__note_frictionmcp__mcp-cocktail-server__check_guardrailmcp__mcp-cocktail-server__get_scorecardmcp__mcp-cocktail-server__run_trial
4. Generate Multi-Arm Trial Briefs & Subagent Payloads
Create standardized briefs and subagent task payloads for subagents to execute the same task independently across defined arms:
# Standard serial trial run (< 1s instant baseline scene reload)
mcp-cocktail run T-001 "Build scene hierarchy for vehicle physics" --exec auto
# Visual comparison mode (leaves temporary scene files for human Unity Editor review)
mcp-cocktail run T-001 "Build scene hierarchy" --compare-visual
Generates:
docs/trials/T-001/brief-unity-cli.mddocs/trials/T-001/brief-official-mcp.mddocs/trials/T-001/trial-meta.jsondocs/trials/T-001/trial-tasks.json
5. Log Friction & Mine Transcripts for P1-P5 Patterns
Subagents or humans can capture friction observations mid-task:
mcp-cocktail note "CLI command ignores positional table filter silently" --cost 15
Mine session transcripts to rank tool usage, identify error clusters, and auto-detect recurring trap patterns (P1 Startup Snapshot, P2 Confident Wrong Answer, P3 Termination $\neq$ Completion, P4 Green Light, P5 Ignored Arguments):
mcp-cocktail mine sweep
mcp-cocktail mine stats <session-uuid>
🔄 The 4 RSI Exhaust Pipelines
When an agent encounters a bug, silent failure, or trap in a tool arm, mcp-cocktail generates 4 distinct, purpose-built exhaust deliverables:
| Exhaust Pipeline | Target Audience | Format / Location | Action Taken |
|---|---|---|---|
| 1. Machine Guardrail | Active session & future local agents | traps.json |
Weakness Maximization computes a regex matcher + warning payload (< 5ms interception). |
| 2. In-Repo Guidance | Humans & agents in the repo | DOMAIN-NOTES.md |
Promoted into structured pattern entries (P1-P5). Teaches agents how to use the tools correctly. |
| 3. Open-Source Patch | Community MCPs / CLIs | Subagent Task Spec (generate_patch_task) |
Spawns a subagent task to write a failing test, fix the source code (CoplayDev/unity-mcp), and open a PR. |
| 4. Upstream Vendor Draft | Vendor engineering teams | docs/upstream/*.md (mcp-cocktail upstream) |
Generates structured markdown issue templates with verbatim payloads, step sequences, and diagnostic PID/socket evidence. |
🔬 Theoretical Foundation: Weakness Maximization (Bennett, 2023)
Standard AI theory often relies on Ockham’s Razor or Minimum Description Length (MDL) — assuming that the shortest hypothesis is the most likely to generalize.
As proven by Michael Timothy Bennett (2023) in "The Optimal Choice of Hypothesis Is the Weakest, Not the Shortest" (arXiv:2301.12987v4):
Compression/length is neither necessary nor sufficient for generalization. Instead, to maximize the probability that an inferred hypothesis generalizes, it is necessary and sufficient to select the WEAKEST valid hypothesis — the explanation with maximum generality (least specificity) that remains consistent with observations.
How mcp-cocktail Applies Weakness Maximization:
- An over-fitted guardrail rule (e.g. matching
unity command --foo --bar --baz) fails to protect agents callingunity command --other. mcp-cocktailuses the Rule of Least Specificity inmcp_cocktail.weakness: it generalizes raw friction observations into the broadest valid regex matchers that maximize coverage over potential tool call spaces while maintaining zero false positives on safe/read-only calls.
mcp-cocktail scorecard --rsi
📁 Architecture & Data Layout
my-project/
├── mcp-cocktail.json # 1. Manifest: Arms, health checks, CLI commands, capabilities
├── traps.json # 2. Rule Store: Active PreToolUse trap rules & matchers
├── .claude/
│ └── settings.json # 3. Client Config: PreToolUse hook pointing to mcp-cocktail check
└── docs/
├── findings-inbox.md # 4. Raw Friction Inbox: Mid-task append-only notes
├── tooling-scorecard.md # 5. Synthesized Scorecard: Automated ranking table
├── upstream/ # 6. Upstream Vendor Bug Reports: Feedback drafts for official tools
└── trials/ # 7. Benchmark Data Store: Trial briefs, meta, tasks, and reports
└── T-001/
├── brief-unity-cli.md
├── unity-cli.md
├── trial-meta.json
└── trial-tasks.json
🎮 Reference Datasets
See examples/unity/ for a complete reference dataset containing:
- Multi-arm evaluation manifest (
examples/unity/cocktail.json) with 11 curated arms - Comprehensive Unity trap rule store (
examples/unity/traps.json) - Historic trial reports and scorecard (
examples/unity/docs/trials/) - Historical research log (
examples/unity/UNITY-TOOLING-NOTES.md)
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。