Skip to content

Allow ChatGPT-hosted MCP servers to use session auth - #29733

Merged
aibrahim-oai merged 9 commits into
mainfrom
codex/configurable-chatgpt-mcp-auth
Jun 25, 2026
Merged

Allow ChatGPT-hosted MCP servers to use session auth#29733
aibrahim-oai merged 9 commits into
mainfrom
codex/configurable-chatgpt-mcp-auth

Conversation

@aibrahim-oai

@aibrahim-oai aibrahim-oai commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Why

ChatGPT session authentication was inferred from the reserved Codex Apps server name. That couples credential routing to Codex Apps-specific behavior and prevents other MCP endpoints hosted by ChatGPT from explicitly using the current session.

The opt-in also needs a clear security boundary: an arbitrary MCP configuration must not be able to redirect ChatGPT credentials to another origin.

What changed

  • Add use_chatgpt_auth to HTTP MCP server configuration, defaulting to false.
  • Honor the setting only when the parsed server URL has the same HTTP(S) origin as the configured chatgpt_base_url; otherwise remove the capability before startup.
  • Resolve bearer tokens and static or environment-backed authorization headers before selecting authentication, with configured authorization taking precedence over ChatGPT session auth.
  • Enable the setting for the built-in Codex Apps and hosted plugin runtime endpoints while keeping Codex Apps caching and tool normalization scoped to the reserved server.
  • Persist the setting through MCP config rewrite paths and expose it in the generated config schema.
  • Load the current login state for codex mcp list so reported auth status matches runtime behavior.

Verification

Core integration coverage exercises the complete streamable HTTP MCP startup path and verifies that:

  • a same-origin opted-in server receives the current ChatGPT access token;
  • an explicitly configured authorization header takes precedence;
  • a different-origin server completes MCP initialization and tool listing without receiving any ChatGPT authorization header.

@aibrahim-oai
aibrahim-oai requested a review from a team as a code owner June 23, 2026 21:59

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0f4e82fea3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/codex-mcp/src/mcp/mod.rs
Comment thread codex-rs/config/src/mcp_types.rs Outdated
Comment thread codex-rs/codex-mcp/src/connection_manager.rs

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f6b8e34170

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/codex-mcp/src/connection_manager.rs Outdated
Comment thread codex-rs/config/src/mcp_types.rs
@aibrahim-oai

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fcb808d555

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/codex-mcp/src/connection_manager.rs
Comment thread codex-rs/codex-mcp/src/connection_manager.rs
Comment thread codex-rs/codex-mcp/src/mcp/auth.rs

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 86514162c1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/config/src/mcp_types.rs Outdated
Comment thread codex-rs/codex-mcp/src/connection_manager.rs

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 39e74efbd7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/codex-mcp/src/mcp/mod.rs
@aibrahim-oai

Copy link
Copy Markdown
Contributor Author

@codex review this

@aibrahim-oai aibrahim-oai changed the title Allow MCP servers to use ChatGPT auth Allow ChatGPT-hosted MCP servers to use session auth Jun 24, 2026
env_vars: Vec<McpServerEnvVar>,
) -> McpServerConfig {
McpServerConfig {
use_chatgpt_auth: false,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nit: consider grouping into an enum with oauth being another auth alternative.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea. didn't want to cause breaking changes but maybe I can process the information after config. will look into it

@aibrahim-oai
aibrahim-oai merged commit 4c0706e into main Jun 25, 2026
31 checks passed
@aibrahim-oai
aibrahim-oai deleted the codex/configurable-chatgpt-mcp-auth branch June 25, 2026 02:21
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants