# Connecting OpenAI Codex to Treasure AI

[OpenAI Codex](https://learn.chatgpt.com/docs/codex/cli) is OpenAI's CLI coding agent. Connect it to Treasure AI's MCP Server (Platform) to query databases, build segments, and debug workflows from natural-language prompts in your terminal. This page covers installing the tdx CLI, registering it as an MCP server in Codex, and adding TD Skills for CDP-specific guidance.

Documentation Search
Codex connects to MCP Server (Platform) for platform operations. MCP Server (Docs) (documentation search over HTTP) is not currently documented for Codex — the setup below covers platform access only.

## Prerequisites

- [OpenAI Codex CLI](https://learn.chatgpt.com/docs/codex/cli) installed and authenticated
- Node.js and npm
- A Treasure AI account with API access


## Install and Authenticate tdx

```bash
npm install -g @treasuredata/tdx
tdx auth setup
```

## Add the MCP Server to Codex

```bash
codex mcp add tdx -- tdx mcp
```

To share the connection with your team, commit the server configuration to your repository instead of running the command per machine:

```toml
# .codex/config.toml — commit to your repo
[mcp_servers.tdx]
command = "tdx"
args = ["mcp"]
```

Each teammate still runs `tdx auth setup` individually to authenticate.

## Install TD Skills

TD Skills give Codex CDP-specific guidance for SQL, workflows, and segment/journey syntax.

```bash
codex plugin marketplace add treasure-data/td-skills
codex plugin add tdx-skills@td-skills
codex plugin add sql-skills@td-skills
codex plugin add workflow-skills@td-skills
```

Start a new Codex session before using the installed skills. See [TD Skills](/treasure-code/guide/td-skills) for the full skill catalog and additional plugins.

## Try It

Ask Codex a question that requires querying your data:

```
> Which of our databases has last week's web events?
```

## Next Steps

- [MCP Server (Platform)](/getting-started/ai/mcp-server-platform) — reference for `tdx_run` and `tdx_search`
- [tdx mcp command reference](/treasure-code/commands/mcp) — full tool reference, blocked commands, and troubleshooting
- [TD Skills](/treasure-code/guide/td-skills)
- Connect a different tool: [Claude Code](/getting-started/ai/claude-code) · [VS Code and GitHub Copilot](/getting-started/ai/vscode-github-copilot) · [Cursor](/getting-started/ai/cursor)
- [Why teams pair OpenAI Codex with Treasure AI](https://www.treasure.ai/works-with/openai-codex)