-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[MCP] Add support for MCP Oauth credentials #4517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
676a08f
to
a48094e
Compare
a48094e
to
66d2c09
Compare
88f9410
to
a3129a1
Compare
f4a56cc
to
588e10a
Compare
There was a problem hiding this 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!( |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't derive?
There was a problem hiding this comment.
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.
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
andcodex mcp logout
but it doesn't appear in/mcp
orcodex 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.