# Codex

Connect Dstl8 to OpenAI Codex (CLI, VS Code extension, or Desktop app) for observability access while coding.

### Prerequisites

* Codex CLI, VS Code extension, or Desktop app installed
* Node.js 18+
* Your [MCP endpoint and API token](/controltheory-documentation/dstl8-docs/mcp-integration.md)

### Setup (CLI)

The quickest way is via the CLI:

```bash
codex mcp add Dstl8 --env DSTL8_TOKEN=<your-token> -- npx -y mcp-remote https://<org_id>.app.dstl8.ai/mcp --header "Authorization: Bearer <your-token>"
```

Replace `<org-id>` and `<your-token>` with your credentials from **Settings → Integrations → MCP**.

### Setup (config file)

Codex stores MCP config in `~/.codex/config.toml`. For project-scoped config, use `.codex/config.toml` in your project root.

#### Option A: Remote HTTP (recommended)

If your Dstl8 MCP endpoint supports direct HTTP connections:

```toml
[mcp_servers.Dstl8]
url = "https://<org_id>.app.dstl8.ai/mcp"
bearer_token_env_var = "DSTL8_TOKEN"
```

Then set the environment variable in your shell profile (`.bashrc`, `.zshrc`, etc.):

```bash
export DSTL8_TOKEN="dstl8_xxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxx"
```

#### Option B: Via mcp-remote

If direct HTTP doesn't connect (e.g. due to transport compatibility), use `mcp-remote` as a stdio bridge:

```toml
[mcp_servers.Dstl8]
command = "npx"
args = ["-y", "mcp-remote", "https://<org_id>.app.dstl8.ai/mcp", "--header", "Authorization: Bearer <your-token>"]
```

Replace `<org-id>` and `<your-token>` with your credentials.

### Verify

In the Codex CLI, run:

```
/mcp
```

You should see `Dstl8` listed as connected.

In the VS Code extension, go to the gear icon → **MCP settings** to check server status.

### Troubleshooting

**Server fails to connect** — Test `mcp-remote` directly:

```bash
npx -y mcp-remote https://<org_id>.app.dstl8.ai/mcp \
  --header "Authorization: Bearer <your-token>"
```

**Timeout on startup** — Increase the startup timeout in your config:

```toml
[mcp_servers.Dstl8]
startup_timeout_sec = 30.0
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.controltheory.com/controltheory-documentation/dstl8-docs/mcp-integration/codex.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
