# Codex

> Add the Stableship MCP server to Codex from your terminal, and sign in through your browser.

Codex connects to the Stableship MCP server and reads `AGENTS.md` from your repository. Once it is connected, ask it to fix what Stableship found; it reads each fix brief, fixes the code and asks Stableship to verify the fix.

> **Note** We have not yet tested Codex with Stableship end to end. It connects over MCP with the steps below, taken from Codex's own docs. If a step does not match what you see, tell us at support@stableship.ai.

## Connect

1. Add Stableship in your terminal:

   ```sh
   codex mcp add stableship --url https://api.stableship.ai/mcp
   ```

2. Codex opens your browser. Approve there.

Approving opens app.stableship.ai: sign in, pick the workspace and approve. No token to copy. You can disconnect it any time in Stableship: **Settings**, then **Connections**, then **Connected apps**.

## Use a token instead

First make a token: in Stableship open **Settings**, then **Connections**, open **API tokens and connected apps**, and choose **Create token** with **Read findings and rules** and **Start checks and verify fixes**. Copy it: it starts with `sst_` and is shown once. Use it where these steps say `sst_your_token`.

Add the export to your shell profile and the table to `~/.codex/config.toml`:

```sh
export STABLESHIP_TOKEN=sst_your_token

[mcp_servers.stableship]
url = "https://api.stableship.ai/mcp"
bearer_token_env_var = "STABLESHIP_TOKEN"
```

Keep the token out of your repository.

## Check it works

Start a new Codex session. Then ask Codex to list your Stableship projects: it calls `list_projects` and names your app.

If it does not connect:

- Run `codex mcp login stableship`, then approve.
- Or [use a token instead](#use-a-token-instead).

## Keep the rules in your repository

Ask Codex to call `get_repo_files` and commit what it returns: `.gate/rules.md`, `.gate/context.md`, and a Stableship section in `AGENTS.md` that tells every session how to use the rules and the tools. Stableship never writes to your repository, so your agent commits these.
