Invoke AI CLI agents as tools with parallel execution and retries
Nexus MCP
A MCP server that enables AI models to invoke AI CLI agents (Gemini CLI, Codex, Claude Code, OpenCode) as tools. Provides parallel execution, automatic retries with exponential backoff, JSON-first response parsing, and structured output through five MCP tools.
Use Cases
Nexus MCP is useful whenever a task benefits from querying multiple AI agents in parallel rather than sequentially:
- Research & summarization — fan out a topic to multiple agents, then synthesize their responses into a single summary with diverse perspectives
- Code review — send different files or review angles (security, correctness, style) to separate agents simultaneously
- Multi-model comparison — prompt the same question to different models and compare outputs side-by-side for quality or consistency
- Bulk content generation — generate multiple test cases, translations, or documentation pages concurrently instead of one at a time
- Second-opinion workflows — get independent answers from separate agents before making a decision, reducing single-model bias
Features
- Parallel execution —
batch_promptfans out tasks withasyncio.gatherand a configurable semaphore (default concurrency: 3) - Automatic retries — exponential backoff with full jitter for transient errors (HTTP 429/503)
- Output handling — JSON-first parsing, brace-depth fallback for noisy stdout, temp-file spillover for outputs exceeding 50 KB
- Execution modes —
default(safe, no auto-approve),yolo(full auto-approve) - CLI detection — auto-detects binary path, version, and JSON output capability at startup
- Session preferences — set defaults for execution mode, model, max retries, output limit, and timeout once per session; subsequent calls inherit them without repeating parameters
- Tool timeouts — configurable safety timeout (default 15 min) cancels long-running tool calls to prevent the server from blocking indefinitely
- Client-visible logging — runner events (retries, output truncation, error recovery) are sent to MCP clients via protocol notifications, not just server stderr
- Extensible — implement
build_command+parse_output, register inRunnerFactory
| Agent | Status |
|---|---|
| Gemini CLI | Supported |
| Codex | Supported |
| Claude Code | Supported |
| OpenCode | Supported |
Installation
Run with uvx (recommended)
uvx nexus-mcp
uvx installs the package in an ephemeral virtual environment and runs it — no cloning required.
To check the installed version:
uvx nexus-mcp --version
To update to the latest version:
uvx --reinstall nexus-mcp
MCP Client Configuration
Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
"mcpServers": {
"nexus-mcp": {
"command": "uvx",
"args": ["nexus-mcp"],
"env": {
"NEXUS_GEMINI_MODEL": "gemini-3-flash-preview",
"NEXUS_GEMINI_MODELS": "gemini-3.1-pro-preview,gemini-3-flash-preview,gemini-2.5-pro,gemini-2.5-flash,gemini-2.5-flash-lite",
"NEXUS_CODEX_MODEL": "gpt-5.2",
"NEXUS_CODEX_MODELS": "gpt-5.4,gpt-5.4-mini,gpt-5.3-codex,gpt-5.2-codex,gpt-5.2,gpt-5.1-codex-max,gpt-5.1-codex-mini",
"NEXUS_OPENCODE_MODEL": "ollama-cloud/kimi-k2.5",
"NEXUS_OPENCODE_MODELS": "ollama-cloud/glm-5,ollama-cloud/kimi-k2.5,ollama-cloud/qwen3-coder-next,ollama-cloud/minimax-m2.5,ollama/gemini-3-flash-preview"
}
}
}
}
Cursor (.cursor/mcp.json in your project or ~/.cursor/mcp.json globally):
{
"mcpServers": {
"nexus-mcp": {
"command": "uvx",
"args": ["nexus-mcp"],
"env": {
"NEXUS_GEMINI_MODEL": "gemini-3-flash-preview",
"NEXUS_GEMINI_MODELS": "gemini-3.1-pro-preview,gemini-3-flash-preview,gemini-2.5-pro,gemini-2.5-flash,gemini-2.5-flash-lite",
"NEXUS_CODEX_MODEL": "gpt-5.2",
"NEXUS_CODEX_MODELS": "gpt-5.4,gpt-5.4-mini,gpt-5.3-codex,gpt-5.2-codex,gpt-5.2,gpt-5.1-codex-max,gpt-5.1-codex-mini",
"NEXUS_OPENCODE_MODEL": "ollama-cloud/kimi-k2.5",
"NEXUS_OPENCODE_MODEL
Tools (1)
batch_promptExecutes prompts across multiple AI agents in parallel with automatic retries.Environment Variables
NEXUS_GEMINI_MODELDefault Gemini model to useNEXUS_CODEX_MODELDefault Codex model to useNEXUS_OPENCODE_MODELDefault OpenCode model to useConfiguration
{"mcpServers": {"nexus-mcp": {"command": "uvx", "args": ["nexus-mcp"], "env": {"NEXUS_GEMINI_MODEL": "gemini-3-flash-preview", "NEXUS_CODEX_MODEL": "gpt-5.2", "NEXUS_OPENCODE_MODEL": "ollama-cloud/kimi-k2.5"}}}}