codex-mcp-server
Allows executing autonomous coding tasks and managing conversation threads via Codex CLI, powered by OpenAI's models.
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., "@codex-mcp-serverstart a new coding task to build a REST API"
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.
Codex Model Context Protocol (MCP) Server
A clean, scalable, and open-source Model Context Protocol (MCP) server that provides programmatic access to Codex agent threads, tasks, and history.
This server acts as a bridge between MCP clients (such as Claude Desktop, Cursor, or Windsurf) and your local Codex CLI installation, exposing tools to execute autonomous coding tasks, manage conversation threads, fork sessions, and inspect historical rolls directly from the local SQLite state.
Architecture
MCP Client (Claude / Cursor)
│
▼ MCP Protocol (stdio JSON-RPC)
[Codex MCP Server]
│
▼ @openai/codex-sdk
[Codex CLI] (Running locally)
│
▼ OpenAI API
[GPT-5.x / o3 / o1]Related MCP server: claudecode-mcp
Prerequisites
Before setting up the MCP server, ensure you have the following installed on your local machine:
Node.js: Version
18.xor higher (we recommend22+to leverage native SQLite bindings).Codex CLI: Install and authenticate the Codex CLI on your machine.
codex doctorMake sure
codex doctorreports a healthy installation and active authentication status.
Installation
Clone the Repository:
git clone https://github.com/4dhxm/codex-mcp-server.git cd codex-mcp-serverInstall Dependencies:
npm installBuild the Server:
npm run build
Configuration
To use this server with your favorite MCP client, add it to your client's configuration file.
1. Claude Desktop
Add the server configuration to your claude_desktop_config.json file.
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"codex-mcp-server": {
"command": "node",
"args": [
"/absolute/path/to/codex-mcp-server/dist/index.js"
]
}
}
}2. Cursor
Go to Settings > Features > MCP.
Click + Add New MCP Server.
Fill in the fields:
Name:
codex-mcp-serverType:
commandCommand:
node /absolute/path/to/codex-mcp-server/dist/index.js
Click Save.
Tools Exposed
This server exposes the following tools to MCP clients:
1. Running Tasks
codex_task/codex_run: Starts a new thread, executes a complete coding task from a prompt, and returns the final response.Arguments:
prompt(string, required): The coding task or prompt.workingDirectory(string, optional): Working root for the agent.model(string, optional): Model override (e.g.o3,o1).sandboxMode(string, optional):'read-only' | 'workspace-write' | 'danger-full-access'.webSearchEnabled(boolean, optional): Enable web search.
2. Thread Lifecycle
codex_start_thread: Initializes a conversation session but defers executing turns.Arguments:
workingDirectory,model,sandboxMode,webSearchEnabled.
codex_run_turn/codex_continue/codex_continue_thread: Send a follow-up prompt to an existing thread.Arguments:
threadId(string, required): The ID of the thread to continue.prompt(string, required): The prompt for the new turn.model(string, optional).
3. Session Utilities
codex_list_threads: Lists all active and archived conversation threads directly from your localstate_5.sqlitecache.Arguments:
limit(number, optional, default:50): Max threads to return.includeArchived(boolean, optional, default:false): Include archived threads.
codex_get_thread: Returns metadata and the complete, parsed conversation history (user & assistant messages) of a thread.Arguments:
threadId(string, required): The thread ID.
codex_fork_thread: Clones an existing thread's conversation history into a new thread ID, allowing you to branch off from previous sessions.Arguments:
threadId(string, required): The source thread ID to fork.cwd(string, optional): Optional working directory override.
codex_archive_thread: Archives an active thread, moving its rollout files to~/.codex/archived_sessions.Arguments:
threadId(string, required).
codex_unarchive_thread: Unarchives a thread, moving it back to active directories.Arguments:
threadId(string, required).
codex_interrupt/codex_interrupt_turn: Programmatically aborts the running turn of a thread viaAbortSignals.Arguments:
threadId(string, required).
Local Development & Testing
We provide a built-in verification script to test database connectivity, rollout path parsing, and JSONL log parsing locally:
Run the Verification Script:
npm run build && node dist/test-db.jsThis will query your local
~/.codex/state_5.sqlitedatabase, print the 5 most recent threads, and display message histories.Watcher Mode: For auto-compiling typescript files while editing:
npm run watch
License
This project is open-sourced under the Apache 2.0 License.
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
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/4dhxm/codex-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server