
### Codex CLI

Auth: Org API key via `bearer_token_env_var` — Codex sends the Authorization header itself.

1. Mint an org API key with the `create_api_key` tool from a connected session, and export it in your shell (e.g. `MEINKONTEXT_TOKEN`).
2. Add the block below to `~/.codex/config.toml` (or a project-local `.codex/config.toml`), then start Codex.

```toml
# ~/.codex/config.toml
[mcp_servers.meinkontext]
url = "https://meinkontext.de/mcp"
# The NAME of the env var, not the key — Codex reads it at start and
# sends Authorization: Bearer itself, so the token stays out of the file.
bearer_token_env_var = "MEINKONTEXT_TOKEN"
```

- Caveat: `bearer_token_env_var` contains only the variable name. Keep the actual key out of configuration files and protect its environment or secret store. See the [official MCP guide](https://learn.chatgpt.com/docs/extend/mcp?surface=cli).
- Caveat: Org-scoped service principal — read-only for objects (authoring tools are hidden), and for memory: `recall` and `search` work, `remember` and `forget` need OAuth.
- Caveat: `instructions` arrive at connect only — restart Codex after a tool-surface change, otherwise the session keeps the old digest.
- Caveat: With a personal OAuth connection, ask: “Set up meinKontext for this project using `setup_client`. Prefer relevant skills, memory and knowledge without repeated reminders.” Name the connection as configured in your client. Agent profiles and org API keys cannot run personal setup.
- Caveat: The tool returns a recipe; your agent checks the effective instruction file and adds only its marked routing block. Existing rules remain. It does not copy your context or switch off native memory, but it tells your agent to save lasting facts only in meinKontext. On request it can supply a local hook and rollback recipe; your client must install and trust it. Supported local versions get a project or user recipe; unknown versions and browser/cloud clients get session instructions. Start a new session afterwards.
- Caveat: Ask the agent to check with `action: "check"` or remove with `action: "remove"`. A matching block hash confirms only the client-reported structure. Test a relevant task in a fresh session to see whether it actually reads the skill or memory. Keep the local installation receipt: it lets the agent remove its unchanged block even when the server is offline. Modified or duplicate blocks require reconciliation.
- Caveat: For personal setup, use a separate OAuth connection rather than the org API key configuration above: `codex mcp add meinkontext-personal --url https://meinkontext.de/mcp`, then `codex mcp login meinkontext-personal`. Use `meinkontext-personal` as the setup connection name. See [Codex MCP authentication](https://learn.chatgpt.com/docs/extend/mcp?surface=cli).

**Variant: add it from the command line**

1. `codex mcp add` can write the same configuration using the environment variable name. Older CLI versions may require the file configuration above.

```bash
codex mcp add meinkontext --url https://meinkontext.de/mcp --bearer-token-env-var MEINKONTEXT_TOKEN
```