# Codex

Set up the OpenAI Codex CLI for SurrealDB with the hosted MCP server and the official Agent Skills.

[Codex](https://developers.openai.com/codex/) is OpenAI's coding agent, available as a terminal CLI and a desktop app. Connecting the SurrealDB MCP server lets it work against your Cloud instances while it edits code.

## Add the MCP server

```bash
codex mcp add surrealdb --url https://mcp.surrealdb.com
```

Codex also reads MCP servers from `~/.codex/config.toml`, or `.codex/config.toml` in a trusted project:

```toml
[mcp_servers.surrealdb]
url = "https://mcp.surrealdb.com"
```

## Sign in

Start a Codex session and approve the SurrealDB connection when it prompts you. For an unattended run, create a [personal access token](/docs/build/ai-agents/mcp.md#signing-in) and point Codex at it through an environment variable rather than writing the value into the file:

```toml
[mcp_servers.surrealdb]
url = "https://mcp.surrealdb.com"
bearer_token_env_var = "SURREALDB_TOKEN"
```

## Install the Agent Skills

```bash
npx skills add surrealdb/agent-skills
```

## Check it worked

```bash
codex mcp list
```

**surrealdb** should appear in the list. Ask Codex what SurrealDB tools it has available.

## Try it

> Create a `task` table in my dev instance with a title and a done flag, insert two rows, then show me the ones that are not done.

## Next steps

- [SurrealDB MCP Server](/docs/build/ai-agents/mcp.md) — every tool the server publishes
- [Agent Skills](/docs/build/ai-agents/agent-skills.md) — what each skill covers
