$ show GuDaStudio/codexmcp
CodexMCP is a lightweight MCP (Model Context Protocol) server that acts as a bridge between Claude Code and OpenAI's Codex CLI. It exposes a single `codex` tool that allows MCP clients to invoke Codex CLI sessions programmatically over stdio. The server handles session persistence via UUIDs, supports multi-turn conversations, parallel execution, and sandboxed workspace modes. The core implementation consists of a subprocess wrapper that streams JSON lines from Codex's `exec` command, parses agent messages and thread IDs, and returns structured results. It also includes Windows-specific command-line escaping to handle prompt injection safely. The codebase is minimal (two source modules plus a CLI entry point) but demonstrates solid patterns for wrapping external CLI tools in the MCP protocol, with graceful shutdown handling and error reporting. It does not include tests or CI/CD configuration, but the architecture is clean and focused.
The LLM identified 1 files worth highlighting for reuse:
Contains `run_shell_command`, a generator that executes a command via subprocess and streams output line-by-line using a dedicated reader thread and a queue. It detects a JSON 'turn.completed' signal to trigger a graceful shutdown with a configurable delay, then drains any remaining output. This pattern is reusable for any CLI tool that emits JSON-line output with a completion marker, and demonstrates careful handling of process lifecycle, output buffering, and thread synchronization.