feat(mcp): surface account identity via a whoami tool (#672) - #673
Merged
Conversation
…as (#672) Over the MCP connector a caller holds a session but has no tool that names the identity behind it. Add GET /v1/auth/me/account (gated by the session Bearer only — the row returned is always the caller's own) returning id, login, provider + label, email, roles, createdAt and this token's expiry, and a `whoami` MCP tool that reads it. provider is derived from the uid the OAuth callbacks mint: `google:<id>` is Google, a bare numeric id is GitHub. email is surfaced only for Google, whose sign-in stores the address in github_login; a GitHub login is a username and comes back as `login`, never email. No migration — nothing new is stored. Unlike the ProAppStore original (#138) this needs no internal-token second gate: PAGS does not de-privilege an MCP-origin session and does not ship this shape into creator-controlled app JS, so there is no leak for that gate to close. Tool-count bookkeeping: MCP_TOOL_COUNT 135->136, ALWAYS_ON 117->118, the contract-test golden row, the README tool table, the swept doc claims (mcp.md, llms-full, about, CLAUDE.md) and the OpenAPI spec. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
serge-ivo
force-pushed
the
feat/mcp-whoami-account-identity
branch
from
August 16, 2026 02:06
61507e3 to
69c6af7
Compare
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 #672.
Problem
Over the MCP connector a user cannot find out which account they are connected as. The session is verified but nothing names the identity behind it — there is no
whoamitool (it exists only as a CLI command), and no API endpoint returns the identity in a compact shape.GET /v1/auth/meis the SDK-ish profile shape (name/avatar/subscription/board), not an identity answer.What this adds
GET /v1/auth/me/account→id,login,provider,providerLabel,email,roles,createdAt,tokenExpiry. Gated by the sessionBeareronly (requireUser, which also applies the live suspension check). The row returned is always the caller's own — there is no lookup-by-id parameter to abuse.whoamitool (in theaccountgroup) — ungatedread, no dry-run, mirrorsbilling_status/keys_status; justauthedCall("/v1/auth/me/account").provideris derived from the uid the OAuth callbacks mint:google:<id>→ Google, a bare numeric id → GitHub.emailis surfaced only for Google, whose sign-in stores the address ingithub_login; a GitHubgithub_loginis a username, returned aslogin, neveremail. No migration — nothing new is stored.Why no internal-token gate (unlike ProAppStore #138)
The PAS original guards this behind a second
X-Internal-Tokengate because PAS ships the identity shape into creator-controlled app JS (the SDKUsercontract) and de-privileges MCP-origin sessions to['user']. PAGS does neither — it has no SDKUsercontract carrying this, and does not de-privilege MCP sessions — so that gate would be net-new plumbing guarding a leak PAGS does not have. PlainrequireUseris the honest gate here.Tool-count / docs bookkeeping
MCP_TOOL_COUNT135→136,MCP_TOOL_ALWAYS_ON117→118, the derivedcontract.test.tsgolden row, the README tool table, every swept doc claim (platform-docs/mcp.md,store/llms-full.txt,store/about/index.html,workers/mcp/CLAUDE.mdincl. the per-fileaccount.tscount), and the OpenAPI spec.Tests
4 new integration tests in
auth.integration.test.ts: 401 without a bearer, 404 with no row, github-shape →emailnull, google-shape →emailsurfaced.Verified locally, all green:
pnpm typecheck(all packages),biome check, auth + MCP suites (199 tests),docs-drift.mjs,openapi-coverage.mjs,check-file-size.mjs.🤖 Generated with Claude Code