Skip to main content

Codex (OpenAI)

Codex MCP Integration

The Codex desktop app and Codex CLI support remote MCP servers, including OAuth. For detailed configuration instructions, visit the official documentation.

This guide covers the local Codex desktop app and CLI - not ChatGPT web or hosted Codex tasks. Examples use PowerShell on Windows; app labels and CLI options can vary by Codex release.

Setting up OAuth

Connecting with OAuth lets Codex sign you in through your organization's identity provider, using MCP OAuth with Dynamic Client Registration (DCR). For the full client and admin setup, follow the OAuth Setup guide.

Codex uses Timbr's Streamable HTTP endpoint:

https://<your-timbr-host>/timbr/api/mcp

Use the exact same URL in the configuration and at sign-in, including any trailing slash - Codex derives its OAuth callback from the server URL. Don't use the legacy /sse endpoint for this flow.

Codex sign-in is separate from Timbr sign-in

Signing into Codex with a ChatGPT account does not authenticate you to Timbr. The OAuth flow opens your organization's identity provider so you sign in as your own Timbr user.

Codex Desktop App​

  1. Install or update the Codex desktop app and sign into Codex.

  2. Open Settings (Ctrl+, on Windows, Cmd+, on macOS) and search for the MCPs with the label Plugins underneath. Then click on the Add dropdown menu and choose the Add MCP server option.

    Codex desktop app MCP servers settings

  3. Give a name to the custom MCP server, for example timbr

  4. Change the Type to Streamable HTTP

  5. Enter the URL of your MCP server which should be in the following pattern: https://<your-timbr-host>/timbr/api/mcp

  6. Click on the Save button. Codex MCP Server settings

  7. Click Authenticate on the timbr server and sign in through your organization's identity provider.

  8. Start a new conversation and confirm Timbr's tools are available.

Setting up OAuth

Your Timbr admin must register the Codex redirect URI (for example http://127.0.0.1:57535/callback/<id>) with your identity provider, and enable DCR on the server. Follow the OAuth Setup guide for more information.

Codex CLI​

  1. Check that your CLI supports forcing DCR:

    codex --version
    codex mcp login --help

    The login help should list --oauth-client-registration. If it doesn't, update Codex. Older versions may still use DCR automatically through codex mcp login timbr.

  2. Add Timbr (skip this if you already added it through the app or config.toml):

    codex mcp add timbr --url https://<your-timbr-host>/timbr/api/mcp
    codex mcp list

    Don't pass --oauth-client-id, an API key, or a bearer token. Add the [mcp_servers.timbr.oauth] callback_port setting from the desktop app steps above to config.toml.

  3. Authenticate with DCR:

    codex mcp login timbr --oauth-client-registration dcr

    Your browser opens your organization's sign-in page. Complete login, MFA, and consent, and wait for Codex to report that login is complete before closing the terminal.

  4. Start Codex and run /mcp to inspect the active servers, then verify with a real tool call:

    Use the Timbr MCP server's list_ontologies tool to list the ontologies available to my account. Do not create or modify anything.

    A listed server is not proof of authentication - confirm the tool call completes without an authentication error. An empty list is valid if your account has no ontology grants.

App and CLI share configuration

The desktop app and CLI share MCP configuration on the same host, but not necessarily credentials. Authenticate in the same environment where the app runs - a login done inside WSL, a container, or another user account is not reused by a Windows app.

Dynamic Client Registration

Codex registers itself as an OAuth client through Timbr's /timbr/api/oauth/register endpoint, then uses the authorization-code flow with PKCE. If your identity provider (e.g. Azure AD) doesn't natively support DCR, your IT admin can enable it on the server by setting MCP_OAUTH_DCR_ENABLED=true together with MCP_OAUTH_CLIENT_ID and MCP_OAUTH_CLIENT_SECRET. See the OAuth Setup guide for the complete provider configuration.

Troubleshooting​

ErrorCauseFix
--oauth-client-registration is unrecognizedOlder Codex CLIUpdate Codex, or use codex mcp login timbr and let it select DCR automatically
No registration request reaches TimbrAn explicit OAuth client ID is configured, or a previous registration is being reusedRemove oauth.client_id from the configuration; sign out of timbr (see codex mcp --help) and log in again
AADSTS50011 / redirect mismatchThe Codex callback isn't registered on the identity provider app, or the port changed between sign-insPin callback_port and ask your admin to register the exact callback - see the OAuth Setup guide
Browser callback cannot connectThe login process stopped, or sign-in ran in a different host (WSL, SSH)Keep the login running and sign in from the same host as Codex
Login works, but tools return 401 or 403Expired token, missing Timbr user, or no ontology grantsRe-authenticate; ask your admin to confirm your Timbr user and access, and remove conflicting static auth settings
Browser says "Authentication complete", but Authenticate reappearsCodex received a Microsoft Graph token instead of a Timbr token (Timbr API Service before version 5.8.1)Upgrade Timbr API Service to version 5.8.1 or later, or force the Timbr scope
CLI works but the app doesn'tDifferent host, user, CODEX_HOME, server URL, or credential storeAlign them and restart the app

Force the Timbr Scope​

Codex requests the scopes listed in Timbr's authorization-server metadata. Before Timbr API Service version 5.8.1, that list held only OpenID scopes (openid profile email offline_access), so Azure AD answered with a Microsoft Graph token that Timbr can't validate: sign-in appears to succeed, then every tool call fails authentication. Timbr Service API version 5.8.1 and later list the resource scope first, so this setting isn't needed there.

To force the scope, add scopes to the server's table, using your server's MCP_OAUTH_SCOPES value followed by offline_access (which gets Codex a refresh token):

[mcp_servers.timbr]
url = "https://<your-timbr-host>/timbr/api/mcp"
scopes = ["api://<resource-app-id>/.default", "offline_access"]

[mcp_servers.timbr.oauth]
callback_port = 57535

Restart the app and click Authenticate - the new sign-in replaces the stored Graph token. The setting stays harmless after upgrading Timbr. With the CLI, codex mcp login timbr --scopes "api://<resource-app-id>/.default,offline_access" does the same for a single login.


References​