local-agent-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@local-agent-mcp use Codex to generate a README for the current project"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
local-agent-mcp
A local MCP Agent Hub: a stdio Model Context Protocol server that lets Claude Code drive your locally installed, already-logged-in Codex CLI and OpenCode CLI as sub-agents.
Claude Code stays the orchestrator. This server exposes four tools — run Codex, run OpenCode, compare both, and a health check — while enforcing a strict directory allowlist, read-only-by-default execution, output/concurrency limits, and secret redaction.
1. Architecture
┌──────────────┐ MCP tool calls ┌────────────────────────┐ spawn (shell:false) ┌───────────────┐
│ │ (stdio JSON-RPC) │ local-agent-mcp │ ────────────────────► │ Codex CLI │
│ Claude Code │ ──────────────────► │ (this MCP server) │ │ (codex exec) │
│ (MCP client) │ ◄────────────────── │ │ ────────────────────► │ OpenCode CLI │
│ │ JSON results │ • Zod validation │ │ (opencode run)│
└──────────────┘ │ • path allowlist │ └───────────────┘
│ • concurrency + locks │
│ • redaction │
│ • JSONL/JSON parsing │
└────────────────────────┘
│ stderr (logs only)
▼
never pollutes stdoutRequest flow for a run:
tool call → Zod parse → length checks → realpath(cwd) + allowlist check
→ write gate (if writing) → acquire concurrency slot (+ write lock)
→ spawn CLI (shell:false, arg array) → capture (capped) → parse events
→ redact → structured JSON result → release slotComponent responsibilities:
Module | Responsibility |
| MCP server bootstrap, stdio transport, tool registration |
| Read & validate environment configuration |
| Path allowlist, realpath/symlink checks, write gating, input limits |
| Global concurrency semaphore + per-directory write lock |
|
|
| Resolve |
| Mask tokens / API keys / auth headers |
| Parse Codex JSONL events |
| Parse OpenCode JSON events |
| The four MCP tool implementations |
Related MCP server: codex-cli-mcp-tool
2. Prerequisites
Requirement | Notes |
Node.js ≥ 18.17 | ES Modules + modern |
Claude Code | The MCP client. Install per Anthropic docs. |
Codex CLI | Installed and logged in ( |
OpenCode CLI | Installed and authenticated ( |
Git | Optional but recommended; reported by |
This server does not log in for you. Codex and OpenCode must already be authenticated with your own credentials on the machine.
3. Install dependencies
npm install4. Check that Codex and OpenCode are logged in
Codex:
codex --version # should print a version
codex login # if not already logged inOpenCode:
opencode --version # should print a version
opencode auth list # inspect configured providers
opencode auth login # if not already authenticatedOnce this server is registered you can also call the agent_health tool from
Claude Code, which reports install status and versions for both CLIs.
5. Environment variables
Variable | Default | Meaning |
| (empty) | Required. Comma-separated absolute directories agents may access. Empty = nothing allowed. |
|
| When |
|
| Max combined stdout+stderr bytes captured per run. Excess is truncated. |
|
| Max simultaneous agent runs. |
|
| When |
See .env.example.
6. Build
npm run build # compiles TypeScript to ./distOther scripts:
npm run dev # run from source with tsx (no build step)
npm start # run the compiled server (node dist/index.js)
npm test # run the vitest suite
npm run typecheck # type-check only, no emit
npm run lint # eslint7. Register with Claude Code (claude mcp add)
After building, register the compiled server. Provide the allowlist and any
other config via --env flags.
macOS / Linux:
claude mcp add local-agent-hub \
--env AGENT_ALLOWED_ROOTS=/Users/me/projects,/home/me/work \
--env AGENT_ALLOW_WRITE=false \
--env AGENT_MAX_CONCURRENCY=3 \
-- node /absolute/path/to/local-agent-mcp/dist/index.jsWindows (PowerShell):
claude mcp add local-agent-hub `
--env AGENT_ALLOWED_ROOTS="C:\Users\me\projects,C:\work" `
--env AGENT_ALLOW_WRITE=false `
--env AGENT_MAX_CONCURRENCY=3 `
-- node "C:\path\to\local-agent-mcp\dist\index.js"Everything after -- is the command Claude Code will spawn. Use an absolute
path to dist/index.js.
Verify:
claude mcp list8. .mcp.json configuration example
To share the server via a project-scoped config, add it to .mcp.json (see
.mcp.json.example):
{
"mcpServers": {
"local-agent-hub": {
"command": "node",
"args": ["./dist/index.js"],
"env": {
"AGENT_ALLOWED_ROOTS": "C:\\Users\\me\\projects,C:\\work",
"AGENT_ALLOW_WRITE": "false",
"AGENT_MAX_OUTPUT_BYTES": "5000000",
"AGENT_MAX_CONCURRENCY": "3",
"AGENT_DEBUG": "false"
}
}
}
}On Windows, JSON requires escaped backslashes (
\\) in paths. On macOS/Linux use ordinary forward-slash paths.
9. Calling the tools from Claude Code
Once registered, just ask Claude Code in natural language; it will select the tool and fill parameters. The tools are:
agent_health— environment/version/config snapshot.codex_run— run Codex non-interactively.opencode_run— run OpenCode non-interactively.agent_compare— run both (read-only) and return both results.
Example prompts:
"Use agent_health to check whether Codex and OpenCode are installed."
"With codex_run, analyze the code in
/Users/me/projects/api(read-only) and summarize the request-handling flow."
"Use agent_compare on
C:\work\serviceto ask both agents how they'd add input validation, then tell me where they agree."
Tool parameters
codex_run
Param | Type | Default | Notes |
| string (req) | — | Instructions for Codex. |
| string (req) | — | Absolute path inside an allowed root. |
|
|
| Maps to Codex |
| string | — | Optional model override ( |
| number (10–3600) | 300 | Kill after timeout (SIGTERM→SIGKILL). |
|
|
|
|
opencode_run
Param | Type | Default | Notes |
| string (req) | — | Instructions for OpenCode. |
| string (req) | — | Absolute path inside an allowed root. |
| string | — |
|
| string | — | Named OpenCode agent. |
| string | — | Continue an existing |
| boolean |
| Maps to |
| number (10–3600) | 300 | |
|
|
|
agent_compare
Param | Type | Default | Notes |
| string (req) | — | Sent to both agents. |
| string (req) | — | Absolute path inside an allowed root. |
| string | — | Codex model override. |
| string | — | OpenCode model override. |
| number (10–3600) | 300 | Per agent. |
| boolean |
| Run both at once or sequentially. |
agent_compare is always read-only and never judges a winner — it returns
both results verbatim for Claude Code to synthesize.
10. Path differences: Windows / macOS / Linux
Absolute paths are required. Relative paths are rejected.
Windows: use drive-letter paths, e.g.
C:\Users\me\projects. In JSON (.mcp.json) escape backslashes:C:\\Users\\me\\projects. Path comparison is case-insensitive on Windows.macOS/Linux: use POSIX paths, e.g.
/Users/me/projectsor/home/me/work. Comparison is case-sensitive.Symlinks are fully resolved with
fs.realpathbefore the allowlist check, on every platform. On macOS note that/tmpand/varare symlinks; the resolved (/private/...) path is what gets checked.Windows executable resolution: npm installs
codex/opencodeas.cmdshims. Node'sspawnwithshell:falsecannot launch.cmdfiles (a security fix, CVE-2024-27980). This server resolves the underlying native.exeornode <entry>.jsand spawns that directly — soshell:falseis always preserved and no shell parsing ever happens.
11. Security notes
stdout is protocol-only. All logs go to stderr; nothing else is ever written to stdout.
Directory allowlist. Every
cwdisrealpath-resolved and must live inside anAGENT_ALLOWED_ROOTSentry (also realpath-resolved). This blocks../traversal and symlink escapes.Read-only by default. Writes require
AGENT_ALLOW_WRITE=true. Even then,agent_comparestays read-only.No
shell, ever. Processes are spawned withshell:falseand arguments as a discrete array — no string concatenation, so command injection via prompt/model/paths is not possible.No arbitrary executables. Only the fixed
codex/opencodebinaries are ever launched; user input never chooses the program.No dangerous bypasses. The server never passes Codex's
--dangerously-bypass-approvals-and-sandboxordanger-full-access, and exposes no arbitrary-shell tool.Concurrency + write lock. A global semaphore caps simultaneous runs; at most one write task may touch a given directory at a time.
Output cap. Combined stdout+stderr is capped (
AGENT_MAX_OUTPUT_BYTES).Timeouts. Runs are killed after
timeout_seconds(SIGTERM, then SIGKILL after a 5s grace period).Input limits.
prompt,cwd,model,agent,session_idhave length caps.Redaction. Bearer tokens, API keys (
sk-…,ghp_…, AWS keys), JWTs, andkey=valuesecrets are masked in logs and error messages.Prompt privacy. Full prompts are not logged unless
AGENT_DEBUG=true.
The server trusts the local, already-authenticated Codex/OpenCode credentials. Anyone able to call this MCP server can run those CLIs within the allowlist, so only expose it to trusted clients (Claude Code on your own machine).
12. Troubleshooting
Symptom | Cause / Fix |
|
|
| Same as above for the run tools. On Windows, ensure the npm global bin dir is on PATH. |
|
|
| You passed a relative path. Use an absolute one. |
| The (realpath-resolved) cwd is not inside any allowed root — including symlink targets. |
| The directory does not exist or is not accessible. |
| You requested |
| Another write task is already running for that directory. Retry after it finishes. |
| The run exceeded |
Result | Output exceeded |
Codex returns a usage-limit error | That's from Codex/your account, surfaced verbatim in |
Nothing happens / client can't connect | Ensure you built ( |
Want to see prompts in logs | Set |
13. Uninstall / remove the MCP server
Remove it from Claude Code:
claude mcp remove local-agent-hubOr delete the mcpServers.local-agent-hub entry from your .mcp.json.
Then optionally delete this project directory. Removing this server does not affect your Codex or OpenCode installations or their logins.
Public demo evidence
public-demo/demo-manifest.json is generated
from one real local, read-only Codex and OpenCode run against the fixed
fixtures/public-demo scenario. The companion
publication-receipt.json binds the
manifest's SHA-256 digest to the complete publication audit.
The two model outputs are shown without ranking and are not benchmark scores. They are review evidence for the same small input-validation fixture.
Privacy boundary
When deployed, the portfolio imports these two reviewed JSON files as a static replay. It cannot call Codex or OpenCode, spawn a CLI, accept a prompt, proxy a request, or access local Agent credentials. Real execution remains on the local machine.
The publication audit rejects write-enabled policy, absolute paths, local usernames, credential-shaped values, auth headers, session/thread identifiers, raw stderr, unreviewed prompts, failed Agent runs, and incomplete verification.
Verification
Run the complete local quality gate:
npm run checkTo verify only the committed replay bundle:
npm run demo:auditdemo:audit validates the schema, privacy boundary, read-only policy, complete
test totals, receipt checks, and manifest hash without requiring either Agent
login. CI runs this offline audit and never invokes demo:record.
License
MIT
Available Tools
4 toolsagent_compareCompare Codex and OpenCodeA
Run Codex and OpenCode against the same prompt in READ-ONLY mode and return both results verbatim. Does not judge which is better; the caller synthesizes the conclusion. One agent failing does not suppress the other.
Inputs: cwd (required), prompt (required), parallel, codex_model, +2 more.
agent_healthAgent Health CheckA
Report the local agent environment: Node version, Git availability, Codex/OpenCode install status and versions, allowed working directories, whether writes are permitted, and current concurrency usage.
Inputs: no named parameters.
codex_runRun Codex CLIA
Run the locally installed, logged-in Codex CLI non-interactively in a sandboxed working directory. Defaults to read-only. Use workspace_write only when writes are enabled server-side. Returns the final agent message plus command/file-change/error summaries.
Inputs: cwd (required), prompt (required), mode, model, +2 more.
opencode_runRun OpenCode CLIA
Run the locally installed, logged-in OpenCode CLI non-interactively in a sandboxed working directory. auto_approve enables side-effecting actions and requires server-side write permission. Supports session continuation and agent/model selection.
Inputs: cwd (required), prompt (required), agent, model, +4 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool has a distinct purpose: agent_health reports environment, codex_run runs Codex, opencode_run runs OpenCode, agent_compares both. No overlap or ambiguity.
All tools use snake_case with descriptive names, but there's a mix: agent_health is noun-based while codex_run, opencode_run, and agent_compare are verb-focused. Still predictable and clear.
4 tools is well-scoped for the domain of running and comparing local AI agents. Each tool earns its place without redundancy or bloat.
Covers health check, execution of both agents, and comparison. Minor gaps like lacking a tool to stop running agents or manage sessions, but core workflows are covered.
Maintenance
Related MCP Connectors
Shared memory MCP server for Claude Code, Codex, Gemini CLI and Cursor. Cited, editable.
Hosted X Ads MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Hosted YouTube MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Augments MCP Server - A comprehensive framework documentation provider for Claude Code
Related MCP Servers
- AlicenseAqualityCmaintenanceA local MCP server that lets Claude delegate scoped work to Codex with structured results and guardrails, supporting planning, code review, build, reverse engineering, and long-running background tasks.11200 PyPIMIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that allows Claude Code to interact with the OpenAI Codex CLI.50 npm20MIT
- AlicenseAqualityCmaintenanceAn MCP server for running Claude Code and the Codex CLI as a pair: Claude drives, and hands self-contained tasks to Codex as background jobs.8MIT
- AlicenseNot gradedqualityCmaintenanceAn MCP server that lets any MCP-capable agent spawn and drive Claude Code sessions — effectively turning Claude Code into an orchestratable sub-agent fleet.105 npmMIT