codex-mcp-longrun
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-longrunRuncargo testand wait for the final result."
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 MCP Longrun
Codex MCP Longrun is a local STDIO MCP server that runs one bounded, non-interactive command and waits for a terminal result without model-driven status polling.
It is intended for builds, test suites, packaging jobs, and similar trusted foreground commands. The local server performs the wait; Codex makes one tool call and receives one final structured result.
Codex calls longrun.run_and_wait once
|
v
The local MCP server starts the command,
captures bounded output, and waits locally
|
v
Codex receives one terminal resultThe project is currently a Linux/WSL pilot, not a production release.
Why use it
Repeatedly checking a long build with model-visible polling tools consumes context and may require additional model turns even when nothing changed. Codex MCP Longrun removes those intermediate polling turns. It does not make the initial tool call or the final model response token-free.
While a call remains pending, the server can emit a short MCP progress heartbeat. By default, the first heartbeat is sent after five minutes and the next ones every 15 minutes. A heartbeat is a transport notification inside the same tool call, not another tool call or a log poll. It contains only elapsed time, time since the last output, and the number of captured bytes; it never contains command output.
The MCP and Codex documentation does not define a billing or model-token guarantee for progress notifications. The design therefore minimizes their frequency and size while keeping the main saving: no model-driven status loop.
Related MCP server: mcp-stdio
Tools
Tool | Purpose |
| Report the version, state paths, allowed roots, and active guardrails |
| Run one command and wait for success, failure, timeout, inactivity timeout, or cancellation |
| Read a bounded tail for a known job ID |
There is intentionally no asynchronous start plus frequently polled
status workflow.
Requirements
The dependency lock currently installs Python MCP SDK 2.0.0 in an isolated
virtual environment.
Install from scratch
Clone the repository and install the locked runtime:
git clone https://github.com/woffko/codex-mcp-longrun.git
cd codex-mcp-longrun
./scripts/install-runtime.shThe default runtime location is:
~/.local/share/codex-longrun-mcp/.venvRegister the server in Codex and replace /absolute/path/to/project with one
trusted project root:
./scripts/configure-codex.py \
--config "$HOME/.codex/config.toml" \
--command "$HOME/.local/share/codex-longrun-mcp/.venv/bin/codex-mcp-longrun" \
--server-cwd "$HOME/.local/share/codex-longrun-mcp" \
--state-dir "$HOME/.local/state/codex-longrun" \
--allowed-root /absolute/path/to/projectThe configuration script:
refuses to overwrite an existing
mcp_servers.longrunentry;creates a timestamped private backup under
~/.codex/backups;keeps the MCP optional with
required = false;allows only the three documented tools;
configures
run_and_waitandread_log_tailto require approval;disables shell and privilege-elevation executables;
enables a first heartbeat after 300 seconds and repeats it every 900 seconds;
gives Codex a tool timeout slightly longer than the server's 12-hour limit.
Start a new Codex process after configuration. Existing on-screen processes do not hot-load new MCP servers. A saved session can be resumed in a new process:
codex resume -C /absolute/path/to/project SESSION_IDVerify registration:
codex mcp get longrun
codex mcp listUsage
Ask Codex to use longrun.run_and_wait once for a reviewed command. Pass the
command as an argument array, not as a shell string. For example:
Use longrun.run_and_wait once for ["cargo", "test"], with cwd set to this
project. Wait for the final result and do not poll.The tool supports:
a hard timeout;
an optional no-output timeout;
expected success and failure substrings;
a bounded result tail;
graceful termination followed by forced process-group cleanup.
Progress heartbeats
Heartbeat timing is server-wide and can be changed in the
[mcp_servers.longrun.env] section of the Codex configuration:
Environment variable | Default | Meaning |
|
| Delay before the first notification; |
|
| Interval between later notifications |
longrun.health reports the effective values. The server silently disables
heartbeats for the current job if notification delivery fails; the command
continues running and still returns its terminal result. Clients that do not
request progress simply receive no heartbeat.
Job logs and metadata are private local files under:
~/.local/state/codex-longrun/jobsLogs are capped at 128 MiB by the default installer configuration. The result returns only a bounded tail and the local paths.
Security boundary
This server runs commands with the operating-system permissions of the account running Codex. It is not a security sandbox.
LONGRUN_ALLOWED_ROOTS validates the resolved working directory, but a launched
program can still access any files, networks, and processes available to the
same user. Treat the allowed-root check as a routing guard, not an authorization
boundary.
Additional safeguards include:
shell and privilege-elevation executable rejection by default;
no tool parameter for injecting environment variables;
a small allowlist of inherited environment names;
no raw argument array in job metadata, only a redacted display and digest;
private state directories and files;
bounded logs and result tails;
a Linux supervisor that terminates the full command process group on normal completion, timeout, cancellation, or abrupt MCP-parent death;
startup recovery for incomplete metadata left by an interrupted server.
Never pass passwords, tokens, API keys, private keys, cookies, or other secrets in arguments. Do not run commands that print secrets: command output is written to the local job log. Redaction is best-effort metadata hygiene, not a secret detection guarantee.
Do not use the server for interactive programs, REPLs, TUI applications, password prompts, indefinite servers, daemons, detached jobs, untrusted repositories, or unreviewed commands.
Test
Create the development environment and run the integration suite:
uv sync --frozen --no-dev
.venv/bin/python -m unittest -v tests.test_serverThe suite covers the STDIO handshake, protocol-level progress delivery, environment isolation, allowed-root and shell rejection, successful and failed commands, hard and inactivity timeouts, log truncation, cancellation, descendant cleanup, abrupt parent death, and metadata recovery.
Upgrade and rollback
After pulling a reviewed update, reinstall the isolated runtime:
./scripts/install-runtime.shTo disable the server without deleting local state:
codex mcp remove longrunAlternatively, restore the timestamped config.toml.before-longrun-* backup
created under ~/.codex/backups. Start a new Codex process after changing the
configuration.
The runtime and state directories are independent of the project repository. Removing the MCP configuration does not remove either directory automatically.
References
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityAmaintenanceProvides a secure, token-authenticated command execution tool over MCP Streamable HTTP, with a default-deny allowlist and shell metacharacter rejection.13Apache 2.0
- Alicense-qualityCmaintenanceA minimal, zero-dependency MCP server that enables defining and running tools over stdio transport, without extra features like HTTP or resources.211MIT
- FlicenseBqualityAmaintenancemcp-agent-ops is a local stdio MCP server for deterministic agent-development operations that otherwise cause repeated shell and generated Python calls.25
- AlicenseBqualityBmaintenanceA local, evidence-driven MCP runtime and control plane for open-source maintainers that provides workspace-bounded tools including controlled file operations, command execution, validation primitives, durable execution records, and human review workflows via stdio and Streamable HTTP transports.33MIT
Related MCP Connectors
An MCP server that let you interact with Cycloid.io Internal Development Portal and Platform
The MCP server for Azure DevOps, bringing the power of Azure DevOps directly to your agents.
Remote MCP server for RunComfy Serverless API (ComfyUI): deployments and async inference.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/woffko/codex-mcp-longrun'
If you have feedback or need assistance with the MCP directory API, please join our Discord server