npm install -g agent-cards, create a card with agent-cards cards create --amount 25, then claude mcp add agent-cards npx -y agent-cards-mcp. Claude Code now has a virtual debit card with a hard spending limit. Full setup takes 5 minutes. See the MCP specification and Anthropic MCP docs for protocol details.
Claude Code can browse the web, write code, execute shell commands, and interact with external services through MCP. One thing it cannot do out of the box is pay for things. The moment a task requires purchasing an API key, a domain name, a dataset, or a SaaS subscription, Claude hits a wall.
This guide walks through the exact steps to give Claude Code its own virtual card with a hard spending limit, connected via the AgentCard MCP server. The entire setup takes about five minutes. No credit card sharing, no API key juggling, no custom middleware.
For the broader MCP payments guide covering Claude Desktop, Cursor, and other MCP clients, see Claude MCP Payments Guide. This post is specifically about Claude Code -- the CLI agent.
What You Get
After setup, Claude Code has access to six MCP tools for payment operations:
create_card-- create a new virtual debit card with a specific amountget_card_details-- retrieve card number, CVV, and expiry for a specific cardlist_cards-- list all cards on your accountcheck_balance-- check remaining balance on a cardget_funding_status-- check if a card has been funded via Stripe Checkoutclose_card-- revoke a card immediately, declining all future transactions
Each card is a real virtual debit card, accepted anywhere Mastercard is accepted online. The card's loaded amount is a hard spending limit enforced at the Mastercard network level. Claude can spend up to that amount and no more -- no matter what instructions it receives, no matter what code it writes, no matter what happens in the session.
Prerequisites
You need:
- Node.js 18 or later installed
- Claude Code installed and working (
claudecommand available in your terminal) - A payment method for funding cards (any card or payment method supported by Stripe)
That's it. No Docker, no database, no server to host.
Step 1: Install the AgentCard CLI
$ npm install -g agent-cards
This installs the agent-cards command globally. The package is available on npm. It handles account management, card creation, balance checking, and card revocation from the terminal.
Verify the installation:
$ agent-cards --version
agent-cards/1.x.x
Step 2: Create Your Account
$ agent-cards signup
This opens a browser window for account creation. Enter your email, set a password, and you're authenticated. The CLI stores your auth token locally -- you won't need to log in again on this machine.
If you already have an account:
$ agent-cards login
Step 3: Create a Card
$ agent-cards cards create --amount 25
Card created: card_xyz789
Amount: $25.00
Status: pending_funding
Funding URL: https://checkout.stripe.com/...
The card is created but not yet funded. The CLI outputs a Stripe Checkout URL. Open it in your browser and complete the payment to fund the card. This is the human-in-the-loop step -- funding always requires human payment approval. The agent cannot create money; it can only spend what you explicitly authorize.
Once payment completes, the card status changes to active and the $25 balance is available for spending. No subscription, no monthly fees.
Check funding status:
$ agent-cards cards list
ID Amount Balance Status
card_xyz789 $25.00 $25.00 active
Step 4: Add the MCP Server to Claude Code
This is the key step. Register the AgentCard MCP server with Claude Code:
$ claude mcp add agent-cards npx -y agent-cards-mcp
This tells Claude Code to launch the agent-cards-mcp package as a stdio MCP server. The server runs locally on your machine, uses your authenticated CLI credentials, and exposes the six payment tools to Claude. For details on how MCP servers integrate with Claude, see Anthropic's MCP documentation.
No API keys to configure. No environment variables to set. The MCP server inherits your CLI authentication automatically.
Step 5: Verify the Connection
Start a new Claude Code session and verify that Claude can see the payment tools:
$ claude
You: List my agent cards.
Claude: I'll check your cards using the list_cards tool.
[Calling list_cards]
You have 1 active card:
- card_xyz789: $25.00 balance (active)
If Claude can list your cards, the MCP server is connected and working. If it can't find the tool, check that the claude mcp add command completed successfully and restart your Claude Code session.
Step 6: Use the Card
Now Claude Code can use the card to make purchases. Here's what an actual interaction looks like:
You: I need you to register the domain example-project.dev.
Use card card_xyz789 to pay for it.
Claude: I'll register that domain. Let me first check the card balance
and then proceed with the registration.
[Calling check_balance with card_id: card_xyz789]
Balance: $25.00 remaining
[Calling get_card_details with card_id: card_xyz789]
Retrieved card credentials.
I'll now navigate to the domain registrar and complete the purchase...
[completes purchase]
Domain example-project.dev registered successfully.
Total charged: $12.49
[Calling check_balance with card_id: card_xyz789]
Remaining balance: $12.51
Notice the workflow: Claude checks the balance first, retrieves card credentials only when needed, completes the purchase, and verifies the remaining balance after. The card credentials are retrieved at runtime through the authenticated MCP tool -- they are never stored in the prompt, never saved to a file, never placed in an environment variable.
After the Task: Revoke the Card
When the task is done, revoke the card. Don't leave it active with a remaining balance.
You: Close card card_xyz789, the task is done.
Claude: [Calling close_card with card_id: card_xyz789]
Card card_xyz789 has been closed. It had $12.51 remaining.
Any future transaction attempts will be declined.
Or do it from the CLI directly:
$ agent-cards cards close card_xyz789
Card closed: card_xyz789
Revocation is immediate. All future transactions on that card number are declined. This is the correct default -- cards should not outlive their tasks.
Common Patterns
Creating cards on the fly
Claude can create new cards during a session using the create_card MCP tool. The card creation returns a funding URL that you (the human) open and pay. Once funded, Claude can use the card immediately.
You: I need to buy three different API keys for the project.
Create a $10 card for each one.
Claude: [Calling create_card with amount: 10]
Card card_aaa created. Please fund it at: https://checkout.stripe.com/...
[Calling create_card with amount: 10]
Card card_bbb created. Please fund it at: https://checkout.stripe.com/...
[Calling create_card with amount: 10]
Card card_ccc created. Please fund it at: https://checkout.stripe.com/...
I've created three cards at $10 each. Please complete the funding
for each card at the URLs above, then let me know when they're ready.
This pattern gives you per-task card isolation even within a single session. Each API key purchase gets its own card with its own $10 limit. If one purchase goes wrong, the blast radius is $10, not $30.
Budget-aware purchasing
Claude can check the balance before making a purchase and make intelligent decisions based on the remaining budget:
You: Buy the datasets we need for the analysis. Use card card_xyz789.
Claude: [Calling check_balance with card_id: card_xyz789]
Remaining: $18.00
Let me check the prices for the datasets we need:
- Dataset A: $7.99
- Dataset B: $5.49
- Dataset C: $8.99
- Total needed: $22.47
The total cost ($22.47) exceeds the card balance ($18.00).
I can purchase Datasets A and B ($13.48 total) within budget.
Dataset C would require an additional $4.99. Would you like me to
proceed with A and B, or would you prefer to fund additional budget?
This is the correct behavior for a budget-constrained agent. It checks what's available, compares against what's needed, and defers to the human when the budget is insufficient rather than attempting transactions that will be declined.
Session-level budgets
For longer sessions with many small purchases, create a single card with a session-level budget:
$ agent-cards cards create --amount 50
Claude makes multiple purchases across the session, drawing from the $50 pool. This is simpler to manage than per-task cards for sessions with many small, unpredictable expenses. The tradeoff is less granular cost attribution -- you see the total session cost but not the cost of each individual action without reviewing transaction history.
Security Properties
This setup provides several security properties that matter for autonomous agent payment access:
- No credential exposure. Claude never sees your personal credit card. It has its own card with its own credentials, retrieved at runtime through authenticated MCP calls. Card credentials are encrypted at rest with AES-256-GCM.
- Hard spending limits. The card's funded amount is the absolute ceiling. Enforced by the Mastercard network, not by application code. No prompt, no code, no bug can cause the card to exceed its loaded amount.
- Human-in-the-loop funding. Creating a card is instant, but funding it requires human payment approval via Stripe Checkout. Claude cannot authorize new funds -- it can only spend what you have explicitly funded.
- Instant revocation. Cards can be disabled immediately via MCP tool or CLI. All subsequent transactions are declined with no delay.
- No persistent credentials. Card credentials are not stored in prompts, environment variables, config files, or conversation history. They are retrieved at runtime and used in context, then discarded when the context window moves on.
For a deeper discussion of the security model, see Should You Give Your AI Agent a Credit Card? For the full spending security framework, see How to Set Spending Limits on AI Agents.
Troubleshooting
Claude can't find the payment tools
Run claude mcp list to verify the AgentCard server is registered. If it's not listed, run the claude mcp add command again. Restart your Claude Code session after adding the server -- MCP servers are loaded when the session starts.
Card shows "pending_funding"
The card has been created but the Stripe Checkout payment hasn't been completed. Open the funding URL from the card creation output and complete the payment. Use agent-cards cards list to check the status. Once funded, the status changes to "active."
Transaction declined unexpectedly
Check the card balance with agent-cards balance <card_id>. If the balance is lower than the transaction amount, that is why it declined -- the hard limit is working as intended. If the balance should be sufficient, the decline may be from the merchant or payment processor side, not the card limit.
MCP server authentication error
The MCP server uses your CLI authentication. Run agent-cards login to re-authenticate, then restart your Claude Code session. The MCP server will pick up the new credentials.
What This Does Not Do
To be clear about the boundaries:
- This does not give Claude access to your bank account or credit card. The debit card is a separate financial instrument.
- This does not let Claude create unlimited funds. Funding requires human payment approval via Stripe Checkout.
- This does not bypass any merchant verification. The card is a standard Mastercard subject to all normal merchant security checks.
- This does not make Claude PCI compliant. AgentCard handles PCI compliance for card storage and issuance. Your use of card credentials within Claude Code is your responsibility -- don't log card numbers, don't save them to files. See the MCP specification for the security model of tool-based credential access.
Frequently Asked Questions
Can I give Claude Code a virtual card with spending limits?
Yes. Install AgentCard (npm install -g agent-cards), create a virtual debit card with a specific amount (agent-cards cards create --amount 25), and add the AgentCard MCP server to Claude Code (claude mcp add agent-cards npx -y agent-cards-mcp). The card has a hard spending limit enforced at the Mastercard network level — Claude cannot spend more than the loaded amount.
How do I set up a payment MCP server for Claude?
Run claude mcp add agent-cards npx -y agent-cards-mcp to add the AgentCard MCP server to Claude Code. This gives Claude access to six payment tools: create_card, get_card_details, list_cards, check_balance, get_funding_status, and close_card. No additional configuration is required.
Does Claude Code support autonomous payments?
Yes, with the AgentCard MCP server connected. Claude Code can create debit cards, retrieve card credentials, check balances, and use cards for purchases — all through MCP tool calls. Human approval is required only for funding the card via Stripe Checkout. Once funded, Claude can use the card autonomously within its budget.
How do AI agents pay for things autonomously?
AI agents pay for things using virtual card credentials retrieved through MCP tool calls. The agent calls get_card_details to retrieve the card number, CVV, and expiry, then uses those credentials to complete online purchases. The card is a standard virtual debit card accepted anywhere Mastercard is accepted online. The agent never sees your personal credit card — it has its own card with its own budget.