Skip to content

Runtime-owned browser and loopback login for MCP OAuth #522

Description

@JAORMX

Parent: #518

Outcome

A local mecatl process completes MCP OAuth itself—browser, callback, and token persistence—with no ACP URL elicitation. Operators may authenticate once before starting Buzz; later launches reuse the same credential profile silently.

Design requirements

  • Implement the official SDK AuthorizationCodeFetcher as a mecatl-owned local authorization session.
  • Bind loopback before constructing the redirect URI; use an unguessable callback path, GET-only route, bounded headers/query/time, safe constant/escaped HTML, security headers, and deterministic cancellation/shutdown.
  • Consume one callback atomically. Bind state to the login attempt, principal/profile, MCP resource, issuer, and redirect URI; return only code/state/iss to the SDK.
  • Launch the browser through an argv-only OS API, never a shell. Explicit no-browser/print mode may write the URL only to the directly attached user terminal, never diagnostics or ACP/Buzz logs.
  • Add a dedicated mecated MCP login operation that uses the same server/auth configuration as serving and exits only after durable save plus authenticated initialize/tool listing.
  • Optionally allow on-demand browser login only in an explicit local-interactive mode. Do not inspect Buzz, send ACP auth/elicitation requests, or depend on stdin.
  • Serialize presentation so concurrent startup connects do not open multiple browsers.
  • If browser/callback placement is unavailable, return typed login-required with the pre-login/pre-provision remedy rather than waiting on ACP.

Acceptance criteria

  • A simulated browser completes the SDK flow through loopback.
  • Wrong method/path/state/issuer, replay, duplicate, oversized, and late callbacks fail safely.
  • Cancellation closes the listener and joins all goroutines.
  • No token, code, state, verifier, cookie, or complete authorization URL reaches logs.
  • A Buzz-style ACP launch in explicit local-interactive mode completes auth while its ACP transcript contains no auth/elicitation method or OAuth artifact.
  • Pre-login followed by a new process invokes no browser.

Verification

Offline loopback integration tests, browser fake, replay/mismatch/fuzz tests, cancellation/goleak proof, terminal-vs-diagnostics redaction test, and ACP method recorder.

Dependencies and sizing

Depends on SDK qualification and the merged controller/fetcher contract.

Size: L. Complexity: high/security-sensitive. Execution: chunk callback host, then command/platform wiring.

Activity

  1. self-assigned this
    on Aug 14, 2026
  2. added
    enhancement
    on Aug 14, 2026
  3. JAORMX commented on Aug 14, 2026

    @JAORMX
    ContributorAuthor

    Implementation is complete on feat/issue-522-mcp-oauth-login, stacked on #521. It adds a stdlib-only importable mcp/oauthlogin runtime with random-path IPv4 loopback callback, strict state/issuer/query validation, bounded HTTP lifecycle, safe static HTML/headers, fixed-argv browser launch, explicit terminal-only no-browser mode, serialization/cancellation/cleanup, plus an app.LoginMCP one-shot bridge through the real controller/Connect path. Security/QA repair waves added probe-flood resilience, proof that OAuth actually occurred, encrypted-store restart, post-callback cancellation, and temporary-session cleanup. No CLI/profile/config/ACP wiring is claimed; that remains #523. Lint, race/full tests, docs/site checks, and offline demo pass. Branch pushed; PR waits on stacked prerequisites for a clean diff.

  4. added a commit that references this issue on Aug 15, 2026
    381a0d3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementux

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions