---
title: "Codex MCP server and hooks: connect OpenAI Codex CLI to Cork · Cork"
description: "Connect OpenAI Codex to Cork with one machine install or the remote MCP server at mcp.corkcli.com (codex mcp add, codex mcp login): what Codex agents get, how to check it works, and how to remove it."
canonical: "https://corkcli.com/docs/codex"
last_updated: "2026-10-17"
---

# Cork for Codex

Cork keeps Codex agents, and the Claude Code and Cursor agents beside them, from overwriting each other on one repository, and hands each agent what the others already learned. Codex gets it through hooks and through Cork's MCP server.

## Install for every repo on the machine

```
curl -fsSL https://corkcli.com/install.sh | sh
```

Or, with Node, in any terminal including Windows PowerShell: `npx corkcli`. Either is safe to run again.

The install sets Codex up when `~/.codex` exists or `codex` is on your PATH:

- the hooks go into `~/.codex/hooks.json`;
- Cork's MCP tools go into `~/.codex/config.toml` as `[mcp_servers.cork]`, running `cork mcp`. A `cork` server you added yourself with `codex mcp add` is replaced, since a second `[mcp_servers.cork]` is a duplicate key and Codex would refuse to start.

Then start a new Codex session and approve Cork's hooks in `/hooks`. Codex trusts each hook by its hash, so a changed entry is skipped until you approve it again there.

Nothing is written into your repositories, and with Cork free and local, nothing of yours leaves the machine. Link the machine to an account with `cork login`. See [the cork command](https://corkcli.com/docs/cli.md).

## Or connect the MCP server only

```
codex mcp add cork --url https://mcp.corkcli.com
codex mcp login cork
```

`codex mcp login cork` runs the browser sign-in once (OAuth 2.1 with PKCE; no API key). The first Cork call also installs the machine hooks; if your agent skips that, tell it `set up cork`.

## What the agent gets

- **A briefing** at session start and with each prompt: exact signatures, callers and recent changes of the code the prompt is about.
- **A write gate** on file edits and shell commands: a write that lands on a teammate's live change is held, with who and what.
- **Teammates' changes** on its next step, as lines starting with `Δ`.
- **Messages** from the other agents in the repo, and `cork message` to send one.
- **MCP tools**: see the [MCP tools reference](https://corkcli.com/docs/mcp-tools.md).

### The hook events

Codex runs **SessionStart**, **UserPromptSubmit**, **PreToolUse** (the gate, on `apply_patch`, `Edit`, `Write`, `MultiEdit`, `shell` and `Bash`), **PostToolUse** and **Stop**. It has no batch or config event. A blocked write is refused with an exit code and stderr. Every hook fails open.

## Check that it works

- Start a new Codex session and approve the hooks in `/hooks`.
- A **Cork briefing** arrives in the session's context at start.
- Run `cork status` to see whether Cork is running and what it did.

## Remove it

```
cork uninstall
```

This takes Cork's hooks out of `~/.codex/hooks.json` and its server out of `~/.codex/config.toml`. Your local data stays in `~/.cork`. Restart open sessions: they keep the hooks they started with.

## More

- [Claude Code](https://corkcli.com/docs/claude-code.md) · [Cursor](https://corkcli.com/docs/cursor.md) · [Gemini CLI](https://corkcli.com/docs/gemini-cli.md)
- [The cork command](https://corkcli.com/docs/cli.md) · [MCP tools reference](https://corkcli.com/docs/mcp-tools.md)
- [Documentation](https://corkcli.com/docs) · [Support](https://corkcli.com/support)
