Skip to content

MCP OAuth: offer the RFC 8628 device authorization grant to MCP clients, so a client running on a remote or headless machine can be authorized from a phone without a localhost redirect #35801

Description

@objectstack-fleet

repo:cloud#5 · hotlong · session_01Q4EjjPP1zuWBNq3nBXVei9

Filing gate: ③ a task on the maintainer's word, verbatim 「立卡」, given in the repo:cloud#5 seat session (2026-11-20). He had just shown a remote MCP client failing to complete OAuth against a hosted environment. Reader: the domain:server lane (plugin-auth OAuth / MCP authorization). Dedupe: device authorization MCP oauth (is:issue) returned 5 unrelated QA-run and invitation cards; no open card covers this.

维护者速读

  • 问题:MCP 客户端跑在云端电脑或服务器上(例如 WorkBuddy 的 Cloud Computer)时,用手机走 OAuth 授权,授权完会跳到 http://localhost:<port>/callback。这个地址指向手机自己,打不开,用户只能手动复制地址栏网址发回给客户端。
  • 要做:MCP 的授权入口同时提供「设备码授权」(RFC 8628)。客户端显示一个短码,用户在手机上打开授权页、输入短码确认即可,不需要跳回 localhost。
  • 平台已有这套机制:objectstack login 已经在用 /api/v1/auth/device/code。要补的是对 MCP 客户端开放,并在授权服务器元数据里声明它。
  • 需要你做的:无。

What was seen

A remote MCP client registered by DCR with a loopback redirect, http://localhost:8765/callback. That is allowed for native clients (RFC 8252; packages/plugins/plugin-auth/src/auth-manager-plugin-list.ts around lines 668–689). The user authorized from a phone. The redirect went to the phone's own localhost and failed. The flow only completed because the user copied the URL by hand back to the client.

Measured (objectstack main)

  • The device flow exists for the CLI: packages/cli/src/commands/login.ts calls POST /api/v1/auth/device/code and polls with grant_type=urn:ietf:params:oauth:grant-type:device_code.
  • The authorization-server metadata (/.well-known/oauth-authorization-server, packages/plugins/plugin-auth/src/auth-plugin.ts around lines 6286–6292) is what MCP clients discover. Not yet read: whether it advertises device_authorization_endpoint and the device grant in grant_types_supported, and whether DCR accepts that grant for a public MCP client. The dev measures these first.

Done when

  • The MCP-facing authorization-server metadata advertises device_authorization_endpoint, and lists urn:ietf:params:oauth:grant-type:device_code in grant_types_supported.
  • A DCR-registered public MCP client can complete the device flow and receive a token with the same scopes and consent screen as the authorization-code flow.
  • The consent page names the client and the requested scopes before approval. The user code is short-lived and single-use.
  • A test pins both the metadata and an end-to-end device-flow token for an MCP client.

The security reading is owed in the PR: user-code entropy and expiry, polling rate limits, and the consent page as the only approval point. Device-flow phishing (a code relayed to a victim) is mitigated by naming the client on consent.

Activity

  1. added
    enhancement
    on Nov 20, 2026
  2. objectstack-fleet commented on Nov 20, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Triage: lands in domain:server (plugin-auth OAuth, MCP authorization) · pm:queue; rationale: area:ai · Feature (offer the RFC 8628 device authorization grant to MCP clients and declare it in the authorization-server metadata, so a client on a remote or headless machine completes OAuth without a localhost redirect; objectstack login already uses /api/v1/auth/device/code) · filed on the maintainer's word 「立卡」 after a remote MCP client failed OAuth on a hosted environment → p2 (a maintainer-sourced Feature; he may raise it) · size M.

  3. added
    area:ai
    domain:server
    pm:queue
    priority:p2
    on Nov 20, 2026
  4. objectstack-fleet commented on Nov 21, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#6 · sunhaolin · session_017xRBcSPM86QhYAcidhG5Bu

    维护者速读

    • 问题:AI 客户端跑在云端电脑上、用户在手机上点同意时,授权结果被送去手机自己的本机地址,页面打不开,只能把地址栏的网址手抄回客户端。只见过你演示的那一次;这类客户端每次连接都会遇到。
    • 选项:A 增加“设备码授权”,客户端显示短码、用户在任意屏幕输入并同意,约 3 个 PR,只对会用设备码的客户端生效;B 现在不做,卡挂起,等有客户端确实会用设备码再做,用户照旧手抄;C 同意页在手机上不再跳去打不开的地址,改成“复制链接”一步,1 个小 PR。
    • 推荐 B:实测通用的 AI 客户端开发包里没有设备码授权,也没有证据说明出问题的那个客户端会用它,现在做等于给每个环境多开一扇没人走的门。
    • 不定会怎样:现状不变,远程客户端的用户授权后看到浏览器报错页,手抄网址才能连上。

    Decision analysis: a second way to approve an AI app that runs on another machine

    Question. A person approves an AI app from a phone while the app runs on a cloud computer, lands on a page that cannot open, and copies the address back by hand: should the platform add an approval that needs no redirect?

    Background. The card's premise (the platform already has this; open it to MCP clients) does not hold as measured: the existing short-code sign-in mints a full sign-in session, not the scoped agent grant.

    Governing text: packages/spec/src/system/auth-config.zod.ts:63-79 (the switch is "CLI / TV-style login"; /device/token is "poll for the issued session token"); ruling 6232069920 A at packages/plugins/plugin-auth/src/auth-manager-plugin-list.ts:707-745 (a consent binds the approving session's organization, never a guessed one); objectstack-ai/cloud#3606 ruling A at mcp-token-revocation.ts:251-259, same directory (the consent is the revocable record the MCP door reads); docs/NORTH-STAR.md:11 (road step "connect an agent"). No option conflicts with these; A must satisfy both rulings.

    Protocol. A adds public surface: a token-endpoint grant, a discovery key, a registrable grant, two columns on sys_device_code, a new meaning for the spec switch. B and C add none.

    Premises (origin/main 30b0987, committed 2026-11-21T15:25Z; "run" = executed on better-auth and @better-auth/oauth-provider 1.7.12, tarballs matching the lockfile; A=packages/plugins/plugin-auth, P=ui/apps/console/src/pages/auth):

    1. Discovery today lists three grants and no device endpoint, and self-registration silently drops a requested device grant (run). The document is the vendor's ($A/src/auth-plugin.ts:6251-6255). Re-check: git grep -l "oauthDeviceAuthorization\|device_authorization_endpoint" origin/main | wc -l → 0 (control: git grep -c deviceAuthorization origin/main -- $A/src/auth-manager-plugin-list.ts → 5).
    2. The existing flow is the vendor's plain plugin, off by default, no environment switch (auth-manager-plugin-list.ts:237, :996-1002). Not gated to the CLI: an unregistered client name gets a code, and approval yields a full session, not a scoped grant (run). Vendor defaults: 8-character code (40 bits), 30 min expiry, 5 s polling interval, single use (run). Re-check: git grep -n validateClient origin/main -- $A/src | wc -l → 0.
    3. The pinned vendor ships its own OAuth device grant. Switched on with nothing else (run): discovery advertises it; an anonymous client registers for it with no redirect address; the first-party name objectstack-cli (packages/cli/src/commands/login.ts:422, packages/cloud-connection/src/cloud-connection-plugin.ts:751) is refused; the token carries no organization and leaves no consent record, though the approving session had one. The MCP door refuses a token with no consent (mcp-token-revocation.ts:277; read, not run). Re-check: grep -n "function oauthDeviceAuthorization" $A/node_modules/@better-auth/oauth-provider/dist/index.mjs.
    4. The consent page names the app, marks it unverified, names where the grant goes and lists permissions ($P/OAuthConsentPage.tsx:190, :392, :438). The device page shows none of these (DeviceAuthPage.tsx:56, :299-309), and a device request has no destination to show. Re-check: git grep -n "client_id\|scope" origin/main -- $P/DeviceAuthPage.tsx | wc -l → 0.
    5. No reader is measured: the pinned MCP client kit (@modelcontextprotocol/sdk 1.32.1) contains no device grant. Re-check: grep -rIlE "device_code|device_authorization" node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1*/ | wc -l → 0.
    6. The consent page leaves for any web address, loopback included; its stay-and-finish card covers app links only. Re-check: git grep -n "window.location.assign(redirect)" origin/main -- $P/OAuthConsentPage.tsx → line 264.
    Option What ships What the customer sees Workload
    A The vendor's device grant behind the existing switch; its approval page names the app, the unverified mark and the permissions; approval writes the same consent record with the organization; the first-party name keeps working An app that speaks the grant shows a short code, approved on any screen; other apps see no change. Any self-registered app can start a request where the switch is on server + ui lanes · 3 PRs · switch and pin like #25156 (+405/−0); page like #32053 (+961/−10); consent and organization on this path: no precedent (nearest #30879, +1114/−16)
    B Nothing; the card goes on hold with a restart condition As today 0 PRs
    C On a phone or tablet, a grant headed to a loopback address stops on a card with Copy link and Continue One tap, then paste into the app; works in apps that accept a pasted link (the sighted one did) ui lane · 1 PR · #34369 (+264/−9)

    In business terms. A: a TV-style pairing code beside the sign-in redirect. B: keep the manual step until an app can use a code. C: put the claim ticket on screen so the person can carry it over.

    Four axes.

    • Long-term soundness. In two years an agent on any machine is approved through one consent record on one approval page. GitHub, Salesforce and Microsoft Entra offer a device code as a per-application opt-in, and Entra advises blocking it unless a device needs it, because approval is not tied to the machine that asked (general knowledge, not measured here). A is that shape once apps use it; today it adds that surface and a second approval page that must track the first, for no measured user.
    • Business pull. One sighting, with a working manual step; nothing measured asks for a device code.
    • AI-error guard. A built halfway fails loudly (the agent and the command-line sign-in are refused), with one quiet case: a grant with no organization. C fails loudly (a stale link).
    • No spread. A is permanent surface on every host with the switch on; C is one page branch; B is nothing.

    os-decision-facets
    ① Long-term soundness: A widens the contract and adds a second approval page; B adds nothing; C adds one page branch.
    ② Business pull: one sighting; no measured client requests a device code.
    ③ AI-error guard: A refuses loudly except for a missing organization; B and C move no boundary.
    ④ No spread: A is a standing obligation with no user today; B none; C small.
    Prior rulings read: device authorization,device_code,rfc 8628,deviceauthorization,device flow,loopback redirect,dynamic client registration,oauth consent → 0 hits; ADR-0090 D10 (read; it governs who the agent is, not how it is approved); thread: none

    Recommendation: B. Not A: nothing measured would use it, and it is three PRs on the sign-in boundary, three times C. Not C: it tidies the hand copy by guessing the device, on one sighting.

    Confidence gaps: whether the sighted client, or any client the maintainer's users run, speaks the device grant is not verified (only the reference client kit was read; the MCP specification site was unreachable here); whether the hosted environment has the switch on was not read; the door's refusal in premise 3 is read, not run.

    Self-check: axis ① alone picks B; do ②③④ flip it: no.

    After the ruling.

    • B: the seat puts the card on hold; it restarts when a named MCP client is shown requesting a device code from a server it discovered.
    • A: the same ruling settles two points: whether any self-registered app may use it (marked unverified) or only administrator-registered ones, and whether hosted environments turn the switch on. Then three PRs in the table's order, the card's security reading in the first. The dev re-runs premise 3 first; if the organization cannot ride the vendor path without copying vendor internals, the dev reports the fork and ships nothing.
    • C: a new ui card; this card goes on hold as in B.

    Related: #24218 (the organization binding A must match).

  5. added
    needs-user-decision
    and removed
    pm:queue
    on Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:aidomain:serverenhancementneeds-user-decisionpriority:p2

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions