Imported from x51xxx/codex-mcp-tool (
AGENTS.md). Install upstream withnpx skills add x51xxx/codex-mcp-tool. Copyright stays with the author.
Repository Guidelines
Project Structure
src/index.ts— MCP server entry (stdio transport, tool dispatch, 25s keepalive)src/constants.ts— CLI flags, models, sandbox modes,ToolArgumentsinterfacesrc/tools/— MCP tools (*.tool.ts), registered viatoolRegistry.push()inindex.tssrc/utils/— CLI execution, version detection, session storage, output parsingdist/— compiled output (tsc)docs/— VitePress documentation site
Build & Development
| Command | Description |
|---|---|
npm run build |
Compile TypeScript to dist/ |
npm run lint |
Type-check (tsc --noEmit) |
npm run dev |
Build + run once |
npm start |
Run compiled server |
npm run docs:dev |
VitePress dev server |
Requirements: Node >=18, codex CLI installed and authenticated.
Coding Style
- TypeScript ESM — use
.jsextensions in imports - 2-space indent, single quotes, kebab-case filenames
- Tools:
*.tool.ts— exportUnifiedToolwith zod schema - Use
cross-spawn(not nativespawn) for Windows compatibility
Architecture Notes
Request Flow
- MCP client →
index.tsdispatches to tool - Tool validates args (zod) → passes to executor
CodexCommandBuilder.build()constructs CLI argsexecuteCodex()spawnscodex exec ...viacross-spawn- Output parsed → formatted → returned as MCP response
CodexCommandBuilder Gotchas
--oss/--local-providermust come afterexecsubcommandexec resumedoesn't support--oss; use-c model_provider=<provider>instead- OSS mode: model name passed as-is (skip OpenAI model validation)
search,oss,localProviderauto-set--sandbox workspace-write
Tools (13 registered)
ask-codex, batch-codex, review-changes, do-act, brainstorm, fetch-chunk, list-sessions, list-skills, health, ping, help, version, timeout-test
Adding a New Tool
- Create
src/tools/your-tool.tool.ts - Define zod schema, export
UnifiedToolobject - Register in
src/tools/index.ts:toolRegistry.push(yourTool)
Commit Style
Concise, imperative: feat: add brainstorm tool, fix(utils): handle quota errors
Keep changes scoped; update README.md and docs/ when behavior changes.
Testing
No automated tests yet (npm test is a stub). If adding tests, place alongside sources and cover src/utils/ parsing/execution utilities.
