AnyRouter Spawn Agent
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., "@AnyRouter Spawn AgentStart an explorer agent to inspect the current configuration"
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.
AnyRouter Spawn Agent
Observable spawn_agent MCP fallback for Codex sessions that use anyrouter.top or other API providers where Codex App native Sub Agents are unavailable.
What This Is
Codex has two different subagent paths:
Codex App native Sub Agent: preferred when the current Codex runtime exposes native Sub Agent tools and App sidebar integration.
This MCP fallback: a local MCP server that launches registered agents through detached
codex execchild processes, then exposes job status through MCP tools.
Use native Sub Agents first. Use this repository when native Sub Agents are hidden or unavailable, for example when a session is routed through https://anyrouter.top/v1 and the App native Sub Agent tool is not exposed to the model.
This fallback is intentionally honest about its limits:
It does not create App sidebar-visible native Sub Agents.
It does not fake native Sub Agent success.
It starts real local
codex execchild processes.It can observe queued/running/completed/failed/timed_out/cancelled fallback jobs through MCP.
Related MCP server: codex-master-mcp
Tools
The MCP server exposes:
Tool | Use |
| Legacy synchronous one-shot fallback. Best for short fixed-response checks. |
| Start an observable fallback job and return |
| Check status, pid, thread id, last activity, output tails, and |
| Fetch final answer and metadata when ready. |
| List recent jobs in the current MCP server process. |
| Cancel queued/running jobs. On Windows it tries |
| Record a redacted diagnostic note/bug for later MCP improvement. |
| List recent diagnostic issues from the persistent journal. |
| Build a Markdown report from recent diagnostic issues. |
possibly_stalled becomes true after five minutes without stdout/stderr activity. It is a warning, not automatic failure.
Diagnostic Journal
The MCP fallback now has a small persistent diagnostic journal for problems discovered while using fallback jobs.
Default location:
$CODEX_HOME/spawn-agent-logs/issues.jsonl
$CODEX_HOME/spawn-agent-logs/events.jsonlSet SPAWN_AGENT_LOG_DIR to place the journal somewhere else.
The journal is intentionally redacted by default. It stores metadata and short previews such as run_id, agent_type, status, tool, error, timeout_ms, idle_ms, and message_preview. It does not copy full parent prompts, final answers, stdout tails, or stderr tails unless a caller explicitly writes a short note.
Launch accounting is also written to events.jsonl. Every fallback subagent launch records a fallback_launch_recorded event:
Observable
spawn_agent_startlaunches record their realrun_id.Legacy synchronous
spawn_agentlaunches recordrun_id: "legacy/no_run_id"and keep the old response shape.The counter is derived from the persistent event journal, so it can survive MCP server restarts as long as the log files remain.
Every 20 fallback launches, spawn_agent_start returns journal_review_due: true plus journal_review_recommended_tool: "spawn_agent_issue_report" in structuredContent, and the response text includes journal review due. The main Agent should then inspect the issue journal and tell the human what recurring MCP issues were found and what changes are recommended.
Tool Exposure Diagnostics
There are two different checks:
Direct MCP
tools/list: proves the local MCP server schema exposes tools.Active model tool surface: proves the current Codex session can actually call those tools.
The first can pass while the second fails. Codex may defer MCP tools behind tool search, a session may not have reloaded config, or the active provider/app surface may filter tools. For observable fallback work, the main Agent must see spawn_agent_start, spawn_agent_status, and spawn_agent_result, or prefixed names such as mcp__spawn_agent__spawn_agent_start.
If those tools are missing from the active model surface, do not silently downgrade long or parallel work to unobservable shell-launched codex exec. Run the diagnostic writer from the target project root:
node "$env:USERPROFILE\.codex\skills\spawn-agent\scripts\diagnose_tool_exposure.js" --visible-tools <comma-separated-visible-tools> --write-issue --write-reportThis records a redacted issue and writes development/tool-exposure-diagnostic-report.md for later MCP development.
After reporting to the human, the main Agent should persist the same redacted findings into this repository's development directory. Use the report writer script:
node "$env:USERPROFILE\.codex\skills\spawn-agent\scripts\write_development_report.js" --limit 20 --output spawn-agent-diagnostic-report.mdThe default output is:
development/spawn-agent-diagnostic-report.mdThe script can also write main-agent-authored Markdown from stdin:
@'
# Spawn Agent Development Report
## Findings
- ...
## Recommended Changes
- ...
'@ | node "$env:USERPROFILE\.codex\skills\spawn-agent\scripts\write_development_report.js" --stdin-only --output journal-review.mdFor safety, output paths must stay inside development/ and must end in .md. The script redacts common bearer tokens, sk-... keys, GitHub PATs, and token/api_key/password assignments before writing.
Issues are recorded automatically for:
failed,timed_out, andcancelledjobs.First observation of
possibly_stalledfor a run.Missing
run_idlookups.Tool argument errors and unknown tool calls.
Use spawn_agent_issue_record manually when a fallback job behaved strangely but did not fail mechanically, for example partial research, unclear timeout behavior, missing capability, bad agent instructions, or a recurring workflow problem.
Example manual issue:
{
"event": "manual_note",
"severity": "warning",
"title": "docs_researcher returned partial source list",
"run_id": "run_000004",
"agent_type": "docs_researcher",
"status": "timed_out",
"notes": "Retry with a narrower source request or longer timeout."
}Repository Layout
agent-mcp/
spawn_agent_server.js
spawn_agent_server.test.js
agents/
explorer.toml
reviewer.toml
docs-researcher.toml
conversation-analyzer.toml
agent-evaluator.toml
spec-miner.toml
skills/
spawn-agent/
spawn-agent-observer/
examples/
config.spawn-agent.toml
AGENTS.spawn-agent.mdInstall
Clone the repo:
git clone git@github.com:wendou-chen/anyrouter-spawn-agent.git
cd anyrouter-spawn-agentCopy the files into your Codex home:
$codexHome = "$env:USERPROFILE\.codex"
New-Item -ItemType Directory -Force -Path "$codexHome\agent-mcp", "$codexHome\agents", "$codexHome\skills" | Out-Null
Copy-Item -Recurse -Force .\agent-mcp\* "$codexHome\agent-mcp\"
Copy-Item -Recurse -Force .\agents\* "$codexHome\agents\"
Copy-Item -Recurse -Force .\skills\spawn-agent "$codexHome\skills\spawn-agent"
Copy-Item -Recurse -Force .\skills\spawn-agent-observer "$codexHome\skills\spawn-agent-observer"Add the snippets from examples/config.spawn-agent.toml to C:\Users\<you>\.codex\config.toml, adjusting absolute paths if needed.
Add the rules from examples/AGENTS.spawn-agent.md to your global C:\Users\<you>\.codex\AGENTS.md or to a project-local AGENTS.md.
Restart Codex App or reload the session so MCP tools and skills are rediscovered.
Agent Selection Rule
Use this decision flow:
Try Codex App native Sub Agent tools when they are visible and supported.
If native Sub Agents are unavailable, hidden by provider/API mode, or cannot be verified, use the MCP fallback tools from this repository.
For long-running, exploratory, research, review, or parallel work, use
spawn_agent_startand keep the returnedrun_id.Use
spawn_agent_statuswhile the job runs andspawn_agent_resultwhen it completes.Use legacy
spawn_agentonly for short one-shot requests where progress does not matter.If the fallback mechanism misbehaves or produces a partial/failed result worth improving, call
spawn_agent_issue_recordor include the automatic issue in aspawn_agent_issue_report.When a launch response says
journal_review_due: true, callspawn_agent_issue_reportand report the issue summary plus recommended fixes to the human.Persist the same review findings with
node "$env:USERPROFILE\.codex\skills\spawn-agent\scripts\write_development_report.js" --stdin-only --output <name>.mdfrom the target project root so future MCP development inside that repository can read the Markdown report. In this repository,npm run report:issuesis a no-argument shortcut.If observable MCP tools are absent from the active model tool surface, run
diagnose_tool_exposure.js, report the diagnosis, and stop unless the human explicitly accepts unobservable fallback.
Example
Start an observable explorer job:
{
"agent_type": "explorer",
"message": "Inspect the current configuration. Do not edit files.",
"timeout_ms": 900000
}Then poll:
{ "run_id": "run_000001" }Report status from observed state, for example:
explorer run_000001: running, pid 1234, thread_id pending, last activity 42s ago, not stalled.
docs_researcher run_000002: completed, thread_id 019..., result ready.Verify
Run the unit tests:
npm testCheck the server schema directly:
$messages = @(
'{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05"}}',
'{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}'
)
$messages | node .\agent-mcp\spawn_agent_server.jsExpected tools:
spawn_agent
spawn_agent_start
spawn_agent_status
spawn_agent_result
spawn_agent_list
spawn_agent_cancel
spawn_agent_issue_record
spawn_agent_issue_list
spawn_agent_issue_reportNotes
Job state is in-memory only. If the MCP server restarts, historical
run_idstate is lost.Child timeouts default to 15 minutes and are capped at 30 minutes.
Registered agents live in
[agents.*]entries inconfig.toml; eachconfig_filemust stay insideCODEX_HOME.On API-key
codex execsessions, external MCP tools may not be available to the child. Put all required context inmessage.
This server cannot be installed
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
- 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/wendou-chen/anyrouter-spawn-agent'
If you have feedback or need assistance with the MCP directory API, please join our Discord server