feat(frontend): MCP service-token auth on gas-station endpoint#62
Merged
Conversation
…ponsor Enables the MCP server (apps/mcp, PR #61) to call /api/gas-station/sponsor via a shared secret in the x-mcp-service-token header, bypassing Privy verification. Timing-safe comparison (crypto.timingSafeEqual) guards against oracle attacks. The existing Privy bearer-auth path is unchanged. Adds 4 new tests covering: valid token, mismatched token, token present but env not configured, and absent header falls through to Privy. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Summary
Enables the MCP server (
apps/mcp, PR #61) to call/api/gas-station/sponsorfor service-to-service requests using a shared secret in thex-mcp-service-tokenheader. Privy bearer auth for human users is unchanged.Why
The MCP server's onboarding flow (
create_account.complete) needs to submit gas-sponsored transactions on behalf of agents. Privy auth is for humans — agents have no Privy session. The shared-secret pattern is the simplest service-to-service path; a separate signed JWT scheme can come later if we ever expose the gas station to other internal services.Behavior
GAS_STATION_SERVICE_TOKENx-mcp-service-tokenvalidx-mcp-service-tokenmismatchx-mcp-service-tokenpresentComparison uses
crypto.timingSafeEqualto avoid timing attacks.Required env var
Add to BOTH frontend Vercel project (this) AND apps/mcp Vercel project:
Test plan
pnpm typecheckpassespnpm testpasses (existing gas-station tests + new MCP-token tests: 28 total, +4 vs baseline of 24)🤖 Generated with Claude Code