AgentKit
ReferenceCLI commands
BetaYou are reading docs for the beta channel (2.4.1-beta.1) — updated automatically on every beta release.Switch to stable →

CLI commands

ak codex-agent-runtime serve

Run the Codex agent MCP server over stdio.

Exposes each discovered kit or user agent as an MCP tool named agent_<slug>. Codex invokes a tool and the runtime spawns codex exec with the agent's system prompt plus user prompt, then returns the result. Cold-start cost: each dispatch spawns a fresh codex exec subprocess (roughly 1-3s per call); a warm/long-lived runtime is a tracked mitigation.

Who it's for: Power devs running the Codex adapter or scripting doctor/CI checks.

When to use it: Codex starts this automatically when registered via ak codex-agent-runtime register. Use --list-only to enumerate discovered agents without starting the MCP transport.

What changes on disk: Read-only. Does not write to disk; starts a long-running MCP stdio server that dispatches to codex exec subprocesses. Use it for scripted doctor/CI checks with --list-only.

Usage

ak codex-agent-runtime serve [flags]

Examples

ak codex-agent-runtime serve                                                      # start MCP server on stdio
ak codex-agent-runtime serve --list-only                                         # print agents and exit without serving
ak codex-agent-runtime serve --list-only --codex-home ~/.codex --plugin-root ~/.claude/plugins # override both dirs

Flags

FlagDescription
--codex-home stringOverride $CODEX_HOME (defaults to ~/.codex)
-h, --helphelp for serve
--jsonEmit machine-readable JSON (implies --no-interactive)
--list-onlyPrint discovered agents and exit without serving MCP
--no-interactiveDisable interactive prompts (CI-safe)
--plugin-root stringOverride $AGENTKIT_PLUGIN_DIR (defaults to ~/.claude/plugins)
-q, --quietSuppress non-error output on stderr
-V, --verboseExtra diagnostic output on stderr (loses to --quiet)
-y, --yesAssume yes for all prompts

Output modes

ModeBehavior
prettydefault on TTY (colors, ASCII markers)
plainauto when stdout piped or --no-interactive
json--json (single-object envelope, NDJSON-safe)

Exit codes

CodeMeaning
0success
1runtime error
2invalid flags
3user-cancel (SIGINT, prompt-cancel)
1MCP transport error or agent discovery failure

On this page