Skip to content

Native OAuth for streaming-HTTP MCP servers #518

Closed
7 of 7 issues completed
Closed

Description

@JAORMX

User outcome

A user running mecatl as a local Buzz ACP runtime can connect to an OAuth-protected streaming-HTTP MCP server without Buzz implementing ACP URL elicitation. Mecatl owns the standard authorization-code flow: the official MCP Go SDK handles discovery, challenge, PKCE, token exchange, refresh, and transport retry; mecatl owns browser/callback UX, credential custody, lifecycle, and diagnostics. Later Buzz launches reuse the credential silently.

A noninteractive or headless process never opens a browser or waits for consent. It either uses cached or pre-provisioned credentials, uses the existing static bearer path, or fails the affected MCP connection promptly with an actionable login-required error.

Scope

  • Operator-configured global streaming-HTTP MCP servers.
  • Official MCP Go SDK auth.AuthorizationCodeHandler, retained per OAuth identity/server and attached to mcp.StreamableClientTransport.OAuthHandler.
  • Authorization code + PKCE with a runtime-owned browser and loopback callback for explicitly interactive local deployments.
  • A dedicated pre-login operation for unattended later launches.
  • Persistent access/refresh/client state with CAS-safe refresh-token rotation.
  • Explicit noninteractive behavior for mecated, mecatequi, and mecak8s.
  • Existing streamable-HTTP reconnect behavior remains the only MCP reconnect path (docs/adr/0056-mcp-client-reconnect.md).

Non-goals

  • ACP URL elicitation, ACP authMethods, ACP terminal authentication, or a Buzz-specific wire extension.
  • MCP URL elicitation for MCP client authorization.
  • stdio MCP or spawning MCP server processes.
  • OAuth for ACP-supplied per-session MCP entries, inline agent-definition MCP entries, or dynamically discovered MCP sources in the first release.
  • Device Authorization Grant, a custom OAuth protocol stack, background refresh polling, token revocation UI, or RFC 7592 client-registration management.
  • A Kubernetes, distributed, multi-replica, or multi-tenant credential backend. The first encrypted backend is explicitly local-workstation storage.
  • MCP configuration reload or per-run external identity injection.

Architecture constraints

  1. Keep OAuth out of engine/; implementation belongs under internal/adapter, internal/cliconfig, internal/app, and composition roots. No provider-neutral LLM or protobuf widening.
  2. Use the official protocol engine. Mecatl supplies AuthorizationCodeFetcher, InitialTokenSource, NewTokenSource, and a hardened OAuth HTTP client; it does not duplicate discovery, PKCE, exchange, or transport retry.
  3. Retain one SDK handler per OAuth identity/server across Server.dial and internal/adapter/mcp/reconnect.go.
  4. Static MCP headers remain origin-scoped. OAuth discovery/token requests use a separate hardened client and never inherit MCP static headers. Static bearer and OAuth are mutually exclusive for one server in the MVP.
  5. Credential identity includes a stable principal/profile, canonical MCP resource, authorization-server issuer, and OAuth client identity; it is never keyed only by a configured server name.
  6. Tokens, client secrets, authorization codes, callback queries, state, PKCE verifiers, cookies, raw token responses, and authorization-URL queries never enter diagnostics, ACP, model context, config dumps, or errors.
  7. Browser/callback behavior is explicitly enabled. Headless, one-shot, and Kubernetes paths are cache/pre-provision only and return a typed login-required error when credentials are absent or unusable.
  8. No stdio MCP.
  9. Inventory the credential store, retained handlers, authorization singleflight state, callback listener, key source, and OAuth HTTP client in docs/adr/0027-cloud-native.md.
  10. The local encrypted backend is documented as node/user-account scoped and sits behind a backend-neutral contract.

Dependency order

  1. Native credential-store kernel and hardened local backend.
  2. Official MCP SDK authorization profile qualification; safe to run in parallel with 1.
  3. MCP OAuth controller, persistence, refresh, and reconnect reuse.
  4. Runtime-owned browser/loopback login UX.
  5. Operator configuration and headless policy wiring.
  6. Cross-boundary acceptance gate and rollout documentation.

Relationship to existing issues

Completion criteria

  • A clean local profile completes authorization through a browser/loopback callback and lists tools from an offline OAuth-protected MCP fixture.
  • A restarted Buzz-style ACP runtime using the same profile connects without browser interaction or ACP elicitation/auth requests.
  • Expiring credentials refresh through the official SDK; rotated refresh state persists with CAS and survives another restart.
  • A dropped MCP session reconnects through the existing path without losing OAuth state.
  • A headless clean profile returns a classified, redacted login-required result promptly and opens no browser/listener.
  • Static bearer behavior remains byte-compatible; selecting static bearer and OAuth together fails validation.
  • Offline tests, race checks, task lint && task test, go run ./cmd/mecademo, docs generation/check, and task site:build are green.

Sub-issues

Sub-issues

7 of 7 Issues completed
Loading 7 sub-issues

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

    Dependency update: #542 adds the backend-polymorphic headless credential-source track requested for remote/Kubernetes deployments. The credential boundary now separates read-only Reader from mutable CAS Store: local encrypted storage is one adapter; Kubernetes Secret-backed env/mounted-file sources may be read-only. #542 should land after #521 defines the envelope and before #523 finalizes headless composition. Durable refresh rotation across restarts still requires a writable CAS backend; env/file bootstrap must not claim that guarantee.

  4. JAORMX commented on Aug 15, 2026

    @JAORMX
    ContributorAuthor

    Completed. All seven subissues are merged with green CI: credential Reader/Store + hardened local backend (#536), official SDK qualification (#537), durable OAuth controller (#559), host-owned loopback login (#561), Kubernetes Secret-backed environment Reader (#560), operator profiles and mecated mcp login (#562), and the full lifecycle acceptance gate (#564). The acceptance suite proves login, warm restart, refresh-token rotation and persisted rotated-token consumption, another restart, reconnect, headless/ACP boundaries, static/none regressions, and secret-canary coverage. The current SDK pin is intentionally retained: agents verified latest unreleased upstream leaves OAuth limitations unchanged and changes ErrRejected semantics in a way that can cause mecatl to reconnect/replay rejected calls; upgrade waits for a release plus classifier regression tests.

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

Metadata

Metadata

Assignees

Labels

enhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions