Stripe CLI for AI agents
The Stripe CLI for coding agents: forward webhooks to localhost, trigger test events, list test-mode objects, and tail API logs, never in live mode.
What Stripe CLI does for an agent
The Stripe CLI is Stripe's official tool for building and testing integrations. It forwards webhook events to a local server, triggers test events, calls the API, and tails request logs.
It works in test mode by default, which is exactly where an agent should stay: live mode needs an explicit --live flag or a live key.
Official site: stripe.com
Install Stripe CLI
The install commands from the official docs. Check it worked with stripe --version.
brew install stripe/stripe-cli/stripe
Signing in Stripe CLI for an agent
A human runs stripe login, which pairs the CLI with an account and stores test-mode keys. Non-interactive runs can pass a test-mode restricted key with --api-key or STRIPE_API_KEY.
stripe config --list
stripe login
Environment variables: STRIPE_API_KEY. Set them in the agent's environment; never paste values into prompts or commit them.
What agents use Stripe CLI for
Example commands with placeholder names. Swap in your own project, app, or file names.
Forward webhooks to a local endpoint
stripe listen --forward-to localhost:3000/api/webhooks/stripe
Long-running. Start it in the background; it prints the webhook signing secret to use locally.
Trigger a test event
stripe trigger payment_intent.succeeded
List recent test customers
stripe customers list --limit 5
Tail API request logs
stripe logs tail
Streams until stopped. Run it with a timeout.
Safety rules for agents
Safe to run without asking
stripe config --liststripe <resource> list / retrieve (test mode)stripe logs tailstripe listen
Ask a human first
anything with --live or a live keystripe refunds createstripe <resource> create / update / deletestripe events resend
- Stay in test mode. Never pass --live or use a live secret key.
- Use restricted keys with only the permissions the task needs.
- Never print or commit API keys or webhook signing secrets.
AGENTS.md or CLAUDE.md snippet
Paste this into the instruction file your agent reads at the start of every session, then adjust the rules to your setup.
## Stripe CLI (stripe) Use `stripe` for testing Stripe webhooks and API calls in test mode. - Check it is installed with `stripe --version`. If it is missing, ask before installing it. - Auth: a human signs stripe in. Check with `stripe config --list`; if it fails, stop and ask. Never run the login flow yourself, and never print tokens (STRIPE_API_KEY). - Run without asking (read-only): `stripe config --list`, `stripe <resource> list / retrieve (test mode)`, `stripe logs tail`, `stripe listen`. - Ask a human first (changes or deletes things): `anything with --live or a live key`, `stripe refunds create`, `stripe <resource> create / update / delete`, `stripe events resend`. - Stay in test mode. Never pass --live or use a live secret key. - Use restricted keys with only the permissions the task needs. - Never print or commit API keys or webhook signing secrets. - Prefer JSON output where the command supports it, and keep output short.
Stripe CLI or an MCP server?
An official MCP option exists. Stripe publishes an official MCP server, as a remote server and in its agent toolkit, for API calls and documentation search. Use it in chat clients; use the CLI for local webhook testing, which the MCP server does not do.
Rule of thumb: in a terminal agent that a human has signed in, the CLI is usually faster and cheaper in context. In a chat client without a shell, or when you want a fixed set of typed tools, use an MCP server.
Stripe CLI questions
How do I install Stripe CLI?
Homebrew: brew install stripe/stripe-cli/stripe. Check the install with stripe --version, and see the Stripe docs for other platforms.
How does an AI agent authenticate Stripe CLI?
A human runs stripe login, which pairs the CLI with an account and stores test-mode keys. Non-interactive runs can pass a test-mode restricted key with --api-key or STRIPE_API_KEY. The agent can check the sign-in with stripe config --list and should stop and ask if it fails.
Which Stripe CLI commands are safe for an agent to run?
Commands that only read state are safe to run without asking: stripe config --list; stripe <resource> list / retrieve (test mode); stripe logs tail; stripe listen. Ask a human before anything that changes or deletes something: anything with --live or a live key; stripe refunds create; stripe <resource> create / update / delete; stripe events resend.
Is there an MCP server for Stripe CLI?
Stripe publishes an official MCP server, as a remote server and in its agent toolkit, for API calls and documentation search. Use it in chat clients; use the CLI for local webhook testing, which the MCP server does not do.