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.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。