Fix Stripe sk_live keys left in MCP or agent config
Updated · Applies to: Stripe, Cursor, Claude, Claude Code, MCP, VS Code, Codex, ChatGPT
TL;DR fix: If a full-access sk_live_ (or unrestricted sk_test_) lived in mcp.json, Claude Desktop config, shell history, or an npx @stripe/mcp --api-key= flag, treat it as exposed: rotate or expire it in the Stripe Dashboard, remove every copy from config and history, then reconnect to Stripe's hosted MCP at https://mcp.stripe.com with OAuth (interactive clients) or an Agent-tagged API key passed as a Bearer token from an env var—never inline. Stripe deprecated the local @stripe/mcp / @stripe/agent-toolkit packages (no further updates, including security fixes) and will stop accepting full-access secret keys and non-Agent restricted keys on MCP after November 30, 2026.
Steps
- Find every place the key was written. Search mcp.json (Cursor ~/.cursor/mcp.json, project .mcp.json, Claude Desktop config, VS Code .vscode/mcp.json), shell history, CI logs, and screenshots for sk_live_, sk_test_, rk_live_, --api-key=, and npx @stripe/mcp. Assume anything that sat in plaintext was copied.
- Rotate or expire the exposed key. In the Stripe Dashboard → Developers → API keys, rotate or expire the compromised secret or restricted key. Prefer rotating with a short grace window so you can cut over, then confirm the old key's request volume drops to zero before it expires. Stripe's key best-practices docs say to rotate even when you are not sure anyone saw it.
- Remove the key from config and history. Delete inline --api-key= values and pasted secrets from every MCP config. Clear or rewrite shell history that logged the command. If the key was committed to git, remove it from history and treat the commit as a leak (same playbook as any other leaked API key).
- Switch to hosted Stripe MCP. Stop launching the deprecated local proxy (npx @stripe/mcp). Point your client at https://mcp.stripe.com. Preferred path: npm install -g @stripe/cli@latest && stripe agent setup, or add the hosted URL in Cursor/Claude/VS Code as documented.
- Authenticate with OAuth or an Agent API key. Interactive clients should use OAuth so you can grant and revoke access without sharing a secret. Autonomous agents should use an Agent-tagged API key from the Dashboard (look for the Agent badge), passed only as Authorization: Bearer from an environment variable—never hard-coded in mcp.json or CLI args.
- Tighten permissions and watch spend. Give the Agent key only the Stripe permissions the agent needs. Enable Stripe billing alerts / Radar as appropriate for your account, and keep per-app rate limits and spend caps on any AI routes that can trigger paid work—see our AI bill-spike fix page.
Why this shows up in vibe-coded setups
AI coding agents made it easy to wire Stripe into Cursor, Claude Code, or Claude Desktop with a one-line MCP entry. The old local pattern looked like this (do not copy it into a live config):
{
"mcpServers": {
"stripe": {
"command": "npx",
"args": ["-y", "@stripe/mcp", "--api-key=sk_live_…"]
}
}
}
That puts a full-access live secret in a file agents, other MCP servers, backups, and shell logs can read. Stripe’s own MCP docs now steer you to the hosted server at https://mcp.stripe.com and warn that after November 30, 2026, MCP will reject full-access secret keys and restricted keys without the Agent tag.
Around early November 2026, Stripe also deprecated the local npm packages (@stripe/mcp, @stripe/agent-toolkit, and related AI packages) with a notice that they receive no further updates, including security fixes. The hosted MCP server is what remains supported.
The fix
1. Rotate the exposed key in Dashboard → API keys. Use Rotate (or Expire) so the old sk_live_ / unrestricted secret stops working. Stripe’s key best practices say to rotate on exposure even when you are unsure who saw it.
2. Scrub every copy. Remove --api-key= flags and pasted secrets from MCP JSON, project docs, CI variables that were echoed in logs, and shell history. If git ever held the key, rewrite history and treat the commit as a leak—same urgency as a public AI API key. Using Claude Code? Also check .claude/settings.local.json: a “Yes, and don’t ask again” approval can save a command with the key inline—see Fix secrets leaked via Claude Code settings.local.json.
3. Point clients at hosted MCP. Cursor example from Stripe’s docs (OAuth flow after connect):
{
"mcpServers": {
"stripe": {
"url": "https://mcp.stripe.com"
}
}
}
Or install via plugin: npm install -g @stripe/cli@latest then stripe agent setup.
4. For autonomous agents, use an Agent API key from an env var (not inline). Claude Code–style shape from Stripe’s docs:
{
"mcpServers": {
"stripe": {
"type": "http",
"url": "https://mcp.stripe.com",
"headers": {
"Authorization": "Bearer ${AGENT_API_KEY}"
}
}
}
}
Create the key in the Dashboard (Agent badge), grant only the permissions the agent needs, test in a sandbox, then expire the old key.
5. Watch for abuse after rotation. Check Stripe request logs and your webhook signature setup if fulfillment looks wrong. Keep AI-route rate limits and spend caps in place so a second leaked provider key cannot drain the unrelated model bill.
Checklist
- No
sk_live_/ unrestrictedsk_test_in anymcp.jsonor Desktop config - No
npx @stripe/mcp --api-key=startup entries left behind - Exposed key rotated or expired; old key request volume is zero
- Client uses
https://mcp.stripe.comwith OAuth or Agent key via env Bearer - Agent key permissions are least-privilege; OAuth sessions reviewed under user settings
- Billing alerts on; AI spend caps still set if the app calls models
Key also in your app’s JavaScript bundle or git history? Follow the Stripe steps in our leaked-keys guide (rotate with expiration Now, move it to a server-side secret, re-search the live bundle).
Prompt for Cursor, Claude Code, or Codex
Search this machine's MCP configs (Cursor mcp.json, project .mcp.json, Claude
Desktop config, VS Code mcp.json) and this repo for Stripe secrets: sk_live_,
sk_test_, rk_live_, --api-key=, and npx @stripe/mcp. List every file path that
still contains a secret or the deprecated local proxy. Do NOT print full key
values—redact after the first 8 characters. Then rewrite each Stripe MCP entry
to use url https://mcp.stripe.com with OAuth (no secret in the file) or
Authorization Bearer from an environment variable named for an Agent API key.
Remind me to rotate any key that was found in plaintext via the Stripe Dashboard. When to get help
Get help if a live sk_live_ key was in a shared repo or chat log, if you see unfamiliar Stripe API traffic after rotation, or if you need a Rescue Report to hunt other secrets agents left in config. Do not paste the key into email or chat when asking for help—rotate it first.
Want us to look at your app?
VibeCPR Rescue Reports are launching soon: we scan your repo and live app, and a human verifies every critical finding. Join the waitlist for early access and founder pricing. You'll also get Patch Notes, our weekly fixes newsletter.
FAQ
Is it safe to put sk_live_ in mcp.json or pass --api-key= to npx @stripe/mcp?
No. Full-access secret keys in MCP config, CLI args, or logs are readable by the agent runtime, other tools on the machine, and anyone with the file. Stripe's current MCP docs show the hosted URL https://mcp.stripe.com with OAuth or an Agent API key as a Bearer token from an env var—not an inline sk_live_.
What happened to @stripe/mcp and @stripe/agent-toolkit?
Stripe marked the local packages deprecated: @stripe/mcp, @stripe/agent-toolkit, stripe-agent-toolkit (Python), @stripe/ai-sdk, and @stripe/token-meter. Official package and repo notices say they will receive no further updates, including security fixes. Connect clients to the hosted server at https://mcp.stripe.com instead. npm package metadata for @stripe/mcp shows a 0.3.4 publish dated 2026-11-04 carrying that deprecation notice.
What is the November 30, 2026 Stripe MCP deadline?
Per Stripe's MCP documentation, migrate API key authentication by November 30, 2026. Starting in December 2026, Stripe MCP stops accepting full-access secret keys and restricted API keys that lack the Agent tag. Unsupported keys get a 401 with an OAuth discovery challenge. Use OAuth or a newly created Agent API key.
OAuth vs Agent API key—which should I use?
Use OAuth for interactive MCP clients (Cursor, Claude Desktop, Claude Code /mcp sign-in): you authorize in the browser and can revoke the session later. Use an Agent-tagged API key only for autonomous clients that cannot complete OAuth; pass it as a Bearer token from an environment variable and keep permissions minimal.
I already rotated the key. Do I still need to change my MCP config?
Yes. A new sk_live_ pasted back into mcp.json recreates the same exposure. Move to https://mcp.stripe.com with OAuth or an Agent key via env var, and delete the old npx @stripe/mcp --api-key= entry so the retired local proxy is not started again.
Could a leaked Stripe key also run up AI or hosting bills?
A Stripe secret is for Stripe API access (charges, customers, payouts, and so on), not your OpenAI/Anthropic bill. Separately, if AI provider keys or unauthenticated AI routes are exposed, you can get a surprise model bill—see our rate-limit and spend-cap fix. After any secret leak, rotate first, then audit other keys in the same config files.
Sources
- Stripe docs: Model Context Protocol (MCP)
- Stripe docs: API keys (rotate / expire)
- Stripe docs: Best practices for managing secret API keys
- Stripe docs: Restricted API keys
- npm: @stripe/mcp (deprecated local proxy)
- npm: @stripe/agent-toolkit (deprecated)
- GitHub MCP Registry: Stripe (deprecation notice)
Related fixes
- AI agent pushed API keys to GitHub? git commit --no-verify skipped your pre-commit hook
- Fix a surprise AI API bill: rate limits and spend caps
- Your app is public to anyone with the link: a share link is not a login
- Triage Bolt's "RLS Policy Always True" warning: when it's fine and how to fix it
- Fix secrets leaked via Claude Code .claude/settings.local.json
- Fix "Your Cloud Firestore database has insecure rules" (Firebase email)
- Login lockout keyed only on email? Rate-limit by IP and account without locking users out
- Fix Lovable "Invalid API key" after rotating Supabase keys (anon, publishable, secret)
- Lovable won't publish because of security findings? What each finding means and how to fix it
- "Sign in with Google" lets anyone in: restrict who can use your app (allowlist, domain check, RLS)
- Fix Stripe webhook "No signatures found matching the expected signature for payload"
- Fix Supabase auth redirecting to localhost after deploy
- Fix Supabase Edge Function "blocked by CORS policy" (preflight)
- Fix Supabase "infinite recursion detected in policy for relation" (42P17) in RLS
- Form says success but no row in Supabase (or Stripe webhook returns 200 but writes nothing)
- Fix "new row violates row-level security policy for table" (Supabase)
- Supabase only returns 1,000 rows? Fix the silent max rows limit in Lovable and Bolt apps
- Fix Supabase "permission denied for table" (42501) on new tables after Oct 30, 2026
- Fix a Supabase public Storage bucket that lets anyone list or download your files
- Supabase Realtime leaking rows or not receiving changes: fix RLS and the publication
- Supabase RLS not working on the server? Your API uses the service_role or secret key
- Fix Supabase RLS policy USING (true) that makes a table publicly readable
- Your app's rules only live in the frontend: move them into Supabase
- Fix a Supabase SECURITY DEFINER function anyone can call through /rest/v1/rpc
- Fix Supabase .single() "JSON object requested, multiple (or no) rows returned" (PGRST116)
- Stop Supabase users from upgrading their own plan or making themselves admin
- Fix a Supabase view that bypasses RLS: security_invoker and revoking anon write grants
- Fix "404: NOT_FOUND" on refresh in a React/Vite app on Vercel (vercel.json rewrite)
- Fix "Module not found: Can't resolve" on Vercel (works locally)
- Is my Vite dev server exposed? Check --host / server.host and patch the RCE (GHSA-p4f5-76q4-ffq7)