Skip to content

fix(site): auto-select MCP server after successful OAuth - #28155

Open
ibetitsmike wants to merge 3 commits into
mainfrom
mike/mcp-oauth-auto-enable
Open

fix(site): auto-select MCP server after successful OAuth#28155
ibetitsmike wants to merge 3 commits into
mainfrom
mike/mcp-oauth-auto-enable

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

When an MCP server requires OAuth, the chat MCP picker showed an "Auth" button, and after completing the popup flow the user still had to reopen the picker and flip the enable switch manually. Clicking Auth already expresses the intent to use the server, so the extra step was unnecessary.

This change auto-selects the server when its OAuth popup reports success. AgentChatInput tracks the flow it started as {popup, serverID}; a mcp-oauth2-complete postMessage changes the selection only when it comes from that popup and names that server, and only for a server that exists in the fetched list, is enabled, and is not already selected. The correlation deliberately survives popup close: coderd's callback page posts the message and then closes itself, so the close poll can observe the closed popup before the queued message is dispatched. Selection persistence is unchanged (parent callbacks on the chat page and create form store it as before), and failed or aborted auth flows post no message, so they cannot select anything.

Covered by five Storybook interaction stories: successful auto-enable through a real menu-open and Auth click with a mocked popup, auto-enable when the popup closes before the message is dispatched, no duplicate selection, unsolicited-message rejection (no Auth click), and mismatched-server rejection (completion names a different server than the one authenticated). Each behavior story was verified red-green against the code it guards.

Dogfood UAT ran with a full OAuth round trip (local OAuth2 stub) on both the chat page and the create form, plus aborted-popup, manual toggle, force_on, and disconnect regression checks; all passed. Codex review ran three rounds; both findings (gate selection on the initiating popup, exercise the real Auth interaction) are fixed and resolved, with a clean verdict on the final head.

Mux acted on Mike's behalf to create this PR.

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

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

Copy link
Copy Markdown

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: 8cee56c1c2

ℹ️ 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 site/src/pages/AgentsPage/components/AgentChatInput.tsx Outdated
Comment thread site/src/pages/AgentsPage/components/AgentChatInput.stories.tsx Outdated
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

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

Copy link
Copy Markdown

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: 83894d4116

ℹ️ 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 site/src/pages/AgentsPage/components/AgentChatInput.tsx Outdated
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 62b641092a

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

@ibetitsmike
ibetitsmike marked this pull request as ready for review August 14, 2026 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant