Skip to main content

Examples

Real-world examples showing how AI agents use LedgerOS MCP tools.

Make a Purchase

The most common flow: check if user can spend, create a card, get details, complete checkout.
User: "Buy me a $30 book on Amazon"

Agent:
1. ledger_status({ userId: "user_xxx" })
   → { canSpend: true, balance: 5000, verificationStatus: "approved" }

2. ledger_card({
     action: "create",
     purpose: "Buy book on Amazon",
     type: "single",
     maxAmount: 3500
   })
   → { cardId: "card_abc", lastFour: "4242", status: "active" }

3. ledger_card({
     action: "details",
     cardId: "card_abc",
     summary: "Purchasing book on Amazon"
   })
   → { pan: "4111111111114242", cvv: "123", expiry: "12/27", billingAddress: {...} }

4. [Agent navigates to Amazon, adds book to cart, enters card details at checkout]

5. ledger_transactions({ cardId: "card_abc" })
   → { transactions: [{ amount: 2999, merchantName: "AMAZON.COM", status: "completed" }] }

Agent: "Done! I bought the book for $29.99. Your card has been automatically closed."

Handle 3DS Verification

When a merchant requires 3DS authentication during checkout:
[During checkout, Amazon shows 3DS verification page]

Agent:
1. ledger_challenges()
   → {
       challenges: [{
         otp: "847293",
         merchantName: "Amazon",
         amount: 2999,
         expiresAt: 1704067200
       }]
     }

Agent: "Amazon needs verification. Enter this code: 847293"

[User enters code or agent auto-fills if allowed]

User Onboarding

Help a new user get verified and funded:
User: "I want to start using the shopping agent"

Agent:
1. ledger_status({ userId: "user_xxx" })
   → { verificationStatus: "notStarted", balance: 0, canSpend: false }

Agent: "You need to complete identity verification first."

2. ledger_onboarding({ userId: "user_xxx" })
   → { verificationUrl: "https://persona.com/verify/abc123" }

Agent: "Please complete verification here: [link]"

[User completes KYC]

3. ledger_status({ userId: "user_xxx" })
   → { verificationStatus: "approved", balance: 0, canSpend: false }

Agent: "Great, you're verified! Now you need to add funds."

4. ledger_funding({
     action: "crypto",
     userId: "user_xxx",
     chain: "base"
   })
   → { method: "crypto", address: "0x1234...", chain: "base", asset: "USDC" }

Agent: "Send USDC to this address on Base: 0x1234..."

[User sends USDC]

5. ledger_funding({ action: "balance", userId: "user_xxx" })
   → { available: 10000, currency: "USD" }

Agent: "You're all set! You have $100 available to spend."

Multi-Use Card with Intents

Create a reusable card that requires intent declaration before each purchase:
User: "Create a card I can use for multiple small purchases this week"

Agent:
1. ledger_card({
     action: "create",
     purpose: "Weekly small purchases",
     type: "multi",
     limitPerDay: 5000,
     requireIntent: true
   })
   → { cardId: "card_xyz", lastFour: "8888", type: "multi" }

Agent: "Created a multi-use card with $50/day limit. I'll need to declare intent before each purchase."

[Later...]

User: "Buy me a coffee"

Agent:
2. ledger_intent({
     action: "declare",
     cardId: "card_xyz",
     summary: "Buy coffee at Starbucks",
     expectedAmount: 650
   })
   → { intentId: "int_123", status: "pending" }

3. ledger_card({
     action: "details",
     cardId: "card_xyz",
     summary: "Coffee at Starbucks"
   })
   → { pan: "...", cvv: "...", expiry: "..." }

[Agent completes purchase]

Admin: Register an Agent

Set up a new AI agent for a user:
Admin workflow:

1. ledger_users({
     action: "create",
     externalId: "customer-123",
     firstName: "Jane",
     lastName: "Smith",
     email: "[email protected]"
   })
   → { userId: "user_abc" }

2. ledger_agents({
     action: "register",
     externalId: "shopping-agent-v1",
     userId: "user_abc",
     name: "Shopping Assistant",
     description: "Helps Jane buy products online"
   })
   → { agentId: "agent_xyz", status: "active" }

3. [Create agent token via API for the agent to use at runtime]

Admin: Configure Risk Detection

Set up anomaly detection for your organization:
1. ledger_risk({ action: "get" })
   → { duplicateDetection: {...}, velocityLimit: {...}, ... }

2. ledger_risk({
     action: "preset",
     preset: "moderate"
   })
   → { message: "Applied 'moderate' preset", config: {...} }

3. ledger_risk({
     action: "update",
     velocityMaxPerHour: 30,
     dryRun: true
   })
   → { message: "Config updated", config: {...} }

[Monitor webhooks in dry-run mode, then disable dryRun when ready]

Error Handling

The MCP server returns errors as JSON in the response:
{
  "error": "cardId is required"
}
Common errors:
ErrorCauseSolution
Agent ID not configuredMissing LEDGER_AGENT_ID envSet agent ID with agent token
cardId is requiredMissing required parameterInclude the parameter
summary is required for attestationGetting details without summaryProvide what you’re purchasing
User not verifiedUser hasn’t completed KYCUse ledger_onboarding first
Insufficient balanceNot enough fundsUse ledger_funding to get deposit info