Skip to content

Conversation

gpeal
Copy link
Collaborator

@gpeal gpeal commented Sep 30, 2025

This PR adds oauth login support to streamable http servers when experimental_use_rmcp_client is enabled.

This PR is large but represents the minimal amount of work required for this to work. To keep this PR smaller, login can only be done with codex mcp login and codex mcp logout but it doesn't appear in /mcp or codex mcp list yet. Fingers crossed that this is the last large MCP PR and that subsequent PRs can be smaller.

Under the hood, credentials are stored using platform credential managers using the keyring crate. When the keyring isn't available, it falls back to storing credentials in CODEX_HOME/.credentials.json which is consistent with how other coding agents handle authentication.

I tested this on macOS, Windows, WSL (ubuntu), and Linux. I wasn't able to test the dbus store on linux but did verify that the fallback works.

One quirk is that if you have credentials, during development, every build will have its own ad-hoc binary so the keyring won't recognize the reader as being the same as the write so it may ask for the user's password. I may add an override to disable this or allow users/enterprises to opt-out of the keyring storage if it causes issues.

CleanShot 2025-09-30 at 19 31 40 image

@gpeal gpeal force-pushed the gpeal/mcp-auth branch 2 times, most recently from 676a08f to a48094e Compare September 30, 2025 20:33
@gpeal gpeal changed the title [Draft][MCP] Add support for MCP Oauth credentials [MCP] Add support for MCP Oauth credentials Oct 1, 2025
@gpeal gpeal marked this pull request as ready for review October 1, 2025 18:24
Copy link
Contributor

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

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.

ℹ️ 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

.context("failed to load configuration")?;

if !config.use_experimental_use_rmcp_client {
bail!(
Copy link
Collaborator

Choose a reason for hiding this comment

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

What does the user seem when bail!() is used? Is it an ugly scary message with something like a stacktrace or fairly human-readable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nope! It's a normal stdout/err line


impl PartialEq for WrappedOAuthTokenResponse {
fn eq(&self, other: &Self) -> bool {
match (serde_json::to_string(self), serde_json::to_string(other)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can't derive?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No because we don't control the original type and it's in another crate. Let me know if there is a way to do that though but I'm not aware of one.

@gpeal gpeal merged commit 1d17ca1 into main Oct 3, 2025
20 checks passed
@gpeal gpeal deleted the gpeal/mcp-auth branch October 3, 2025 17:43
@github-actions github-actions bot locked and limited conversation to collaborators Oct 3, 2025
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