# Lago MCP

> Lago connects your AI agent to robust metering and usage-based billing. Handle complex pricing models—including custom plans, prepaid credits, and real-time consumption tracking—without leaving your chat interface.

## Overview
- **Category:** money-moves
- **Price:** Free
- **Tags:** usage-based-billing, metering, saas-metrics, subscription-management, revenue-operations, api-integration

## Description

This MCP lets you automate the entire cycle of usage-based revenue operations. Forget juggling multiple dashboards or writing custom scripts every time a customer consumes resources; you manage it all through natural language. You can create new pricing plans, assign them to customers, and even set up prepaid credit wallets for immediate use. When activity happens, you send simple usage events that trigger accurate billing calculations in real-time. Need to correct something? Your agent handles applying coupons or generating detailed invoices instantly. Connecting Lago via the Vinkius catalog makes your entire revenue stack available from one place, letting you manage everything—from customer setup to final invoice generation—directly through your preferred AI client.

## Tools

### apply_coupon
Applies a specific coupon code to an existing customer's account.

### batch_events
Sends multiple usage events at once, useful for syncing historical data or large batches of consumption records.

### create_billable_metric
Defines a new type of resource that can be measured and charged against customer usage.

### create_coupon
Generates a new, usable coupon code for your customers to redeem.

### create_plan
Builds and saves an entirely new billing plan structure within the system.

### create_subscription
Assigns a specific, pre-existing pricing plan to a customer account, activating their subscription.

### create_wallet
Creates a dedicated wallet balance for prepaid credits or stored value for any user.

### get_customer
Retrieves all current profile details for a customer using their unique external ID.

### get_subscription
Fetches the full status and details of any active subscription account.

### list_invoices
Pulls a list of all past and pending invoices associated with your accounts.

### send_event
Sends a single, real-time usage event immediately to trigger billing updates.

### upsert_customer
Creates a new customer record or safely updates an existing one using its unique external ID.

## Prompt Examples

**Prompt:** 
```
Create a new customer in Lago with external ID 'user_123' and email 'dev@example.com'.
```

**Response:** 
```
I've successfully created the customer record for 'user_123'. Their profile is now active in Lago and ready for subscriptions.
```

**Prompt:** 
```
Show me the subscription details for ID 'sub_98765'.
```

**Response:** 
```
Fetching subscription 'sub_98765'... It is currently active on the 'Premium' plan, started on 2023-10-01, and is set for monthly billing.
```

**Prompt:** 
```
List all invoices for my Lago account.
```

**Response:** 
```
I've retrieved the latest invoices. You have 3 pending invoices for this month and 12 paid invoices from the previous quarter. Would you like to see the details for a specific one?
```

## Capabilities

### Manage Customer Profiles
Create or update full customer records and retrieve existing details using a unique external ID.

### Control Subscriptions and Plans
Set up new billing plans, assign those plans to customers, or pull up the status of any active subscription.

### Track Usage Data for Billing
Send single usage events or large batches of data points that automatically trigger consumption and billing updates.

### Handle Financial Operations
Generate invoices, create coupon codes, or top up customer prepaid credit wallets.

### View Billing Metrics
Pull specific data points about what can be billed, ensuring your usage tracking is accurate before billing cycles end.

## Use Cases

### A new feature was released and needs immediate metering.
The growth engineer knows the service is going live. They ask their agent to 'Create a billable metric called API_CALLS' using `create_billable_metric`. This ensures that when users start making calls, those specific actions are immediately accounted for in billing.

### A large corporate client needs an immediate discount.
The sales rep asks the agent to 'Apply a 25% coupon to Acme Corp'. The agent uses `apply_coupon` and confirms the discount, ensuring the revenue team can process the change instantly.

### End-of-quarter billing reconciliation is due.
The finance analyst simply asks the agent to 'List all invoices for Q2'. The agent runs `list_invoices` and provides a summarized view, eliminating hours of spreadsheet work.

### A beta user needs immediate access but has no paid plan.
The product manager asks the agent to 'Create a $50 credit wallet for Beta User 789'. The agent uses `create_wallet`, giving the user instant, pre-paid access while the billing team finalizes their subscription.

## Benefits

- Stop manual billing calculations. You can send usage data via the `send_event` or `batch_events` tools, making sure your customers are billed instantly and accurately based on real-time consumption.
- Manage customer finances without leaving chat. Use `create_wallet` to issue prepaid credits and `apply_coupon` to run promotions instantly, all through natural language queries.
- Build complex pricing models easily. The `create_plan` tool lets you define new tiers (e.g., 'Tier 2: $0.10/unit') that your customers can subscribe to using `create_subscription`.
- Maintain clean data integrity. Use `upsert_customer` and `get_customer` together to ensure every customer profile is accurate before running any billing operations.
- Simplify reporting. Your agent handles listing all invoices via `list_invoices`, giving you immediate visibility into outstanding revenue without needing a dashboard view.

## How It Works

The bottom line is that you talk to your agent like talking to a finance analyst, and it handles all the complex API calls needed to manage billing logic.

1. First, subscribe to this MCP and provide your API key within your AI client.
2. Next, tell your agent exactly what you need—like 'Create a new plan for 100 units at $0.05' or 'Send usage data for the last hour'.
3. Finally, the MCP executes the billing action in Lago and provides confirmation of the change.

## Frequently Asked Questions

**How do I handle usage-based billing with Lago?**
You use the `send_event` or `batch_events` tools to push real-time consumption data. This triggers the metering system, which accurately tracks and bills against defined metrics.

**Can I change a customer's plan using Lago?**
Yes, you can assign new billing plans by running `create_subscription`. You just need to know the target plan ID beforehand.

**What is the difference between `upsert_customer` and creating a customer?**
`Upsert_customer` is for updating records. It's safer because it tries to update an existing client first; if that fails, it creates them instead.

**Does Lago handle prepaid credits?**
Yes. You can set up and manage prepaid funds by using the `create_wallet` tool to issue stored value or credit to a customer account.

**How do I verify if I've created a metric correctly with Lago?**
You should use the `get_customer` tool first, then follow up by calling `create_billable_metric`. This lets you confirm the resource is ready to track usage.