MCP Hub
Back to servers

cli-agent-mcp

A unified MCP server that orchestrates multiple CLI agents including Codex, Gemini, Claude, and OpenCode, featuring image generation capabilities and a real-time GUI dashboard for task monitoring.

Stars
11
Tools
7
Updated
Jan 4, 2026
Validated
Jan 9, 2026

cli-agent-mcp

中文文档

Unified MCP (Model Context Protocol) server for CLI AI agents. Provides a single interface to invoke Codex, Gemini, Claude, OpenCode CLI tools, and Nano Banana Pro image generation.

Why cli-agent-mcp?

This is more than a CLI wrapper — it's an orchestration pattern for multi-model collaboration.

Can't articulate your requirements clearly? Let Claude orchestrate. Describe what you want, and it will decompose your vague idea into concrete tasks for the right agent. The act of delegation forces clarity.

Planning a grand product vision? Each model brings a unique lens:

  • Codex: The critic. Its analytical eye catches what you missed, challenges assumptions, finds edge cases.
  • Gemini: The creative. Divergent thinking, unexpected connections, the spark you didn't know you needed.
  • Claude: The scribe. Faithful execution, clear documentation, turning ideas into working code.
  • Banana: The artist. High-fidelity image generation for UI mockups, product visuals, and creative assets.

Want persistent results? Use save_file to capture agent outputs, then let Claude synthesize insights across multiple analyses.

We don't just wrap CLIs — we provide a thinking framework for human-AI collaboration.

Features

  • Unified Interface: Single MCP server exposing multiple CLI agents
  • GUI Dashboard: Real-time task monitoring with pywebview
  • Request Isolation: Per-request execution context for safe concurrent usage
  • Signal Handling: Graceful cancellation via SIGINT without killing the server
  • Debug Logging: Comprehensive subprocess output capture for debugging

Screenshot

CLI Agent MCP GUI

Installation

# Install from PyPI (when published)
uvx cli-agent-mcp

# Install from GitHub
uvx --from git+https://github.com/shiharuharu/cli-agent-mcp.git cli-agent-mcp

# Install from source (editable mode for development)
uvx --from /path/to/cli-agent-mcp cli-agent-mcp

# Or use pip
pip install -e .

Configuration

Configure via environment variables:

VariableDescriptionDefault
CAM_ENABLEComma-separated list of enabled tools (empty = all)"" (all)
CAM_DISABLEComma-separated list of disabled tools (subtracted from enable)""
CAM_GUIEnable GUI dashboardtrue
CAM_GUI_DETAILGUI detail modefalse
CAM_GUI_KEEPKeep GUI on exitfalse
CAM_DEBUGInclude debug info in MCP responsesfalse
CAM_LOG_DEBUGWrite debug logs to temp filefalse
CAM_SIGINT_MODESIGINT handling (cancel/exit/cancel_then_exit)cancel
CAM_SIGINT_DOUBLE_TAP_WINDOWDouble-tap exit window (seconds)1.0

Tools

codex

Invoke OpenAI Codex CLI agent for deep code analysis and critical review.

Best for: Code review, bug hunting, security analysis

ParameterTypeRequiredDefaultDescription
promptstring-Task instruction for the agent
workspacestring-Absolute path to the project directory
continuation_idstring""Pass from previous response to continue conversation
permissionstringread-onlyPermission level: read-only, workspace-write, unlimited
modelstring""Model override (only specify if explicitly requested)
save_filestring""PREFERRED for large outputs. Writes directly to file, avoiding context overflow
report_modebooleanfalseGenerate standalone report format
save_file_with_wrapperbooleanfalseWrap output with <agent-output> XML tags
save_file_with_append_modebooleanfalseAppend to file instead of overwriting
verbose_outputbooleanfalseReturn detailed output including reasoning
context_pathsarray[]Reference file/directory paths to provide context
imagearray[]Absolute paths to image files for visual context
task_notestring""Display label for GUI
debugboolean(global)Override debug setting for this call

gemini

Invoke Google Gemini CLI agent for UI design and comprehensive analysis.

Best for: UI mockups, image analysis, requirement discovery, full-text analysis

ParameterTypeRequiredDefaultDescription
promptstring-Task instruction for the agent
workspacestring-Absolute path to the project directory
continuation_idstring""Pass from previous response to continue conversation
permissionstringread-onlyPermission level: read-only, workspace-write, unlimited
modelstring""Model override
save_filestring""PREFERRED for large outputs. Writes directly to file, avoiding context overflow
report_modebooleanfalseGenerate standalone report format
save_file_with_wrapperbooleanfalseWrap output with <agent-output> XML tags
save_file_with_append_modebooleanfalseAppend to file instead of overwriting
verbose_outputbooleanfalseReturn detailed output including reasoning
context_pathsarray[]Reference file/directory paths to provide context
task_notestring""Display label for GUI
debugboolean(global)Override debug setting for this call

claude

Invoke Anthropic Claude CLI agent for code implementation.

Best for: Feature implementation, refactoring, code generation

ParameterTypeRequiredDefaultDescription
promptstring-Task instruction for the agent
workspacestring-Absolute path to the project directory
continuation_idstring""Pass from previous response to continue conversation
permissionstringread-onlyPermission level: read-only, workspace-write, unlimited
modelstring""Model override (sonnet, opus, or full model name)
save_filestring""PREFERRED for large outputs. Writes directly to file, avoiding context overflow
report_modebooleanfalseGenerate standalone report format
save_file_with_wrapperbooleanfalseWrap output with <agent-output> XML tags
save_file_with_append_modebooleanfalseAppend to file instead of overwriting
verbose_outputbooleanfalseReturn detailed output including reasoning
context_pathsarray[]Reference file/directory paths to provide context
system_promptstring""Complete replacement for the default system prompt
append_system_promptstring""Additional instructions appended to default prompt
agentstring""Specify agent name (overrides default agent setting)
task_notestring""Display label for GUI
debugboolean(global)Override debug setting for this call

opencode

Invoke OpenCode CLI agent for full-stack development.

Best for: Rapid prototyping, multi-framework projects

ParameterTypeRequiredDefaultDescription
promptstring-Task instruction for the agent
workspacestring-Absolute path to the project directory
continuation_idstring""Pass from previous response to continue conversation
permissionstringread-onlyPermission level: read-only, workspace-write, unlimited
modelstring""Model override (format: provider/model)
save_filestring""PREFERRED for large outputs. Writes directly to file, avoiding context overflow
report_modebooleanfalseGenerate standalone report format
save_file_with_wrapperbooleanfalseWrap output with <agent-output> XML tags
save_file_with_append_modebooleanfalseAppend to file instead of overwriting
verbose_outputbooleanfalseReturn detailed output including reasoning
context_pathsarray[]Reference file/directory paths to provide context
filearray[]Absolute paths to files to attach
agentstringbuildAgent type: build, plan, etc.
task_notestring""Display label for GUI
debugboolean(global)Override debug setting for this call

banana

Generate high-fidelity images via the Nano Banana Pro API.

Best for: UI mockups, product visuals, infographics, architectural renders, character art

Nano Banana Pro has exceptional understanding and visual expression capabilities—your prompt creativity is the only limit, not the model.

ParameterTypeRequiredDefaultDescription
promptstring-Image generation prompt
save_pathstring-Base directory for saving images
task_notestring-Subdirectory name (English recommended, e.g., 'hero-banner'). Files saved to {save_path}/{task_note}/
imagesarray[]Reference images (absolute paths) with optional role and label
aspect_ratiostring"1:1"Image aspect ratio: 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9
resolutionstring"1K"Image resolution: 1K, 2K, 4K
include_thoughtsbooleanfalseInclude thinking process in response

Environment Variables:

VariableRequiredDefaultDescription
BANANA_AUTH_TOKEN-Google API key or Bearer token
BANANA_ENDPOINThttps://generativelanguage.googleapis.comAPI endpoint (version path auto-appended)

Prompt Best Practices:

  • Explicitly request an image (e.g., start with "Generate an image:" or include "output":"image")
  • Use structured specs (JSON / XML tags / labeled sections) for complex requests
  • Use MUST/STRICT/CRITICAL for non-negotiable constraints
  • Add negative constraints (e.g., "no watermark", "no distorted hands")

image

Generate images via OpenRouter-compatible or OpenAI-compatible endpoints.

Best for: General image generation when you need compatibility with various providers. For best results with Gemini models, use the banana tool instead.

ParameterTypeRequiredDefaultDescription
promptstring-Image generation prompt
save_pathstring-Base directory for saving images
task_notestring-Subdirectory name (English recommended, e.g., 'hero-banner'). Files saved to {save_path}/{task_note}/
imagesarray[]Reference images (absolute paths) with optional role and label
aspect_ratiostring"1:1"Image aspect ratio: 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9
resolutionstring"1K"Image resolution: 1K, 2K, 4K
modelstring(env)Model to use for generation
api_typestring(env)API type: openrouter_chat, openai_images, openai_responses

Environment Variables:

VariableRequiredDefaultDescription
IMAGE_AUTH_TOKEN-API key for image generation
IMAGE_ENDPOINThttps://openrouter.ai/apiAPI endpoint (version path auto-appended)
IMAGE_MODELgpt-image-1Default model
IMAGE_API_TYPEopenrouter_chatAPI type: openrouter_chat, openai_images, openai_responses

get_gui_url

Get the GUI dashboard URL. Returns the HTTP URL where the live event viewer is accessible.

No parameters required.

Prompt Injection

Some parameters automatically inject additional content into the prompt using <mcp-injection> XML tags. These tags make it easy to debug and identify system-injected content.

report_mode

When save_file and report_mode are both set, output format requirements are injected:

<your prompt>

<mcp-injection type="output-format">
  <output-requirements>
    <rule>This response will be saved as a standalone document.</rule>
    <rule>Write so it can be understood WITHOUT any prior conversation context.</rule>
    <rule>Do NOT reference "above", "previous messages", or "as discussed".</rule>
    <rule>Use the same language as the user's request.</rule>
  </output-requirements>
  <structure>
    <section name="Summary">3-7 bullet points with key findings and conclusions</section>
    <section name="Context">Restate the task/problem so readers understand without chat history</section>
    <section name="Analysis">Step-by-step reasoning with evidence; include file:line references</section>
    <section name="Recommendations">Actionable next steps ordered by priority</section>
  </structure>
  <note>Write with enough detail to be useful standalone, but avoid unnecessary filler.</note>
</mcp-injection>

context_paths

When context_paths is provided, reference paths are injected:

<your prompt>

<mcp-injection type="reference-paths">
  <description>
    These paths are provided as reference for project structure.
    You may use them to understand naming conventions and file organization.
  </description>
  <paths>
    <path>/src/api/handlers.py</path>
    <path>/config/settings.json</path>
  </paths>
</mcp-injection>

Stateless Design

Important: Each tool call is stateless - the agent has NO memory of previous calls.

  • New conversation (no continuation_id): Include ALL relevant context in your prompt - background, specifics, constraints, and prior findings.
  • Continuing conversation (with continuation_id): The agent retains context from that session, so you can be brief.

If your request references prior context (e.g., "fix that bug", "continue the work"), you must either:

  1. Provide continuation_id from a previous response, OR
  2. Expand the reference into concrete details

File Output Options

save_file_with_wrapper

When enabled, output is wrapped with XML tags containing metadata:

<agent-output agent="gemini" continuation_id="abc123">
... agent response ...
</agent-output>

save_file_with_append_mode

When enabled, new output is appended to existing file instead of overwriting. Combined with save_file_with_wrapper, enables multi-agent collaboration:

<agent-output agent="codex" continuation_id="...">
Critical analysis of the codebase...
</agent-output>

<agent-output agent="gemini" continuation_id="...">
Creative suggestions for improvement...
</agent-output>

<agent-output agent="claude" continuation_id="...">
Implementation summary...
</agent-output>

Response Format

All responses are wrapped in XML format:

Success Response

<response>
  <thought_process>...</thought_process>  <!-- Only when verbose_output=true -->
  <answer>
    Agent's response content...
  </answer>
  <continuation_id>session-id-here</continuation_id>
  <debug_info>...</debug_info>  <!-- Only when debug=true -->
</response>

Error Response

Error responses include partial progress to enable retry:

<response>
  <error>Error message</error>
  <thought_process>...</thought_process>  <!-- Collected steps before error -->
  <partial_answer>...</partial_answer>    <!-- Partial output if any -->
  <continuation_id>session-id</continuation_id>
  <hint>Task failed. Above is the output collected so far. You can send 'continue' with this continuation_id to retry.</hint>
  <debug_info>...</debug_info>
</response>

Permission Levels

LevelDescriptionCodexGeminiClaudeOpenCodeBanana
read-onlyCan only read files--sandbox read-onlyRead-only tools only--tools Read,Grep,Globedit: deny, bash: denyRead workspace images only
workspace-writeCan modify files within workspace--sandbox workspace-writeAll tools + sandbox--tools Read,Edit,Write,Bashedit: allow, bash: askWrite to workspace only
unlimitedFull system access (use with caution)--sandbox danger-full-accessAll tools, no sandbox--tools defaultedit: allow, bash: allowFull access

Debug Mode

Enable debug mode to get detailed execution information:

# Enable debug info in responses
export CAM_DEBUG=true

# Enable detailed log file
export CAM_LOG_DEBUG=true

When CAM_LOG_DEBUG=true, logs are written to:

/tmp/cli-agent-mcp/cam_debug_YYYYMMDD_HHMMSS.log

Debug output includes:

  • Full subprocess command
  • Complete stdout/stderr output
  • Return codes
  • MCP request/response summaries

MCP Configuration

Add to your MCP client configuration (e.g., Claude Desktop claude_desktop_config.json):

Basic Configuration

{
  "mcpServers": {
    "cli-agent-mcp": {
      "command": "uvx",
      "args": ["cli-agent-mcp"]
    }
  }
}

Install from GitHub

{
  "mcpServers": {
    "cli-agent-mcp": {
      "command": "uvx",
      "args": [
        "--from",
        "git+https://github.com/shiharuharu/cli-agent-mcp.git",
        "cli-agent-mcp"
      ]
    }
  }
}

With Debug Mode

{
  "mcpServers": {
    "cli-agent-mcp": {
      "command": "uvx",
      "args": [
        "--from",
        "git+https://github.com/shiharuharu/cli-agent-mcp.git",
        "cli-agent-mcp"
      ],
      "env": {
        "CAM_DEBUG": "true",
        "CAM_LOG_DEBUG": "true"
      }
    }
  }
}

Disable GUI

{
  "mcpServers": {
    "cli-agent-mcp": {
      "command": "uvx",
      "args": ["cli-agent-mcp"],
      "env": {
        "CAM_GUI": "false"
      }
    }
  }
}

Limit Available Tools

{
  "mcpServers": {
    "cli-agent-mcp": {
      "command": "uvx",
      "args": ["cli-agent-mcp"],
      "env": {
        "CAM_ENABLE": "claude,gemini"
      }
    }
  }
}

Disable Image Tools

{
  "mcpServers": {
    "cli-agent-mcp": {
      "command": "uvx",
      "args": ["cli-agent-mcp"],
      "env": {
        "CAM_DISABLE": "banana,image"
      }
    }
  }
}

Project Structure

cli-agent-mcp/
├── src/cli_agent_mcp/
│   ├── __init__.py          # Package exports
│   ├── __main__.py          # Entry point
│   ├── app.py               # Server lifecycle (run_server, main)
│   ├── server.py            # MCP protocol adapter (create_server)
│   ├── tool_schema.py       # Tool descriptions and JSON schemas
│   ├── config.py            # Configuration management
│   ├── gui_manager.py       # GUI dashboard manager
│   ├── orchestrator.py      # Request registry
│   ├── signal_manager.py    # Signal handling (SIGINT/SIGTERM)
│   ├── handlers/            # Tool handlers
│   │   ├── base.py          # ToolContext, ToolHandler base class
│   │   ├── cli.py           # CLI tools (codex/gemini/claude/opencode)
│   │   ├── parallel.py      # Parallel execution (*_parallel tools)
│   │   └── image_tools.py   # Image tools (banana/image)
│   ├── utils/               # Utility functions
│   │   ├── xml_wrapper.py   # XML escaping and wrapper building
│   │   └── prompt_injection.py  # Prompt injection helpers
│   └── shared/              # Shared modules
│       ├── invokers/        # CLI invoker implementations
│       ├── parsers/         # Output parsers
│       ├── gui/             # GUI components
│       └── response_formatter.py  # Response formatting
└── tests/

Development

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

License

MIT

Reviews

No reviews yet

Sign in to write a review