Skip to main content
Glama
AI CLI MCP Server

AI CLI MCP Server

by kiranmaya

AI CLI MCP Server

Python 3.10+ MCP Spec License: MIT Build Status

A production-ready Model Context Protocol (MCP) server that acts as a secure, unified gateway to both OpenAI Codex CLI and Google Antigravity CLI (agy).

It empowers primary AI orchestrators (such as Claude Desktop, Gemini, Cursor, or Windsurf) to delegate complex coding tasks, file refactorings, and deep automated code reviews to autonomous CLI agents running in YOLO mode with robust process lifecycle supervision.


Architecture

                 ┌───────────────────────────────────┐
                 │          Any AI Agent             │
                 │ Claude / Gemini / Cursor / etc.   │
                 └─────────────────┬─────────────────┘
                                   │ MCP Protocol
                                   ▼
                ┌────────────────────────────────────┐
                │        Python MCP Server           │
                │        (ai_cli_mcp_server)         │
                ├────────────────────────────────────┤
                │ • codex_run     • codex_review     │
                │ • antigravity_run • antigravity_rvw│
                │ • cli_status    • get_agent_skills │
                └──────────────┬──────────────┬──────┘
                               │              │
                   ┌───────────┘              └───────────┐
                   ▼                                      ▼
     ┌───────────────────────────┐          ┌───────────────────────────┐
     │      OpenAI Codex CLI     │          │  Google Antigravity CLI   │
     │  (--dangerously-bypass)   │          │  (--dangerously-skip)     │
     └───────────────────────────┘          └───────────────────────────┘

Related MCP server: SubagentBridge

Key Features

  • Unified CLI Gateway: Controls both OpenAI Codex and Google Antigravity agents through clean, standard MCP tools.

  • True Autonomous YOLO Mode:

    • Automatically applies --dangerously-bypass-approvals-and-sandbox for Codex.

    • Automatically applies --dangerously-skip-permissions for Antigravity (agy).

    • Guarantees non-blocking, headless execution without hanging on confirmation dialogs.

  • Safer by Design: Does not expose arbitrary shell execution (cmd.exe/bash). Only structured, sandboxed tasks are dispatched to vetted agent CLIs.

  • Process Supervision & Windows Tree-Killing: When a task times out, child processes (compilers, servers, node) are terminated cleanly via process-tree signals.

  • Built-in Agent Skills: Exposes an embedded, self-contained skills document via tool (get_agent_skills) and MCP resource (skills://usage-guide) so calling agents know how to orchestrate multi-agent workflows.

  • Multi-Client Support: Out-of-the-box configuration for Claude Desktop, Cursor, Antigravity, Gemini, and VS Code.


Available MCP Tools

Tool

Parameters

Description

codex_run

prompt, working_directory, model?, timeout?, yolo?

Runs an autonomous coding task with OpenAI Codex CLI.

antigravity_run

prompt, working_directory, model?, timeout?, yolo?

Runs an autonomous coding task with Google Antigravity CLI.

codex_review

working_directory, instructions?, model?, timeout?, uncommitted?

Runs a non-interactive Git diff code review via Codex.

antigravity_review

working_directory, instructions?, model?, timeout?

Runs an automated codebase critique and review via Antigravity.

cli_status

(none)

Inspects local CLI binary health, versions, paths, and platform info.

get_agent_skills

(none)

Returns the comprehensive orchestration guide for calling agents.


Quickstart

1. Installation

# Clone the repository
git clone https://github.com/kiranmaya/ai-cli-mcp.git
cd ai-cli-mcp

# Install dependencies or install in editable mode
pip install -e .

2. Verify Host Binaries & CLI Status

Run the server status check using the provided runner scripts or directly in Python:

:: Using Batch runner
run_server.bat --status

:: Using PowerShell runner
.\run_server.ps1 -Status

:: Or directly via Python
python -c "import asyncio, server; print(asyncio.run(server.cli_status()))"

3. Running the Server

To launch the MCP Server on stdio transport:

  • Batch: run_server.bat

  • PowerShell: .\run_server.ps1

  • Direct Python: python server.py

4. Client Quick Setup

Claude (Claude Desktop & Claude Code CLI)

  • Claude Desktop: In %APPDATA%\Claude\claude_desktop_config.json:

{
  "mcpServers": {
    "ai-cli-gateway": {
      "command": "python",
      "args": ["c:/Projects2026/AgentsCLI_MCP_Server/ai_cli_mcp_server.py"],
      "env": { "CLI_YOLO_MODE": "true", "CLI_DEFAULT_TIMEOUT": "300" }
    }
  }
}
  • Claude Code CLI: Add "ai-cli-gateway" to ~/.claude.json.

OpenAI Codex CLI

codex mcp add ai-cli-gateway --env CLI_YOLO_MODE=true --env CLI_DEFAULT_TIMEOUT=300 -- python c:/Projects2026/AgentsCLI_MCP_Server/ai_cli_mcp_server.py

Gemini CLI & Google Antigravity

  • Gemini CLI:

gemini mcp add ai-cli-gateway python c:/Projects2026/AgentsCLI_MCP_Server/ai_cli_mcp_server.py
  • Google Antigravity CLI / IDE:

agy mcp add --env CLI_YOLO_MODE=true --env CLI_DEFAULT_TIMEOUT=300 ai-cli-gateway python c:/Projects2026/AgentsCLI_MCP_Server/ai_cli_mcp_server.py

(For detailed configurations including Cursor, Windsurf, and VS Code Cline, see INSTALLATION_AND_CLIENTS.md.)


Multi-Agent Workflow Example

A calling agent (e.g. Claude) can execute an end-to-end task and peer review:

# 1. Dispatch feature implementation to Codex
codex_run(
    prompt="Implement JWT refresh token rotation with SQLite in src/auth.py",
    working_directory="C:/MyProject"
)

# 2. Dispatch cross-verification review to Antigravity
antigravity_review(
    working_directory="C:/MyProject",
    instructions="Audit security edge cases for token invalidation in src/auth.py"
)

Project Structure

ai-cli-mcp/
├── ai_cli_mcp_server.py     # Main CLI entrypoint
├── server.py                # MCP Server & Tool definitions
├── config.py                # Path discovery & sandbox validation
├── process.py               # Async process execution & tree killing
├── cli/
│   ├── codex.py             # OpenAI Codex CLI adapter
│   └── antigravity.py       # Google Antigravity CLI adapter
├── models/
│   └── requests.py          # Pydantic schemas & response models
├── skills/
│   └── document.md          # In-depth agent usage & skills documentation
├── pyproject.toml           # Packaging & build configuration
├── requirements.txt         # Core dependencies
├── INSTALLATION_AND_CLIENTS.md # Client configuration reference
└── README.md

Environment Configuration

Variable

Default

Purpose

CLI_YOLO_MODE

true

Runs commands with permission-bypass flags.

CLI_DEFAULT_TIMEOUT

300

Default timeout in seconds (5 min).

CLI_MAX_TIMEOUT

1800

Maximum timeout ceiling (30 min).

ALLOWED_WORKING_DIRECTORIES

*

Sandbox directory whitelist (comma-separated).

CODEX_CLI_PATH

Auto

Override path to codex.exe.

AGY_CLI_PATH

Auto

Override path to agy.exe.


License

MIT License. See LICENSE for details.

Available Tools

6 tools
antigravity_reviewB

Performs an automated code review on a workspace using Google Antigravity CLI.

Args: working_directory: Root directory of the workspace or repository to review. instructions: Optional custom review criteria, guidelines, or focus areas. model: Optional model override. timeout: Execution timeout in seconds (default: 300).

Returns: JSON string containing review critique, exit code, and execution summary.

Inputs: working_directory (required), model, timeout, instructions. Returns: result

antigravity_runA

Executes a coding prompt non-interactively using Google Antigravity CLI (agy).

Args: prompt: Detailed instruction or task description for the Antigravity agent. working_directory: Target project root directory where the task executes. model: Optional model override (e.g. gemini-2.5-pro, gemini-2.5-flash). timeout: Execution timeout in seconds (default: 300, max: 1800). yolo: When true, runs in YOLO mode (--dangerously-skip-permissions) for automated non-blocking execution.

Returns: JSON string containing success status, exit code, execution time, stdout, and stderr.

Inputs: prompt (required), working_directory (required), yolo, model, +1 more. Returns: result

cli_statusA

Checks the operational status of Codex CLI and Antigravity CLI binaries on the host.

Inputs: no named parameters. Returns: result

codex_reviewA

Performs an automated code review on a git repository using OpenAI Codex CLI.

Args: working_directory: Root directory of the Git repository to review. instructions: Optional review focus areas or guidelines (e.g. security, memory leaks). model: Optional model override. timeout: Execution timeout in seconds (default: 300). uncommitted: When true, reviews uncommitted staged and unstaged changes.

Returns: JSON string containing code review output, exit code, and execution summary.

Inputs: working_directory (required), model, timeout, uncommitted, +1 more. Returns: result

codex_runA

Executes a coding prompt non-interactively using the OpenAI Codex CLI.

Args: prompt: Detailed instruction or task description for the Codex agent. working_directory: Target project root directory where the task executes. model: Optional model override (e.g. o3-mini, o1, gpt-4o). timeout: Execution timeout in seconds (default: 300, max: 1800). yolo: When true, runs in YOLO mode (--dangerously-bypass-approvals-and-sandbox) for automated non-blocking execution.

Returns: JSON string containing success status, exit code, execution time, stdout, and stderr.

Inputs: prompt (required), working_directory (required), yolo, model, +1 more. Returns: result

get_agent_skillsA

Returns the comprehensive AI Agent Skills & Usage Guide for delegating tasks to Codex and Antigravity.

Calling agents should read this guide to understand:

  • Tool invocation parameters and return formats

  • YOLO autonomous mode execution mechanics

  • Decision matrix for choosing Codex vs. Antigravity

  • Multi-agent collaboration pipelines and prompt patterns

Inputs: no named parameters. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 6 tools

    Disambiguation4/5

    The two run tools and two review tools are intentionally parallel but clearly distinguished by vendor (Codex vs. Antigravity), and cli_status/get_agent_skills are wholly distinct. The main confusion risk is between codex_run and antigravity_run, but descriptions make the target CLI explicit.

    Naming Consistency4/5

    The core tools follow a consistent vendor_action pattern (codex_run, antigravity_run, codex_review, antigravity_review). cli_status and get_agent_skills break the pattern slightly, but they are also different kinds of operations and the names remain readable and predictable.

    Tool Count5/5

    Six tools is a well-scoped set for a server that wraps two external CLI agents. Each tool covers a distinct operational need: execute, review, status check, and usage guidance.

    Completeness4/5

    The server covers the primary workflows one would expect: running and reviewing with both Codex and Antigravity, plus environment status and skill guidance. Minor gaps like model listing or installation tooling exist, but agents can work around them.

    Maintenance

    ActivityStale
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers