Skip to main content
Glama

Codex Baton

Codex Baton gives ChatGPT read-only access to local workspaces you choose. Through OpenAI’s Secure MCP Tunnel, it can read source files, open screenshots, show Git changes and inspect saved Codex sessions.

“Show me the unstaged changes in app. Did the last Codex session record any test results?”

v0.1.0 public preview for one trusted user. Codex Baton is an unofficial community project, independently maintained and unaffiliated with OpenAI.

Local setup · Start at macOS login · Tool reference · Security policy

Install and select workspaces

Start with Git and uv on macOS or Linux and a workspace on a local filesystem. The sync command below uses Python 3.12, downloads it if needed, and creates .venv with the dependencies pinned in uv.lock. The four session-history tools also require the Codex CLI. Installing uv · How uv manages Python

git clone https://github.com/tomasciar/codex-baton.git
cd codex-baton
uv sync --locked --python 3.12
.venv/bin/python -B -m unittest discover -s tests -v

Create the config directory with mkdir -p -m 700 "$HOME/.config/codex-baton". Save the following as ~/.config/codex-baton/workspaces.toml, outside your shared roots. Replace each sample path with the output of pwd -P in that project.

[workspaces]
app = "/absolute/path/to/application"
docs = "/absolute/path/to/documentation"

Choose 1–64 names of up to 64 characters. Start each with an ASCII letter and use letters, digits, underscores or hyphens. Roots must be absolute directories with approved path components. Symlinks, the filesystem root and paths containing .. are rejected. Use the smallest project directories you want to share. Restart the tunnel client after changing roots so Baton reopens them.

To use a local MCP stdio client, configure the following command from the checkout, using absolute paths when the client starts elsewhere. In a terminal the process waits for MCP input.

.venv/bin/python -EsB server.py --config "$HOME/.config/codex-baton/workspaces.toml"

Related MCP server: ChatGPT MCP Bridge

Connect ChatGPT

The tunnel client connects outbound and starts server.py as a local stdio process. Your private ChatGPT plugin sends tool calls through that tunnel. Baton uses pinned workspace directories for file reads, private snapshots for Git queries and the local Codex App Server for history. Secure MCP Tunnel guide

  1. Install OpenAI’s tunnel client. On macOS, use brew install openai/tools/tunnel-client. Follow the upstream installation instructions for Linux. The examples use tunnel-client 0.0.21. Tunnel client installation

  2. Create or select a tunnel and obtain a runtime API key whose principal has Tunnels Read + Use. Keep the key and tunnel profile outside this checkout and every shared root. Tunnel management · Runtime API keys

  3. Create the local profile once. The read command expects the tunnel ID on the next input line. Replace the three absolute paths below with the interpreter in the checkout, the server script and your allowlist. The example uses paths without spaces. Skip this step if you already have a working codex-baton profile.

    read -r CONTROL_PLANE_TUNNEL_ID
    tunnel-client init --sample sample_mcp_stdio_local --profile codex-baton \
      --tunnel-id "$CONTROL_PLANE_TUNNEL_ID" \
      --mcp-command '/absolute/path/to/codex-baton/.venv/bin/python -EsB /absolute/path/to/codex-baton/server.py --config /absolute/path/to/workspaces.toml'
  4. Start the client using one of the options below. In ChatGPT’s app or connector settings, create or select your private plugin and attach the same tunnel. Ask “Use Baton to list my workspaces.” The returned names should match the TOML file. ChatGPT connector settings · Secure MCP Tunnel setup

Start automatically at macOS login

Stop any foreground client for this tunnel with Ctrl-C in its terminal. If a managed runtime owns it, stop that alias with tunnel-client runtimes stop <alias>. Each stdio tunnel supports one active client. Run the setup command from the checkout as your normal login user.

ruby scripts/start-at-login.rb

Setup uses your existing Baton profile and prompts privately for the runtime key if needed. It reports ready after Homebrew starts the service and the tunnel client successfully polls the control plane. Homebrew starts the client at future logins and restarts it after an exit. The Mac must be awake with your user logged in.

Verify the setup. Close the terminal and ask ChatGPT to list your Baton workspaces. Compare the response with your allowlist. At your next login, repeat the call before starting a tunnel command.

Check registration and tunnel health separately.

brew services info openai/tools/tunnel-client
tunnel-client health --url-file "${XDG_CONFIG_HOME:-$HOME/.config}/codex-baton/tunnel-health.url" --require-control-plane-poll
  • The service profile lives at $(brew --prefix)/etc/tunnel-client.yaml. Setup stops if a different profile already exists there. Use absolute paths and keep the health listener on loopback.

  • For the runtime key, setup resolves env:CONTROL_PLANE_API_KEY from your environment or a hidden prompt. It saves the key in a mode-0600 file in your Baton config directory. The service profile holds the file reference. An existing absolute file: reference also works. Supply any other credentials a custom profile needs through references available at login.

  • Restart after editing the service copy with brew services restart openai/tools/tunnel-client. To disable login startup, run brew services stop openai/tools/tunnel-client. The profile and key remain available for reuse.

  • If readiness fails, inspect $(brew --prefix)/var/log/tunnel-client.log locally. Stop the service to free the health port before running tunnel-client doctor --profile-file "$(brew --prefix)/etc/tunnel-client.yaml". Upstream macOS login service

Run in the foreground on macOS or Linux

Supply the runtime key via your secret manager or a local hidden prompt for the default env: reference. If the profile uses a private absolute file: reference, skip the export. Keep the terminal open while using the tunnel.

export CONTROL_PLANE_API_KEY="$(.venv/bin/python -c 'from getpass import getpass; print(getpass("Tunnel runtime API key: "))')"
tunnel-client doctor --profile codex-baton
tunnel-client run --profile codex-baton

MCP tools

Files and Git

Tool

Example arguments

Result

list_workspaces

{}

Configured names, sorted alphabetically

list_directory

{"workspace":"app","path":"src"}

Child names and types. Omit path for the root. Pass next_after back as after for another page.

read_text

{"workspace":"app","path":"src/main.py"}

UTF-8 text

read_image

{"workspace":"app","path":"screenshots/menu.png"}

A native MCP image block containing the original PNG or JPEG bytes

git_status

{"workspace":"app"}

Changes with two-column Git status codes and a truncated flag

git_diff

{"workspace":"app","path":"src/main.py","staged":true}

A unified patch for one tracked path. The default compares the index with the working file. Set staged to compare HEAD with the index.

In status output, " M" identifies an unstaged modification, "M " a staged modification, and "??" an untracked file. Use read_text or read_image for untracked content. An empty patch means the selected comparison has no changes for that path. Git status · Git diff

Codex history

Use the session_id from list_codex_sessions and the turn_id from list_codex_turns. Omit turn_id to page across turns.

Tool

Example arguments

Result

list_codex_sessions

{"workspace":"app","directory":".","limit":8}

Saved sessions for the exact root. Omit directory to include authorized descendants, or pass a relative directory for an exact subdirectory search. Set archived to true for archived sessions.

list_codex_turns

{"workspace":"app","session_id":"<returned id>"}

Recent turn IDs, saved states, timestamps and recorded error categories

read_codex_session

{"workspace":"app","session_id":"<id>","turn_id":"<turn id>"}

Public user and assistant message excerpts

inspect_codex_execution

{"workspace":"app","session_id":"<id>"}

Recorded actions, command summaries, exit codes, durations, failures and recognized test totals. Accepts an optional turn_id.

Saved Codex sessions

The history tools use the JSONL App Server interface verified with Codex CLI 0.172.0. Install Codex as the user running the tunnel. Baton looks in ~/.local/bin, the usual Homebrew bin directories and /usr/bin. Append --codex-bin /absolute/path/to/codex to the server command for another installation. Codex App Server protocol

Baton starts a short-lived codex app-server --stdio for each inspection. After the handshake it can call only thread/list, thread/read, thread/turns/list and thread/items/list. It checks the recorded thread ID and working directory before and after each history read. Session discovery uses the local index. It supports exact-directory searches, authorized descendants and archived sessions. A separate worktree outside those roots needs its own allowlist entry.

History pages are newest first. Supply limit (1–16) and pass next_cursor back as cursor with the same workspace, view and filters. Filtering can produce an empty page with a continuation. Older stores that explicitly reject item pagination can return one full turn through the turns API. Unavailable methods and oversized turns produce tool errors. Codex may write its own runtime state during startup. Baton never opens private session storage.

A saved inProgress value describes the historical record. Live execution, agent control and approval actions are outside this interface. Test totals require a recognizable runner summary. A missing total means no matching evidence on the sampled page. Baton excludes raw reasoning items, tool arguments, command lines, stdout, stderr and raw error payloads.

To verify using your own saved session, supply a project directory where Codex has recorded messages and commands. The opt-in check reports aggregate counts for each supplied root and exits successfully when each sample contains turns, messages and executions.

.venv/bin/python -B -m tests.check_saved_sessions /absolute/path/to/application

Access boundaries and limits

Files are opened relative to pinned directory descriptors with symlink following disabled. Baton returns regular, single-link files. Its shared filename policy hides sensitive names, common credential extensions and backup variants from listings, reads and Git results. Hidden components are excluded except .gitignore, .gitattributes, .editorconfig and .github. Source files, patches, conversation excerpts and original image metadata can still contain secrets. Share only projects and conversations you trust.

Git inspection requires a standalone SHA-1 working tree with a real .git directory at the configured root. Each request builds a private temporary snapshot outside every workspace. Fixed Git commands use a clean environment and literal diff paths. Repository config, hooks, external converters, linked worktrees and external object stores are excluded. Custom filters and concurrent edits can produce different results from your terminal. Large histories can exceed the snapshot budget even for a small patch.

Resource

Limit

Directory listing

100 returned entries per page, 10,000 scanned entries, 3-second scan budget

Text or patch

128 KiB. Oversized content produces a tool error.

Image

2 MiB encoded file size and 16 million pixels. Baton checks the file signature and dimensions before returning the bytes.

Git inspection

10-second budget, 30,000 scanned entries, 128 MiB of copied object, index and working-file data, 8 MiB per tracked working file for status. Git's guarded allocations are capped at 128 MiB each.

Git output

1 MiB per internal command, 200 visible status entries and 128 KiB of status path records

Codex transport

2 simultaneous reads, 15-second request deadline, 4 MiB per frame, 12 MiB and 96 frames per inspection

Codex history

16 source records per page, 2 KiB per text excerpt, up to 4 index pages per subtree search. Continuations are private to this Baton process, valid for up to 10 minutes, with 512 slots.

See the security policy, contribution guide, release notes and MIT license.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      C
      maintenance
      Enables ChatGPT to work directly on local projects by reading files, editing code, running tests and commands, inspecting Git state, and managing durable workflows, with optional delegation to local Codex agents for complex tasks.
      28
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables ChatGPT to read and edit local project files, inspect Git changes, and run approved development scripts through a secure MCP tunnel, with optional Codex Desktop integration.
      8
      Apache 2.0
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables ChatGPT conversations to directly inspect local workspaces and delegate coding tasks to a local Codex agent, with controlled concurrency, reusable sessions, and task/usage tracking.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables an AI to open a workspace, list files, read and write files within a configured workspace directory, and render an embedded workspace UI inside ChatGPT. File access is restricted to that workspace, with hidden folders and symlinks skipped.
      Apache 2.0