Skip to content

feat(mcp): one-click approval for a user already signed in to the site - #93

Merged
buzz-code merged 1 commit into
mainfrom
claude/mcp-session-approve
Nov 4, 2026
Merged

buzz-code merged 1 commit into
mainfrom
claude/mcp-session-approve

Conversation

@buzz-code

Copy link
Copy Markdown
Owner

Requested by הדסה · project thread

The MCP login page always asked for email and password, even when the browser was already signed in to the site.

How it works

  • The site cookie (Authentication, SameSite=Strict) isn't sent on the AI app's redirect to /authorize, but it is on same-site requests. So the page calls POST /mcp/oauth/session from a script. When the user is signed in, it shows "אישור בתור ", which posts to POST /mcp/oauth/approve.
  • McpOAuthProvider.sessionUser verifies the cookie JWT with JWT_SECRET and loads the user. It refuses impersonated sessions and admins, the same rule as the password login.

Security

  • CSRF: both endpoints require Origin to equal this server's base URL. The cookie is SameSite=Strict as well, so another site can't approve or read the name.
  • Clickjacking: the login page sends frame-ancestors 'none' and X-Frame-Options: DENY.
  • Consent phishing: client_name is self-registered, so the page also shows the host of the redirect URI the user returns to.
  • The password form is unchanged.

Tests

  • New cases cover: one-click approval through the token exchange to a tool call; refused with no cookie, a foreign or missing Origin, an impersonated session, an admin, or a forged cookie; the session endpoint is same-origin only; the page can't be framed.
  • jest shared/mcp src/mcp-tools passes (55 tests), and tsc is clean. Both were run from dnd-management-nra.
  • Checked in Chromium: the button appears only when the session call returns a name, and the approve POST carries the page's Origin.

Fixes buzz-code/ops#47


Generated by Claude Code

The MCP login page asks /mcp/oauth/session (same-origin, so the site's
SameSite=Strict cookie is sent) and, when signed in, offers "approve as
<name>" posting to /mcp/oauth/approve. Approve requires a matching Origin
and a valid site cookie; admins and impersonated sessions get the form.
The page can't be framed and shows the host it returns to.

Refs buzz-code/ops#47

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012GTicqnHNZPYxcmrvzQsZs
@buzz-code buzz-code self-assigned this Nov 4, 2026
@buzz-code
buzz-code merged commit 68730a0 into main Nov 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants