Skip to content

feat(mcp): add inline OAuth re-authentication prompt and sign-in flow - #8336

Open
smsunarto wants to merge 1 commit into
get-bb:mainfrom
smsunarto:scott/bb-19-mcp-oauth-reauth-prompt-with-inline-sign-i-thr_tsdzd2zehf
Open

smsunarto wants to merge 1 commit into
get-bb:mainfrom
smsunarto:scott/bb-19-mcp-oauth-reauth-prompt-with-inline-sign-i-thr_tsdzd2zehf

Conversation

@smsunarto

Copy link
Copy Markdown
Contributor

Human comments

What was wrong

When a Codex or Claude Code MCP server required OAuth authentication or re-authentication, bb dropped the provider's signal (#8335). In plugins/provider-codex/src/visibility.ts, mcpServer/startupStatus/updated was classified as "noise" and ignored by delta translation, and plugins/provider-claude-code/src/bridge/bridge.ts never inspected mcp_servers or mcpServerStatus() for needs-auth servers. Users received no prompt in the thread timeline and had to run codex mcp login <name> manually—which fails on remote hosts where the provider's local loopback OAuth listener runs on a machine the user's browser cannot reach directly.

What changed

  • Inline notice & Sign in drawer (Codex + Claude Code):
    • Surfaces OAuth-required MCP startup notices (reauthenticationRequired / mcp login on Codex; non-claudeai needs-auth on Claude Code) as inline warning rows kept outside collapsed turns, while keeping non-auth startup failures suppressed.
    • Clicking Sign in opens the shared compact dialog/drawer with Open sign-in page, Copy link, and a paste-the-redirect-URL input for local and remote hosts. Never auto-opens a browser directly; auto-closes when login completes; offers Try again directly after provider rejection or timeout.
    • Persists sign-in completion via an additive provider/mcpSignIn/completed thread event (also emitted when Codex reports ready or Claude reports connected after an announced notice), derived per thread and server across latest pages, older pages, reloads, and turn-summary details.
  • Wire & protocol changes:
    • Bumped HOST_DAEMON_PROTOCOL_VERSION from 285 to 286, adding thread.mcp_sign_in.start and thread.mcp_sign_in.complete host daemon commands and thread/mcpSignIn/start / thread/mcpSignIn/complete provider bridge JSON-RPC methods.
  • Plugin SDK export:
    • Exported experimental_validateLoopbackOAuthCallbackUrl from @get-bb/plugin-sdk/provider-bridge (http/https only, with protocol, host, port, pathname, and state bound and loopback-only verification via @bb/config/loopback), documented in docs/api_to_audit.md and plugins/plugin-api-docs/src/surfaces.ts.
  • New public surfaces:
    • HTTP API & @bb/sdk: POST /api/v1/threads/:id/mcp-sign-in/start and POST /api/v1/threads/:id/mcp-sign-in/complete.
    • CLI & guide templates: bb thread mcp-sign-in [id] --server <name> [--callback-url-file <path> | --callback-url <url>], supporting - to read piped stdin or paste interactively at a terminal (raw-mode readline to avoid canonical-mode truncation and keep OAuth codes out of shell history).
  • Known follow-ups (out of scope here):
    • An open tab's already-loaded older-page rows update only after reload (server older-page cache and re-fetches reflect completion immediately; live client merge into already-loaded older pages would require extending the timeline response/delta contract).
    • Codex loginId matching on mcpServer/oauthLogin/completed (upstream notification schema does not carry loginId).
    • Dedupe resets when a thread session resumes.
  • Credit: Ported from and inspired by T3 Code at fa02e0d78135e4b06892ac35f62213f0e592aac7 (MIT).

How you verified

  • Automated tests (all touched packages):
    • pnpm exec turbo run build:types --filter=@get-bb/plugin-sdk and full lint, typecheck, and test suites across all 20 touched packages (@bb/app 706 files / 7,487 tests, @bb/server 439 files / 4,595 tests, @bb/cli 82 files / 1,460 tests, @bb/db 72 files / 762 tests, @bb/thread-view 36 files / 567 tests, @bb/agent-runtime 23 files / 320 tests, @bb/provider-bridge-protocol 26 files / 430 tests, @get-bb/plugin-sdk 44 files / 453 tests, bb-plugin-provider-codex 51 files / 641 tests, bb-plugin-provider-claude-code 33 files / 467 tests, bb-plugin-plugin-api-docs 13 files / 76 tests, plus @bb/domain, @bb/host-daemon-contract, @bb/server-contract, @bb/sdk, @bb/client-core, @bb/templates, @bb/provider-bridge-acp, bb-plugin-provider-pi, and @bb/host-daemon).
    • Added unit, bridge, daemon dispatch, server API/pagination/turn-details, CLI command-output, and React UI tests covering mid-turn collapse, out-of-slice completion, older-page cache invalidation, strict loopback callback validation, rejection/retry UX, and TTY/stdin input.
  • Dev instance & PTY checks (fakes only):
    • Verified end-to-end in an isolated pnpm start:worktree dev instance driven by fake-codex-app-server.mjs and a fake loopback OAuth server (127.0.0.1): mid-turn notice stays outside collapsed turns, rejection offers Try again, completion persists Signed in across reload and turn expansion, and bb thread mcp-sign-in --callback-url-file - works end-to-end. Testing used fake OAuth servers only, never real accounts.
    • Verified 5,009-character terminal paste without truncation or echo on a real Linux PTY (pty.openpty()).

Closes #8335

AGENT GENERATED

@smsunarto
smsunarto force-pushed the scott/bb-19-mcp-oauth-reauth-prompt-with-inline-sign-i-thr_tsdzd2zehf branch from cf0f22c to 9bc6112 Compare November 29, 2026 06:11

This branch has not been deployed

No deployments
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.

Surface MCP OAuth re-authentication notices with inline Sign in for Codex and Claude Code

1 participant