Repository navigation
app/: /mcp/admin and the staff-only admin OAuth scope, ported from the Loco server (sc-8900) - #145
Merged
Merged
Conversation
…uth scope, ported from the Loco server (sc-8900) - /mcp/admin with the old server's 12 tools (list_feedback, get_feedback, find_user, find_org, get_org, recent_failures, list_emails, resolve_email, set_open_source_withdrawn, set_plan, mark_feedback_handled, rerun_build) and the 5 shared read tools for any organization; writes need a reason; every call goes to admin_audit; customer text under untrusted_customer_data. - OAuth: two resources (/mcp with mcp, /mcp/admin with admin), each advertising its own scope. The consent step grants admin only to staff and only on the admin resource; mcp alone on /mcp. - /mcp now accepts MCP clients' OAuth access tokens (vca_), which it refused before. Co-authored-by: Claude <noreply@anthropic.com>
ndbroadbent
force-pushed
the
app-staff-admin-mcp
branch
from
December 3, 2026 18:21
98770a7 to
4629ca6
Compare
…nsaction, an admin consent warning with the redirect host, and tighter tools (sc-8900) - A call and its admin_audit row run in one transaction: a row that can't be written undoes the call. - The admin consent page warns what admin access can do and shows the host the person is sent back to. - An approval the OAuth server can't read is refused by the consent check too. - resolve_email needs a real reason; find_user and find_org take % and _ literally and refuse an empty query; get_feedback can't overflow; rerun_build takes only builds stuck over 30 minutes; set_plan refuses an organization with a Stripe subscription. Co-authored-by: Claude <noreply@anthropic.com>
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.
Ports the Loco server's staff admin MCP endpoint and the staff-only
adminOAuth scope into app/ (sc-8900, before sign-ups open). It's the first of three PRs. The staff commands and the credit override come in separate PRs./mcp/admin(app/src/mcp/admin.rs)The tools have the same names, arguments and answers as the old
server/src/mcp/admin.rs(git show 0788198^:server/src/mcp/admin.rs):list_feedback,get_feedback,find_user,find_org,get_org(with billing and usage),recent_failures,list_emails.reason:set_plan,mark_feedback_handled,rerun_build(only a build stuck processing),resolve_email(retry or dismiss),set_open_source_withdrawn.get_project,list_builds,get_build,get_snapshot,snapshot_history. Staff act as an admin there (Via::Admin), and the answer starts with the untrusted-customer-data note.admin_auditrow (user, OAuth client, agent, tool, arguments, reason, ok). Customer-written text comes back underuntrusted_customer_data.auth::staff::feedback_page,resolve_failed).The admin scope (
app/src/auth/oauth.rs)<mcp url>/mcp(scopemcp) and<mcp url>/mcp/admin(scopeadmin). Each one's metadata advertises only its own scope. The admin resource is added automatically next to every/mcpresource, soOAUTH_RESOURCESneeds no change.consent_scopes(web group, after the session) decides first, as the oldgranted_scopesdid:adminalone on the admin resource and only for staff,mcpalone on/mcp.mcp adminon/mcpgetsmcponly.admin, for someone who is still staff (403 once they aren't).vcu_) and project (vci_) tokens get a 401 saying they don't work there, even a staff member's. That matches the old server, which never let personal tokens use/mcp/admin.Fix: OAuth tokens on
/mcp/mcphad no check for OAuth access tokens: thePrincipalextractor only knows sessions andvcu_/vci_tokens, and no test called/mcpwith avca_token. So I believe MCP clients connected over OAuth were refused with 401.mcp::handlenow verifiesvca_tokens for<mcp url>/mcpwith themcpscope. A revoked token gets theinvalid_tokenchallenge. Test:an_oauth_token_reaches_mcp_as_its_person.Tests
app/tests/mcp_admin.rs, through the real flow (registration, consent page, approval, token exchange):/mcp/admin, and a tampered approval is refused.app/tests/golden/mcp_admin/, in the public MCP's golden style.Gates on the build box:
cargo fmt --all --check,cargo clippy --locked --workspace --all-targets -- -D warningsandcargo test --locked --workspaceall pass.VisualCI build
The new golden files are JSON snapshots, so the build should show new
mcp_admin/...JSON snapshots and no other changes.Docs: design.md's "Admin tools" section now describes what exists (the "app/ doesn't serve it yet" note is gone).
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.Review fixes (second commit)
db::transactiontogether with itsadmin_auditinsert. Every query joins it, including job dispatches on the database queue. If the audit row can't be written, the call's change is rolled back and the agent gets "this call failed, or couldn't be recorded in the audit log, so nothing was changed". Test: with a CHECK constraint that rejectsmark_feedback_handledaudit rows, the call returns that error, the feedback stays unhandled and the audit table gains no rows.warningstyle: "Admin access. This app could read every organization's data, change plans, re-run builds and resolve customers' emails and feedback, as you." It also shows the redirect host prominently ("After you allow it, you're sent to127.0.0.1:9999"). The/mcpconsent page is unchanged. Test:the_admin_consent_page_warns_and_names_the_redirect_host.resolve_emailuses the same reason check as the other writes.find_userandfind_orgescape%,_and backslashes, and refuse an empty query.get_feedbackuseschecked_add.rerun_buildonly takes builds still processing 30 minutes after they were finalized, asrecent_failurescounts them.set_planrefuses an organization with a Stripe subscription: "... pays for its plan through Stripe (subscription ...); setting it here would leave Stripe billing them. Change or cancel the subscription in Stripe instead". I chose a refusal over changing the plan and leaving Stripe billing them.find_user-2/-3,set_plan-4,rerun_build-3. The existing goldens are unchanged.-D warningsandcargo test --locked --workspaceall pass.