external-agent-mcp
Bridges Codex to external CLI coding agents for read-only code analysis and deterministic quality fixes.
README
external-agent-mcp
Local stdio MCP bridge that lets Codex call installed external CLI coding agents for bounded read-only code analysis and deterministic quality fixes.
This first version supports:
- Cursor Agent via
/usr/local/bin/cursor agent --print --mode=plan - Gemini CLI via
/opt/homebrew/bin/gemini --prompt ... --approval-mode plan - Claude Code via
/opt/homebrew/bin/claude --print --permission-mode plan
The server is dependency-free Node.js and speaks MCP over line-delimited JSON-RPC on stdio.
Tools
analyze_code
Runs one external provider against a repository path and returns a structured JSON payload containing command metadata, exit status, bounded stdout, and bounded stderr.
Required arguments:
provider:cursor,gemini, orclauderepo_path: absolute path to the repository/workspacetask: concrete read-only code analysis task
Optional arguments:
files: focus files; repo-relative or absolute paths underrepo_pathextra_context: additional instructionsmodel: provider-specific model overridetimeout_sec: defaults to600, capped at1800max_output_chars: defaults to30000, capped at100000include_stderr: defaults totrue
agent_status
Checks configured provider binaries with version commands. It does not run an analysis prompt.
quality_fix
Runs allow-listed deterministic quality commands over a bounded file set. This is intended for mechanical fixes that should not spend LLM tokens.
Default commands:
ruff_format:ruff format <files>ruff_safe_fix:ruff check --fix <files>
Additional commands:
ruff_check:ruff check <files>ruff_unsafe_fix:ruff check --fix --unsafe-fixes <files>; requiresallow_unsafe_fixes: true
Required arguments:
repo_path: absolute path to the git repository/workspace
Optional arguments:
files: repo-relative or absolute files to fix; required unlessallow_repo_wideis truecommands: defaults to["ruff_format", "ruff_safe_fix"]allow_repo_wide: allows target.; defaults tofalseallow_unsafe_fixes: required forruff_unsafe_fix; defaults tofalsetimeout_sec: per-command timeout; defaults to120, capped at900max_output_chars: per-command output cap; defaults to30000max_changed_files: maximum newly dirty files; defaults to20include_diff_stat: defaults totrue
The result includes command outputs, before/after git status paths, newly dirty files, out-of-scope newly dirty files, safety errors, and optional diff stat.
Codex config
Add this to ~/.codex/config.toml or a trusted project .codex/config.toml:
[mcp_servers.external_agent]
command = "node"
args = ["/Users/luchong/OpenSourceProject/external-agent-mcp/src/server.mjs"]
startup_timeout_sec = 10
tool_timeout_sec = 900
[mcp_servers.external_agent.env]
EXTERNAL_AGENT_ALLOWED_ROOTS = "/Users/luchong/Desktop:/Users/luchong/OpenSourceProject"
Optional binary overrides:
[mcp_servers.external_agent.env]
CURSOR_AGENT_BIN = "/usr/local/bin/cursor"
GEMINI_BIN = "/opt/homebrew/bin/gemini"
CLAUDE_BIN = "/opt/homebrew/bin/claude"
RUFF_BIN = "ruff"
EXTERNAL_AGENT_ALLOWED_ROOTS = "/Users/luchong/Desktop:/Users/luchong/OpenSourceProject"
After changing MCP config, refresh/restart Codex or start a new thread so the new tool surface is loaded.
Manual test
npm test
Example tool arguments
External analysis
{
"provider": "gemini",
"repo_path": "/Users/luchong/Desktop/Agnes_Core",
"task": "Analyze the stream cancellation implementation. Focus on correctness, structured error propagation, and missing tests.",
"files": [
"kw-agent-service/path/to/file.py"
],
"timeout_sec": 900,
"max_output_chars": 40000
}
Deterministic Ruff fix
{
"repo_path": "/Users/luchong/Desktop/Agnes_Core",
"files": [
"kw-agent-service/path/to/file.py"
],
"commands": [
"ruff_format",
"ruff_safe_fix"
],
"timeout_sec": 120,
"max_changed_files": 10
}
Safety notes
- The bridge uses
child_process.spawnwith argv arrays, not shell command strings. - Read-only provider modes are hardcoded for normal analysis calls.
quality_fixrequires a git repository so it can report before/after changed files and flag unexpected newly dirty files.quality_fixrequires explicit files by default; repo-wide.runs requireallow_repo_wide: true.EXTERNAL_AGENT_ALLOWED_ROOTSis strongly recommended. If it is unset, the bridge allows any existing absolute directory passed by the MCP caller.- The bridge does not pass
--yolo,--force, or equivalent write-friendly flags.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.