Get Started
Integrating the Pieces MCP with OpenAI Codex CLI brings your workflow context directly into the Codex command-line agent. Codex uses TOML (not JSON) for its configuration.
Prerequisites
There are two prerequisites for integrating Pieces with Codex CLI as an MCP—an active instance of PiecesOS and the fully-enabled Long-Term Memory engine.
Installing PiecesOS & Configuring Permissions
Follow the instructions below for a detailed guide on setting up and configuring PiecesOS to correctly pass captured workflow context to the Pieces MCP server.
Setting Up OpenAI Codex CLI
Codex stores its MCP configuration in ~/.codex/config.toml. The file format is TOML, not JSON.
Config File Location
| Scope | Path |
|---|---|
| User (global) | ~/.codex/config.toml |
| Project | .codex/config.toml at project root (trusted projects only) |
Local Setup (Streamable HTTP — recommended)
Edit ~/.codex/config.toml:
[mcp_servers.pieces]
url = "http://localhost:39300/model_context_protocol/2025-03-26/mcp"
startup_timeout_sec = 10
tool_timeout_sec = 60
Optional: Filter Specific Tools
To only expose specific Pieces tools:
[mcp_servers.pieces]
url = "http://localhost:39300/model_context_protocol/2025-03-26/mcp"
enabled_tools = ["ask_pieces_ltm", "workstream_summaries_full_text_search"]
Using Pieces MCP Server in Codex CLI
Once integrated, you can utilize Pieces LTM directly in Codex.
Updating
Edit ~/.codex/config.toml, update the url, and run a new Codex session.
Troubleshooting
If you're experiencing issues integrating Pieces MCP with Codex CLI:
Verify PiecesOS Status: Ensure PiecesOS is actively running on your system. Verify the URL responds.
Use TOML, Not JSON: Codex uses TOML format. Creating a
.jsonfile will not work.Update Codex: MCP support requires Codex CLI 0.2.0 or later.
Config File Not Found: Create
~/.codex/config.tomlmanually.Timeout Errors: Increase
startup_timeout_secortool_timeout_secif you encounter timeouts.
You're now set to enhance your Codex CLI workflow with powerful context retrieval through Pieces MCP. Happy coding!