# Connect Gryz MCP in Codex

Source: https://www.gryz.ai/docs/guides/setup/codex-mcp-walkthrough/
Updated: 2026-09-09

## Before you start [#before-you-start]

You need a free Gryz account and [OpenAI Codex](https://github.com/openai/codex) (CLI, desktop app, or IDE extension). This guide is **complete on its own**: follow every step below even if you skip the video.

<Note>
  **Video walkthrough:** The embed above demonstrates the same flow. Use it after reading the steps if you prefer to watch first.
</Note>

Watch the full video on YouTube: [How to Connect Codex to an MCP Server (Step-by-Step) | Gryz](https://www.youtube.com/watch?v=0zc_poa4Igw).

## Prerequisites [#prerequisites]

* Gryz account ([sign up](https://www.gryz.ai/login/))
* Codex CLI or the Codex app (MCP config is shared)
* MCP server URL (always use `www`):

```text
https://www.gryz.ai/api/mcp
```

## Step 1: Add the Gryz server [#step-1-add-the-gryz-server]

From a terminal:

```bash
codex mcp add gryz --url https://www.gryz.ai/api/mcp
```

Codex stores MCP servers in `~/.codex/config.toml`. The CLI, desktop app, and IDE extension read the same file.

Equivalent TOML if you prefer to edit the file yourself:

```toml
[mcp_servers.gryz]
url = "https://www.gryz.ai/api/mcp"
```

## Step 2: Sign in with OAuth [#step-2-sign-in-with-oauth]

OAuth avoids storing an API key on disk.

```bash
codex mcp login gryz
```

1. Codex opens a browser window to Gryz
2. Sign in with Google, GitHub, an email code, or password
3. Approve access on the Allow screen
4. Return to the terminal. The login command should complete

<Tip>
  Complete OAuth on the **same desktop** where Codex is running. Opening the sign-in link on your phone breaks the short-lived cookie handoff.
</Tip>

## Step 3: API key alternative [#step-3-api-key-alternative]

If OAuth is unavailable in your environment, generate a key on the [API keys page](https://www.gryz.ai/account/api-keys/). Codex reads the token from an environment variable. It does not write the secret into `config.toml`.

```bash
export GRYZ_API_KEY=gryz_YOUR_KEY_HERE
codex mcp add gryz --url https://www.gryz.ai/api/mcp --bearer-token-env-var GRYZ_API_KEY
```

Replace `gryz_YOUR_KEY_HERE` with your key. Keep `GRYZ_API_KEY` in your shell profile or secret manager, not in git.

Equivalent TOML:

```toml
[mcp_servers.gryz]
url = "https://www.gryz.ai/api/mcp"
bearer_token_env_var = "GRYZ_API_KEY"
```

## Step 4: Confirm the connection [#step-4-confirm-the-connection]

```bash
codex mcp list
codex mcp get gryz --json
```

The list should show `gryz` as **enabled**. The JSON `transport.url` must be `https://www.gryz.ai/api/mcp`.

Then start a **new** Codex session (restart if one was already open) and run `/mcp` to see Gryz tools.

## Step 5: Verify with a prompt [#step-5-verify-with-a-prompt]

Try these prompts in Codex:

* `List my Gryz documents`
* `Publish this markdown to Gryz as a private doc titled "Codex MCP test"`

A successful publish returns a URL in the assistant reply. Open it to confirm the document rendered.

## Example prompts [#example-prompts]

* `Publish this spec to Gryz as a public doc titled "Q3 roadmap"`
* `Get my Gryz document with slug "q3-roadmap"`
* `Delete my Gryz test document with slug "codex-mcp-test"`

## Troubleshooting [#troubleshooting]

| Issue                              | Fix                                                                                                                                          |
| ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| OAuth login fails / wrong resource | Re-add with `codex mcp add gryz --url https://www.gryz.ai/api/mcp --oauth-resource https://www.gryz.ai/api/mcp`, then `codex mcp login gryz` |
| Sign-in link on another device     | Start OAuth on desktop; open the email link on the same machine                                                                              |
| 401 / connection failed            | Confirm `www` and no trailing slash on the MCP URL; apex redirects strip auth headers                                                        |
| Tools not appearing                | Start a new Codex session after `mcp add` / `mcp login`. Run `/mcp` to confirm the server loaded                                             |
| Duplicate `gryz` entry             | `codex mcp remove gryz`, then add again                                                                                                      |

## Reference [#reference]

For Claude, ChatGPT, and Cursor setup, plus the tools table and API details, see the [MCP setup reference](/docs/mcp/setup/).

## Related reading [#related-reading]

* [Shared context for AI agents](/topics/shared-context/)
* [Shared context for AI coding agents, over MCP](/gryzle/shared-context-for-ai-coding-agents/)
