Skip to content

fix(core): report MCP OAuth token exchange failures on the callback page - #53378

Merged
neriousy merged 3 commits into
anomalyco:v2from
neriousy:mcp-oauth-callback-result
Oct 5, 2026
Merged

neriousy merged 3 commits into
anomalyco:v2from
neriousy:mcp-oauth-callback-result

Conversation

@neriousy

@neriousy neriousy commented Oct 5, 2026

Copy link
Copy Markdown
Member

Fixes #53256

The MCP OAuth loopback callback answered "Authorization successful" as soon as it received a code, before the token exchange ran. When the exchange was rejected (e.g. Slack's bad_client_secret from an unset {env:} client_secret), the browser reported success while the CLI failed and the cause was only in the server log.

The callback now holds the browser response until the exchange finishes and renders the success page or the error page with the provider's message. The exchange runs in a scoped fiber, so it completes whether or not the caller awaits callback.

Adds a test where the token endpoint rejects the code and asserts the callback page returns 400 with the error and callback fails.

neriousy and others added 3 commits October 5, 2026 17:19
The loopback callback answered "Authorization successful" as soon as it
received a code, before the token exchange ran. A rejected exchange (for
example an empty client_secret from an unset {env:} reference) then showed
success in the browser while the CLI failed.

The callback page now waits for the exchange and renders the error when it
fails, and an empty configured client_secret is rejected before the browser
flow starts.

Fixes anomalyco#53256
An empty secret can only be detected after {env:} substitution, so the check
could not name the missing variable. The callback page already reports the
rejected exchange.
@neriousy
neriousy merged commit 4aba11e into anomalyco:v2 Oct 5, 2026
9 checks passed
Sniezka1927 added a commit to nightly-labs/openbot that referenced this pull request Nov 18, 2026
#12141)

* Say in the browser and to the agent when an MCP sign-in did not finish

The loopback page of an MCP sign-in answered "OpenBot is signed in. You
can close this window." as soon as it got the grant, before the token
exchange. When the token endpoint then refused the grant, the browser
said "signed in", but no sign-in was saved. The reason showed only on
the Marketplace page that started the sign-in. The agent's next test
gave only needs_sign_in, so it showed a new Sign in card with no reason.

The page now waits for the token exchange (at most the existing token
timeout). It says "signed in" only when the sign-in was saved. Else it
says "The sign-in did not finish. Go back to OpenBot to see why." The
page uses catalog text only, so no provider text reaches the markup. At
shutdown, a page that still waits is ended at once.

The gateway keeps the reason of the last failed sign-in for each address
in this run. A cancel does not count, and a saved sign-in or a sign-out
removes it. The agent's needs_sign_in result has it as lastSignInError,
and the agent tells the user the reason first.

A sign-in whose page opened on another computer, a relayed sign-in and
the openbot:// link keep their answers. opencode fixed the same page
problem in anomalyco/opencode#53378.

Fixes #12017

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Keep the tool search condition first, and forget a removed server's sign-in failure

In a tool search answer, the sentence that tells the agent to report the
last sign-in failure came before "When the user's request needs this
server". Now the condition comes first.

A server that the user removes, when no other server uses its address,
now also loses its last sign-in failure. A server that the user adds
again does not get an old reason.

A comment now says why a relayed sign-in, and a sign-in opened on another
computer, keep their answer at once.

Refs #12017

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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