Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
2306fb8
feat(oauth): opt-in switch and default-off gate for browser login (Sp…
Dumbris Nov 22, 2026
e0dc9b9
fix(oauth): refuse browser login in every server-edition build (Spec …
Dumbris Nov 22, 2026
bfcc550
feat(oauth): protocol logic for browser login (Spec 132 PR-1b)
Dumbris Nov 22, 2026
1251d0a
fix(oauth): tighten redirect matching and bound in-memory state (Spec…
Dumbris Nov 22, 2026
fb7d861
fix(oauth): align code and request expiry, make limiter admission ato…
Dumbris Nov 22, 2026
8f51f22
feat(oauth): storage for browser logins and one binding writer (Spec …
Dumbris Nov 22, 2026
6d74c98
test(oauth): scope the no-storage check to browser-login state (Spec …
Dumbris Nov 22, 2026
143494c
fix(oauth): harden browser-login storage after review (Spec 132 PR-1c)
Dumbris Nov 22, 2026
8ecda0a
fix(oauth): validate bindings only where a browser-login copy exists …
Dumbris Nov 22, 2026
5716d19
fix(oauth): restore pins by binding incarnation, keep connect snapsho…
Dumbris Nov 22, 2026
3bd6cdd
Merge remote-tracking branch 'origin/feat/client-oauth-login-switch' …
Dumbris Nov 22, 2026
f51b746
feat(oauth): browser-login service, client views and guard (Spec 132 …
Dumbris Nov 22, 2026
a592315
fix(oauth): close cancellation, token-endpoint and client-view gaps (…
Dumbris Nov 22, 2026
4981623
fix(oauth): close exchange/approve races and rollback guard gap (Spec…
Dumbris Nov 22, 2026
17c9397
fix(oauth): fence the exchange with config commits, atomic key creati…
Dumbris Nov 22, 2026
0761328
fix(oauth): fence refresh with config commits, complete key-file fall…
Dumbris Nov 22, 2026
dc01d1a
feat(oauth): browser-login endpoints and access-token auth (Spec 132 …
Dumbris Nov 22, 2026
6c66382
fix(oauth): close stream, cross-site and contract gaps after review (…
Dumbris Nov 23, 2026
f08df21
fix(oauth): end blocked streams on revoke, cancel across quick off/on…
Dumbris Nov 23, 2026
b89b95d
fix(oauth): order the disable epoch, per-run stream tracking (Spec 13…
Dumbris Nov 23, 2026
3f8eacb
fix(oauth): bump the disable epoch only on publish, bind streams to a…
Dumbris Nov 23, 2026
ff2b6e7
test(oauth): end-to-end script, docs and real-client record for brows…
Dumbris Nov 23, 2026
b62f508
test(oauth): harden the browser-login e2e script, correct docs (Spec …
Dumbris Nov 23, 2026
133210d
test(oauth): real-shaped forged tokens, isolate the manual check (Spe…
Dumbris Nov 23, 2026
44ac406
docs(oauth): qualify the server-edition 404 (Spec 132 PR-1f)
Dumbris Nov 23, 2026
5c0b698
docs(oauth): record the Claude Code real-client check (Spec 132 PR-1f)
Dumbris Nov 23, 2026
f118305
feat(oauth): consent page for browser login (Spec 132 PR-2a)
Dumbris Nov 23, 2026
60723ab
fix(oauth): consent page review round 1, backend (Spec 132 PR-2a)
Dumbris Nov 23, 2026
94fb487
fix(oauth): consent page review round 1, page and replace ownership (…
Dumbris Nov 23, 2026
db9a666
fix(oauth): consent page review round 2 (Spec 132 PR-2a)
Dumbris Nov 23, 2026
313f261
fix(oauth): consent page review round 3 (Spec 132 PR-2a)
Dumbris Nov 23, 2026
fef8406
fix(oauth): consent page review round 4 (Spec 132 PR-2a)
Dumbris Nov 23, 2026
0a0cd93
fix(oauth): consent page review round 5 (Spec 132 PR-2a)
Dumbris Nov 23, 2026
09b8281
test(oauth): Playwright spec for the consent page (Spec 132 PR-2a, T061)
Dumbris Nov 23, 2026
a0a84a8
fix(oauth): consent page security review fixes (Spec 132 PR-2a)
Dumbris Nov 23, 2026
4a2f24e
fix(oauth): normalise the initialize name like the registered name (S…
Dumbris Nov 23, 2026
ee47435
feat(oauth): manage browser logins in Clients hub, CLI and MCP (Spec …
Dumbris Nov 23, 2026
8a407ea
fix(oauth): refuse blank login ids and lock the revoke dialog while i…
Dumbris Nov 23, 2026
5bba11c
Merge origin/main into feat/client-oauth-login-storage
Dumbris Nov 23, 2026
2f17cd2
Merge storage slice and main into feat/client-oauth-login-runtime
Dumbris Nov 23, 2026
7c19092
test(oauth): fixture credential expiry follows the real clock (Spec 1…
Dumbris Nov 23, 2026
4f99a0f
feat(tray): approve browser sign-in requests from the tray (Spec 132 …
Dumbris Nov 23, 2026
97a6068
fix(tray): sign-in requests survive neither stale reloads nor reconne…
Dumbris Nov 23, 2026
6aaa317
fix(tray): a decision for an unknown request still invalidates an in-…
Dumbris Nov 23, 2026
5b20ad1
Merge origin/main into feat/client-oauth-login-runtime
Dumbris Nov 23, 2026
a133327
Merge runtime slice and main into feat/client-oauth-login-http
Dumbris Nov 23, 2026
05e5080
test(auth): skip the key-file mode check on Windows (Spec 132 PR-1d)
Dumbris Nov 23, 2026
b90a6f8
test(storage): repin order test no longer depends on hash luck (Spec …
Dumbris Nov 23, 2026
54653b3
Merge runtime slice into feat/client-oauth-login-http
Dumbris Nov 23, 2026
41a51a6
Merge origin/main into feat/client-oauth-login-http
Dumbris Nov 23, 2026
fed24cd
Merge http slice into feat/client-oauth-login-e2e
Dumbris Nov 23, 2026
db811ed
Merge e2e slice into feat/client-oauth-login-consent
Dumbris Nov 23, 2026
9abd1c1
chore: drop review scratch files committed by mistake (Spec 132 PR-2b)
Dumbris Nov 23, 2026
9e6e6f7
Merge consent slice into feat/client-oauth-login-hub
Dumbris Nov 23, 2026
8251402
Merge hub slice into feat/client-oauth-login-tray
Dumbris Nov 23, 2026
1c10156
fix(server): a stopped run no longer stops or unmarks the next run (S…
Dumbris Nov 23, 2026
bc5ae6f
fix(server): a stop in progress leaves a newly started run alone (Spe…
Dumbris Nov 23, 2026
c247595
Merge remote-tracking branch 'origin/feat/client-oauth-login-http' in…
Dumbris Nov 23, 2026
82da502
Merge remote-tracking branch 'origin/main' into feat/client-oauth-log…
Dumbris Nov 23, 2026
88bb54d
Merge remote-tracking branch 'origin/feat/client-oauth-login-e2e' int…
Dumbris Nov 23, 2026
34994a6
docs: trim the oldest Recent Changes entries from CLAUDE.md
Dumbris Nov 23, 2026
9811711
Merge remote-tracking branch 'origin/feat/client-oauth-login-e2e' int…
Dumbris Nov 23, 2026
6abbf43
Merge remote-tracking branch 'origin/main' into feat/client-oauth-log…
Dumbris Nov 23, 2026
e44f61b
Merge remote-tracking branch 'origin/feat/client-oauth-login-consent'…
Dumbris Nov 23, 2026
6d31703
test(oauth): run the consent spec in the Web UI sweep (Spec 132 PR-2a)
Dumbris Nov 23, 2026
16a09f5
Merge remote-tracking branch 'origin/feat/client-oauth-login-consent'…
Dumbris Nov 23, 2026
a72e91a
Merge remote-tracking branch 'origin/main' into feat/client-oauth-log…
Dumbris Nov 23, 2026
99c3659
Merge remote-tracking branch 'origin/feat/client-oauth-login-hub' int…
Dumbris Nov 23, 2026
e7b5b0b
Merge remote-tracking branch 'origin/main' into feat/client-oauth-log…
Dumbris Nov 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions docs/features/client-oauth-login.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,29 @@ handed over. Everything the app reports is shown as plain text.
- Without the admin API key in this browser the page asks you to open the request from the
MCPProxy tray or paste the key, and makes no request until then.

### From the macOS tray

The tray is the way to reach the consent page with the key in the browser. When an MCP client
asks to sign in, the core publishes `oauth.authorization_pending`; the tray then

- sends one notification ("Sign-in request") naming the app, and
- adds a menu row **Approve sign-in for \<app\>…** per waiting request, newest first (five rows,
the rest in a "N more sign-in requests" submenu).

The row opens `/ui/authorize?request=<id>` the way "Open Web UI in Browser" opens the Web UI (the
API key travels in the same `?apikey=` parameter, which the page moves into local storage). The
tray never approves or denies anything itself; the decision is made on the page.

A row disappears when the request is decided (`oauth.authorization_decided`) or expires (10
minutes). On connect, reconnect and every periodic refresh the tray reloads
`GET /api/v1/oauth/authorizations`, so a request made while the tray was not listening still
shows, and stale ones are dropped. While browser login is off the endpoint answers `404
feature_disabled` and the tray shows nothing.

The app name is chosen by the client, so the tray treats it as untrusted text: control and
invisible characters are removed, white space is collapsed, it is cut to 40 characters, and it is
only ever shown as plain text.

## Managing logins

Everything here is for administrators. An agent token or a client credential cannot see
Expand Down
110 changes: 110 additions & 0 deletions e2e/web-ui-sweep/client-oauth-consent.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,113 @@ test('h. the consent page is never framed (any case)', async ({ request }) => {
expect(res.headers()['x-frame-options'], path).toBe('DENY')
}
})

// ---------------------------------------------------------------------------
// Spec 132 T061 (web part): /ui/clients credential list and revoke, and the
// browser-login switch on /ui/settings. The core is expected to hold
// `mcp_oauth_enabled` in its config (not only through MCPPROXY_MCP_OAUTH_ENABLED,
// which locks the Settings switch).
// ---------------------------------------------------------------------------

// A client with an API key (POST /clients) that signed in once through the page.
async function clientWithLogin(page: Page, suffix: string): Promise<string> {
await catchCallback(page)
const id = `e2e-hub-${suffix}-${randomBytes(3).toString('hex')}`
const created = await admin('/clients', { method: 'POST', body: JSON.stringify({ id, display_name: `Hub ${suffix}` }) })
expect(created.status, await created.clone().text()).toBeLessThan(300)
const p = await startSignIn(`Hub ${suffix} app`, `/mcp/oauth/${id}`, `state-${suffix}`)
await page.goto(p.requestUrl)
await t(page, 'authorize-approve').click()
await page.waitForURL(/127\.0\.0\.1:54321\/callback/)
await exchange(p, new URL(page.url()).searchParams.get('code') || '')
expect(await loginCount(id)).toBe(1)
return id
}

async function credentials(client: string): Promise<any[]> {
const res = await admin(`/clients/${client}`)
expect(res.status).toBe(200)
return (await res.json()).data?.credentials || []
}

async function openClient(page: Page, id: string) {
await page.goto(`${BASE}/ui/clients`)
await t(page, `client-expand-${id}`).click()
await expect(t(page, `client-credentials-${id}`)).toBeVisible()
}

test('i. /ui/clients lists the API key and the login; revoking the API key alone leaves the login', async ({ page }) => {
await withKey(page)
const id = await clientWithLogin(page, 'key')
await openClient(page, id)
await expect(t(page, 'credential-api_key')).toBeVisible()
const loginRow = page.locator('[data-test^="credential-login-"]')
await expect(loginRow).toHaveCount(1)
await expect(t(page, 'credential-reported-name')).toContainText(/hub key app/i) // the core normalises the reported name
await shot(page, 'i-clients-credentials')

await t(page, 'revoke-api-key').click()
await shot(page, 'i-revoke-api-key-dialog')
await t(page, 'revoke-credential-confirm').click()
await expect(t(page, 'revoke-api-key')).toHaveCount(0)
await expect(t(page, 'credential-state-api_key')).toContainText('revoked')

const creds = await credentials(id)
expect(creds.find((c) => c.kind === 'api_key')?.state).toBe('revoked')
expect(creds.filter((c) => c.kind === 'browser_login' && c.state === 'active')).toHaveLength(1)
await expect(loginRow.locator('[data-test^="revoke-login-"]')).toBeVisible()
})

test('j. /ui/clients revokes one login through the dialog; Cancel changes nothing', async ({ page }) => {
await withKey(page)
const id = await clientWithLogin(page, 'login')
await openClient(page, id)
const revoke = page.locator('[data-test^="revoke-login-"]')
await expect(revoke).toHaveCount(1)
await revoke.click()
await t(page, 'revoke-credential-cancel').click()
expect(await loginCount(id)).toBe(1)

await revoke.click()
await shot(page, 'j-revoke-login-dialog')
await t(page, 'revoke-credential-confirm').click()
await expect(revoke).toHaveCount(0)
expect(await loginCount(id)).toBe(0)
// the API key is untouched
expect((await credentials(id)).find((c) => c.kind === 'api_key')?.state).toBe('active')
await expect(t(page, 'credential-api_key')).toBeVisible()
await shot(page, 'j-after-revoke')
})

test('k. /ui/settings shows the browser-login switch with its badge; toggling it changes mcp_oauth_enabled', async ({ page }) => {
await withKey(page)
const enabled = async () => ((await (await admin('/config')).json()).data?.config?.mcp_oauth_enabled ?? false) as boolean
expect(await enabled(), 'start the scratch core with "mcp_oauth_enabled": true in its config').toBe(true)

await page.goto(`${BASE}/ui/settings?tab=security`)
const row = t(page, 'setting-row-mcp_oauth_enabled')
await expect(row).toBeVisible()
await expect(t(page, 'setting-badge-mcp_oauth_enabled')).toHaveText('Experimental')
await expect(row).toContainText('Browser login for MCP clients')
const toggle = t(page, 'setting-toggle-mcp_oauth_enabled')
await expect(toggle).toBeChecked()
await shot(page, 'k-settings-on')

const save = async () => {
await page.getByRole('button', { name: 'Save changes' }).first().click()
await sleep(1500)
}
await toggle.uncheck()
await save()
expect(await enabled()).toBe(false)
// off needs no restart and hides the OAuth paths again
expect((await fetch(`${BASE}/.well-known/oauth-authorization-server`)).status).toBe(404)
await shot(page, 'k-settings-off')

await page.reload()
await expect(t(page, 'setting-toggle-mcp_oauth_enabled')).not.toBeChecked()
await t(page, 'setting-toggle-mcp_oauth_enabled').check()
await save()
expect(await enabled()).toBe(true)
expect((await fetch(`${BASE}/.well-known/oauth-authorization-server`)).status).toBe(200)
})
10 changes: 10 additions & 0 deletions native/macos/MCPProxy/MCPProxy/API/APIClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,16 @@ actor APIClient {
return try await fetchWrapped(path: "/api/v1/attention")
}

/// Pending browser sign-in requests (Spec 132). `nil` while the feature is
/// off (the core answers 404 `feature_disabled`), so the tray shows nothing.
func signInRequests() async throws -> [SignInWire.Summary]? {
do {
return try await fetchWrapped(path: "/api/v1/oauth/authorizations")
} catch APIClientError.httpError(let status, _) where status == 404 {
return nil
}
}

func reviewQueue() async throws -> ReviewQueueResponse { try await fetchWrapped(path: "/api/v1/review") }
func serverReview(_ name: String) async throws -> ServerReviewResponse { try await fetchWrapped(path: "/api/v1/servers/\(Self.escapePathComponent(name))/review") }
func startSecurityScan(_ id: String) async throws { try await postAction(path: "/api/v1/servers/\(Self.escapePathComponent(id))/scan") }
Expand Down
56 changes: 56 additions & 0 deletions native/macos/MCPProxy/MCPProxy/Core/CoreProcessManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1782,6 +1782,26 @@ actor CoreProcessManager {
// Spec 108-f: a client's binding, credential or lock changed.
scheduleClientsRefresh()

case "oauth.authorization_pending":
// Spec 132: an MCP client asked to sign in. The tray lists it and
// notifies once; approval happens on the Web UI page.
guard let pending = SignInWire.decodePending(event.data) else { break }
let label = SignInPresentation.sanitizedLabel(pending.clientLabel)
let isNew = await MainActor.run {
// An event of an earlier stream belongs to a core we left.
appState.isCurrentConnection(generation)
&& appState.addSignInRequest(id: pending.requestID, rawLabel: pending.clientLabel)
}
if isNew {
await notificationService.sendSignInRequest(requestId: pending.requestID, clientLabel: label)
}

case "oauth.authorization_decided":
guard let decided = SignInWire.decodeDecided(event.data) else { break }
await MainActor.run {
if appState.isCurrentConnection(generation) { appState.removeSignInRequest(id: decided.requestID) }
}

case "ping":
// Keepalive; no action needed
break
Expand Down Expand Up @@ -1961,6 +1981,7 @@ actor CoreProcessManager {
await refreshClients()
await refreshAttention()
await refreshReviewQueue()
await refreshSignInRequests()
// Bump activityVersion so ActivityView reloads. Still needed after the
// glance's SSE work: the bus emits `activity.tool_call.completed` and
// `activity.internal_tool_call.completed` (internal/runtime/events.go),
Expand Down Expand Up @@ -2044,6 +2065,41 @@ actor CoreProcessManager {
}
}

/// Reload the pending browser sign-in requests (Spec 132): on connect and
/// reconnect, so a request made while the tray was not listening still
/// shows, and on the periodic tick, which also drops expired ones. A core
/// with the feature off (404) leaves nothing listed.
/// Test seam: replaces the GET (nil = use `apiClient`).
private var signInRequestsFetcher: (@Sendable () async throws -> [SignInWire.Summary]?)?

func setSignInRequestsFetcher(_ fetcher: (@Sendable () async throws -> [SignInWire.Summary]?)?) {
signInRequestsFetcher = fetcher
}

func refreshSignInRequests() async {
// An SSE event that lands while the GET is in flight, or a reconnect,
// makes the answer stale (see `AppState.applySignInReload`): fetch again.
for _ in 0..<3 {
let ticket = await MainActor.run { appState.signInReloadTicket() }
let fetched: [SignInWire.Summary]?
do {
if let fetcher = signInRequestsFetcher {
fetched = try await fetcher()
} else if let apiClient {
fetched = try await apiClient.signInRequests()
} else {
return
}
} catch {
// Non-fatal; keep what is listed but drop what has expired.
await MainActor.run { appState.expireSignInRequests() }
return
}
let result = await MainActor.run { appState.applySignInReload(fetched, ticket: ticket) }
if result == .applied { return }
}
}

func refreshReviewQueue() async {
guard let apiClient else { return }
let count = (try? await apiClient.reviewQueue().count) ?? 0
Expand Down
40 changes: 40 additions & 0 deletions native/macos/MCPProxy/MCPProxy/MCPProxyApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1245,6 +1245,38 @@ final class AppController: NSObject, NSApplicationDelegate, NSWindowDelegate, NS
menu.addItem(.separator())
}

// Browser sign-in requests (Spec 132): one "Approve sign-in for <client>…"
// row per waiting request, newest first, folded into a submenu past
// `maxMenuRows`. Absent while the feature is off or nothing waits. The
// row only opens the consent page in the Web UI (admin key as for
// "Open Web UI in Browser"); the tray never decides a request.
let signInRows = SignInPresentation.menuRows(appState.signInRequests)
if appState.coreState == .connected, !signInRows.shown.isEmpty {
for request in signInRows.shown {
let item = NSMenuItem(title: SignInPresentation.menuTitle(for: request),
action: #selector(approveSignInFromMenu(_:)), keyEquivalent: "")
item.target = self
item.representedObject = request.id
item.image = NSImage(systemSymbolName: "person.badge.key", accessibilityDescription: "sign-in request")
menu.addItem(item)
}
let rest = signInRows.overflow
if !rest.isEmpty {
let more = NSMenuItem(title: "\(rest.count) more sign-in \(rest.count == 1 ? "request" : "requests")", action: nil, keyEquivalent: "")
let sub = NSMenu(title: "Sign-in requests")
for request in rest {
let item = NSMenuItem(title: SignInPresentation.menuTitle(for: request),
action: #selector(approveSignInFromMenu(_:)), keyEquivalent: "")
item.target = self
item.representedObject = request.id
sub.addItem(item)
}
more.submenu = sub
menu.addItem(more)
}
menu.addItem(.separator())
}

let reviewCount = appState.reviewQueueCount
if reviewCount > 0 {
let item = NSMenuItem(
Expand Down Expand Up @@ -1939,6 +1971,14 @@ final class AppController: NSObject, NSApplicationDelegate, NSWindowDelegate, NS
}
}

/// Open the consent page of one sign-in request (Spec 132) through the same
/// Web UI link path the other deep links use.
@objc private func approveSignInFromMenu(_ sender: NSMenuItem) {
guard let id = sender.representedObject as? String,
let path = appState.signInPath(forRequest: id) else { return }
NotificationCenter.default.post(name: .openWebUIPath, object: path)
}

@objc private func showReviewQueueFromMenu(_ sender: NSMenuItem) {
showMainWindow(tab: .review)
}
Expand Down
17 changes: 17 additions & 0 deletions native/macos/MCPProxy/MCPProxy/Services/NotificationService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,23 @@ actor NotificationService {
markDelivered(key: key)
}

/// Notify that an MCP client asks to sign in through the browser (Spec 132).
/// `clientLabel` must already be cleaned (`SignInPresentation.sanitizedLabel`).
/// The notification only points at the tray menu; approval is on the Web UI page.
func sendSignInRequest(requestId: String, clientLabel: String) async {
let key = "signin:\(requestId)"
guard shouldDeliver(key: key) else { return }

let content = UNMutableNotificationContent()
content.title = "Sign-in request"
content.body = "\(clientLabel) wants to sign in. Choose \"Approve sign-in\u{2026}\" in the MCPProxy menu."
content.sound = .default
content.userInfo = ["requestId": requestId]

await deliver(content: content, identifier: "signin-\(requestId)")
markDelivered(key: key)
}

// MARK: - Rate Limiting

/// Check whether a notification with the given key should be delivered,
Expand Down
Loading
Loading