Skip to content

Studio: stop asking for MCP OAuth consent again after the token expires - #18203

Merged
danielhanchen merged 5 commits into
unslothai:mainfrom
NilayYadav:fix-mcp-oauth-token-endpoint
Nov 18, 2026
Merged

danielhanchen merged 5 commits into
unslothai:mainfrom
NilayYadav:fix-mcp-oauth-token-endpoint

Conversation

@NilayYadav

Copy link
Copy Markdown
Collaborator

Fixes #18164. Studio refreshed MCP OAuth tokens at <server>/token instead of the server's real token endpoint, because every connection starts a new OAuth client that hasn't looked up the server's metadata. Servers like better-auth (/api/auth/oauth2/token) answered 404, so every reconnect after the access token expired sent the user through sign-in and consent again. Studio now saves the token endpoint with the tokens and uses it on refresh.

Tested with a real better-auth server:

Before After
before after

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T06:05:17.828433Z f665d44 Manual 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 0e88f920cf

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

@NilayYadav

Copy link
Copy Markdown
Collaborator Author

@codex security review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 04df8d9041

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

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: b4b59d3e1e

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

@unslothai unslothai deleted a comment from NilayYadav Nov 18, 2026
@unslothai unslothai deleted a comment from NilayYadav Nov 18, 2026
# Conflicts:
#	studio/backend/core/inference/mcp_client.py
danielhanchen pushed a commit to LeoBorcherding/unsloth that referenced this pull request Nov 18, 2026
…CP server (unslothai#18171)

Related to unslothai#18164 (the reported bug is fixed in unslothai#18203). When several
connections to Notion's MCP server refreshed an expired token at the
same time, Studio could keep a refresh token Notion had already
replaced. The next refresh failed with a 400 and Studio asked for
consent again on every connection. Now one connection refreshes and the
rest reuse the new token.

Tested against the real Notion MCP server in Studio:

| Before | After |
|---|---|
|
![before](https://raw.githubusercontent.com/NilayYadav/unsloth-staging/pr-media/pr/18171/mcp-notion-before-7bcd526ef7d7.png)
|
![after](https://raw.githubusercontent.com/NilayYadav/unsloth-staging/pr-media/pr/18171/mcp-notion-after-37aa2f223d8b.png)
|
danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 18, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: f665d44e22

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] MCP OAuth: consent prompt shown on every connection instead of reusing stored token.

2 participants