# Codex `Codex` is OpenAI’s agentic coding tool, available as a CLI and as IDE extensions - see the `official IDE docs` for the full list. This page covers registering the OneTick MCP server with the CLI and the VS Code extension. Register the MCP server with the CLI (`codex mcp add`) even if you mainly work in an IDE. The CLI supports every option on this page, such as pre-registered client IDs, whereas the IDE extension’s settings form doesn’t always expose them. The CLI and the VS Code extension read the same `~/.codex/config.toml`, so once the MCP server is registered with the CLI it is available in both. The same extension is also available for Cursor through its marketplace, and picks up the same `config.toml`. These instructions are not exhaustive, and MCP clients change quickly. For the latest options and behavior, check the client’s own documentation. #### NOTE The examples below use `http://localhost:8000/mcp` for a local install. Substitute your MCP server’s actual hostname and port if it differs. ## CLI Requires `Codex CLI` installed. #### NOTE This is the basic command, for an MCP server with authentication off. If authentication is enabled, the command may need extra options; see `Authentication` below. Register the MCP server with the `codex mcp add` command, using `--url` for the Streamable HTTP transport: ``` codex mcp add OneTick-Cloud --url http://localhost:8000/mcp ``` Verify it was registered: ``` codex mcp list ``` The MCP server will be available in the next Codex session. To remove it: ``` codex mcp remove OneTick-Cloud ``` ### Authentication What to add depends on how the MCP server’s inbound auth is set up (`KX_MCP_AUTH`; see `MCP server authentication`). The IDE steps further down take the same options. | Server setup | What to do | |-------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------| | Authentication off | Nothing. Use the command above. | | `jwks` with pre-registration (`Keycloak walkthrough`) | Add `--oauth-client-id` to the command, set the callback port and scopes in `config.toml`, and register the callback URL on the IdP client. See below. | | `jwks` with CIMD | Not supported with Keycloak today (see the note below). Use pre-registration or `oidc_proxy`. | | `oidc_proxy` or `entra` | Nothing. Codex discovers the login endpoints itself and opens a browser; the MCP server holds the client credentials. | | Headless or machine caller (no browser) | Set `bearer_token_env_var` in `config.toml`. See below. | ### jwks with pre-registration Codex uses a loopback callback on `127.0.0.1`, not `localhost`, so a redirect URI registered for Claude Code does not cover it. Fix the listener port with `mcp_oauth_callback_port`; `8765` in this guide is arbitrary, and any free port works. The callback path depends on the authorization server’s metadata. When the MCP server supports issuer-bound authorization responses, Codex uses the stable `/callback` path. Otherwise it may append a server-specific callback ID. Run `codex mcp add` and register the exact callback it reports, inserting the configured listener port into the reported `127.0.0.1` URL. With the stable path and port `8765`, the result is `http://127.0.0.1:8765/callback`. If Codex reports a suffix, preserve it. Without a fixed port Codex picks a random one on each login. ``` codex mcp add OneTick-Cloud --url http://localhost:8000/mcp --oauth-client-id onetick-mcp ``` No client secret is needed for a public client. Codex also asks for every scope the IdP lists unless told otherwise, and Keycloak rejects the login with `invalid_scope` for any scope the client is not assigned (for example `service_account`). Restrict it with `scopes`; the audience scope from the Keycloak walkthrough is a default scope, so Keycloak still adds it without it being requested. Both settings go in `~/.codex/config.toml`, and the table each key sits under matters. Codex’s `configuration reference` lists every key, and its `MCP guide` covers OAuth client registration and callbacks: ``` # Top level: before the first [table] header in the file. mcp_oauth_callback_port = 8765 [mcp_servers.OneTick-Cloud] url = "http://localhost:8000/mcp" scopes = ["openid"] [mcp_servers.OneTick-Cloud.oauth] client_id = "onetick-mcp" callback_url = "http://127.0.0.1/callback" ``` #### WARNING A key belongs to whichever `[table]` header is above it. `mcp_oauth_callback_port` must be above every `[table]` header, and `scopes` must be under `[mcp_servers.OneTick-Cloud]`, not `[mcp_servers.OneTick-Cloud.oauth]`. In the wrong place Codex silently ignores them. The symptoms are `Invalid parameter: redirect_uri` (Codex is listening on a random port), a browser that cannot connect to `127.0.0.1:8765` (nothing is listening on that port), or `invalid_scope`. `codex mcp add` writes the `[mcp_servers.OneTick-Cloud]` and `.oauth` tables. Check the saved `callback_url` against the URL the command reported, then add the top-level `mcp_oauth_callback_port` line and `scopes`. Passing `-c mcp_oauth_callback_port=8765` to `codex mcp add` fixes the port for that first login only; it is not saved. Then sign in, and leave the command running until it reports success, because Codex only listens on the port while it runs (do not use `--no-browser`, which skips the listener): ``` codex mcp login OneTick-Cloud ``` Run the same command if no login prompt appears or you need to sign in again. For a one-off login, `--scopes openid` restricts the scopes the same way as the config key. #### NOTE Codex cannot log in to an MCP server secured with Keycloak in `jwks` mode using CIMD, because Keycloak rejects the metadata document Codex publishes (`keycloak/keycloak#51236`). Use pre-registration or `oidc_proxy` mode instead; see `IdP setup: Keycloak (oidc_proxy)`. ### Headless callers See `Headless / non-interactive clients` for how to get a token. Point Codex at an environment variable that holds it: ``` [mcp_servers.OneTick-Cloud] url = "http://localhost:8000/mcp" bearer_token_env_var = "ONETICK_MCP_TOKEN" ``` Codex reads the token from that variable when it connects (see `bearer_token_env_var` in the `configuration reference`). The token is not refreshed. When it expires, export a new one and restart Codex. ## VS Code See the `official docs` for details. 1. Register the MCP server with the CLI, as described above, including any options your authentication setup needs (see `Authentication`). 2. Install Codex in VS Code by opening the Extensions Marketplace, searching for “Codex - OpenAI”, and clicking **Install**. 3. Click the Codex icon and start a new chat session. Restart the extension if the MCP server doesn’t appear; it is read from the shared `~/.codex/config.toml`. ## Using the `OneTick Skill` #### NOTE The skill’s tool calls expect the MCP server to be named exactly `OneTick-Cloud` - which is why it was registered under that name in the steps above. Get the skill by installing the `onetick-knowledge` plugin: ``` codex plugin marketplace add KxSystems/kx-skills codex plugin add onetick-knowledge@kx-skills ``` To remove it: ``` codex plugin remove onetick-knowledge@kx-skills codex plugin marketplace remove kx-skills ``` See the `plugin’s own README` for the install command, credentials, and troubleshooting. The plugin bundles its own `OneTick-Cloud` MCP server, pointed at OneTick’s hosted cloud instance. The user-scope `OneTick-Cloud` MCP server takes precedence, so requests still go to your self-hosted MCP server. Confirm with `codex mcp list` that `OneTick-Cloud` still points at your self-hosted URL: ``` Name Url Bearer Token Env Var Status Auth OneTick-Cloud http://localhost:8000/mcp - enabled Unsupported ```