feat(oauth): device flow UX — auto-browser + auth-required tool response (mcp-server, local-mcp)#208
Merged
Merged
Conversation
…ce flow
v0.11.0 で導入した device authorization grant の初回認証 UX を修復する。
stderr へのログ出力のみでは Claude Code / Desktop のチャット UI にユーザが
気付けず、ツール呼び出しが 600 秒沈黙したまま expired_token で終わる状態に
なっていた。
主な変更:
- performOAuthFlow() を phase 1(device code 取得)と phase 2(polling)に
分割し、polling をバックグラウンドに逃がした。
- tool handler は新設した getAccessTokenForToolCall() を経由し、device flow
未完了時は AuthRequiredError 経由で isError=true + user_code / verification
URL を含む構造化応答を即座に返す。2 回目以降の同一ツール呼び出しも同じ
メッセージを返し(polling は 1 本を共有)、完了すれば次の呼び出しで通常
処理に戻る。
- device authorization 応答受信直後に child_process.spawn で platform 既定の
ブラウザを起動する(Windows: cmd /c start、macOS: open、Linux: xdg-open)。
失敗は non-fatal。
- mcp-server/server/index.js と local-mcp/src/index.ts を同じ設計で揃えた。
- manifest.json / package.json / server.json を 0.11.1 に version bump。
- docs/0-requirements.{md,ja.md} に F7.9(自動オープン)/ F7.10(auth-required
応答)を追加。docs/installation.{md,ja.md} の初回認証節を書き換えて
v0.11.1 の体験を説明。
- mcp-server/test/auth-required.test.mjs で応答フォーマットの契約テストを
追加(verification_uri_complete 優先 / user_code 必須 / isError=true /
retry 指示 / expires_at の有無)。
Refs #207
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
github-webhook-mcp | 4cf120f | Apr 20 2026, 01:47 PM |
liplus-lin-lay
commented
Apr 20, 2026
Member
Author
liplus-lin-lay
left a comment
There was a problem hiding this comment.
Self-review: PASS
Acceptance check (issue #207)
- A-1 browser auto-open —
openBrowser()spawns platform browser (cmd /c start/open/xdg-open); failure is non-fatal with stderr warning. Present in bothmcp-server/server/index.jsandlocal-mcp/src/index.ts. - A-2 auth-required tool response —
AuthRequiredError+formatAuthRequiredResponse()returnsisError: truewithuser_code,verification_uri_complete, expiry hint, retry instruction. Polling serialized by_deviceFlowLockso repeat calls share one background flow. - docs — F7.9 + F7.10 added to
0-requirements.{md,ja.md}; installation docs rewritten for v0.11.1 first-auth experience. - version bump — 0.11.1 across
manifest.json/package.json/server.json. - tests —
auth-required.test.mjs(5) + existingmigration.test.mjs(5) = 10/10 pass. CI all green.
Scope deviations
None.
Later / non-blocking
Browser-open failure path still produces the "browser should have opened" phrasing in the tool response. A future pass could thread a success flag into formatAuthRequiredResponse() to adjust wording conditionally. Not a merge blocker.
Next
Mode = auto: no external human review required. Proceeding to merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #207
要約
v0.11.0 で導入した device authorization grant の初回認証 UX を修復する。
背景
v0.11.0 では
user_codeとverification_uriを stderr にのみ書き出し、その後 600 秒の polling を同期でブロックしていた。Claude Code / Claude Desktop は MCP サーバの stderr をチャット UI に露出しないため、ユーザからは「ツールが何も返さずに 10 分後にタイムアウトするだけ」の状態に見えていた。変更内容
mcp-server/server/index.js と local-mcp/src/index.ts(同じ設計で揃えた)
performOAuthFlow()を 2 段階に分割:/oauth/device_authorizationで device code を取得し、_pendingDeviceAuthに格納。verification_uri_complete優先でブラウザ自動オープン、stderr ログ出力。/oauth/tokenの polling をバックグラウンドで継続(_deviceFlowLockで多重実行を直列化)。getAccessTokenForToolCall()を追加:AuthRequiredErrorを throw、ハンドラがisError: trueの構造化応答を返す。2 回目以降の tool call も承認完了前なら同じメッセージ(ポーリングは 1 本を共有)。child_process.spawnで platform 別にcmd /c start/open/xdg-openを呼ぶ。失敗は stderr 警告のみで fatal にしない。connectWebSocket()は従来通り blockinggetAccessToken()を使う(UI を止めないバックグラウンド接続のため)。docs
docs/0-requirements.md/docs/0-requirements.ja.md:isError: true応答仕様と polling serializedocs/installation.md/docs/installation.ja.md:version bump
mcp-server/manifest.json:1.0.0→0.11.1mcp-server/package.json:0.8.2→0.11.1mcp-server/server.json:0.8.2→0.11.1(2 箇所)tests
mcp-server/test/auth-required.test.mjsを新規追加(5 件、black-box 契約テスト):verification_uri_complete優先で表示されるverification_uriとuser_codeのみexpires_at不在時は残り時間ヒントを省略isError: trueが立つmigration.test.mjsは 5 件 pass のまま無回帰。影響範囲
検証
node --check server/index.js: OKnode --test mcp-server/test/*.test.mjs: 10/10 passnpx tsc --noEmit(local-mcp): 型エラーなし実機検証は merge 後の CI/CD 通過と Claude Code / Desktop での初回接続挙動で確認する。