local-agent-mcp
Click on "Install 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-mcpuse 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: AgentSpawnMCP
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
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/3230390742/local-agent-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server