Lago Agent Toolkit
August 25, 2026 · View on GitHub
MCP server and agent tools for Lago. Lets AI agents read and write billing data in Lago — invoices, events, customers, payments, credit notes, coupons — via the Model Context Protocol.
Works with Claude Desktop today.
What's inside
An MCP (Model Context Protocol) server written in Rust, distributed as a Docker image. It bridges AI agents and Lago's billing API.
Features:
- Full access to Lago's billing primitives as 40 MCP tools
- Type-safe Rust implementation
- Multi-architecture Docker image (AMD64 & ARM64)
- Pagination support for large datasets
- Filter invoices, customers, payments, events with rich query parameters
The Managed Agents context
Anthropic launched Claude Managed Agents on April 8, 2026. As of that release, two observable constraints in Anthropic's Admin API:
- The Usage Report API's
group_byparameter accepts 7 values:api_key_id,workspace_id,model,service_tier,context_window,inference_geo,speed.agent_idandsession_idare not among them. - Session creation accepts
agent,environment_id, andvault_ids. Nocustomer_id,metadata, orexternal_id.
For operators deploying Managed Agents to their own customers and needing per-session or per-customer attribution to bill those customers, the attribution data isn't exposed by Anthropic's API. The Lago Agent Toolkit surfaces Lago's billing primitives via MCP so that layer can be built on Lago rather than hand-rolled.
Quick start (Claude Desktop)
- Install Docker Desktop
- Open Claude Desktop → Settings → Developer → Edit Config
- Add the Lago MCP server:
{
"mcpServers": {
"lago": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"--name", "lago-mcp-server",
"-e", "LAGO_API_KEY=your_lago_api_key",
"-e", "LAGO_API_URL=https://api.getlago.com/api/v1",
"-e", "LAGO_AGENT_API_URL=https://agent.getlago.com",
"getlago/lago-mcp-server:latest"
]
}
}
}
- Replace
your_lago_api_keywith your actual Lago API key (find it in your Lago dashboard under API settings). - Restart Claude Desktop. The agent can now call Lago.
For self-hosted Lago, replace LAGO_API_URL with your instance URL.
Analytics tool:
ask_lago_analyticsadditionally requiresLAGO_AGENT_API_URL(the URL of the Lago analytics agent). If it's not set, the other tools work normally and only the analytics tool returns a configuration error. Note: this tool forwards yourX-LAGO-API-KEYto the analytics agent service (a first-party Lago service that re-validates the key and applies the same per-organization row-level security as the Rails API). It is the one tool that does not route through the Lago REST API — see the PR description /docs/for the architecture rationale.
Example prompts
- "Show me all pending invoices from last month" →
list_invoices - "Find all failed payment invoices" →
list_invoices - "Give me the total amount of overdue invoices for March 2025" →
list_invoices+ agent aggregation - "Preview an invoice for customer X with 500 additional API-call events" →
preview_invoice - "Retry payment on invoice INV-123" →
retry_invoice_payment - "What was our MRR for December 2025, broken down by plan?" →
ask_lago_analytics - "List the top 10 customers by usage volume in Q1 2026." →
ask_lago_analytics - "How many invoices went overdue last month?" then "Break that down by customer country." →
ask_lago_analytics(the second call reuses the returnedsession_id)
Available Tools
Analytics
ask_lago_analytics: Ask a natural-language question about your billing and usage data (revenue, MRR, invoices, customers, subscriptions, usage volumes). The analytics agent generates a read-only SQL query, runs it, and returns the SQL, a plain-language explanation, and a results table. The response includes asession_id— pass it back on a follow-up call to refine the same result (filter, aggregate, sort) using the agent's cached rows.
Invoices
find_invoice_by_number: Find an invoice by its number (e.g., "RAF-8142-202601-312") and get its Lago IDget_invoice: Retrieve a specific invoice by Lago IDdelete_invoice: Delete a draft invoice by Lago ID after confirming the action; this cannot be undonelist_invoices: Search and filter invoices with advanced criterialist_customer_invoices: List all invoices for a specific customercreate_invoice: Create a one-off invoice with add-on fees, each optionally carrying a service period (from_datetime/to_datetime)update_invoice: Update an invoice's payment status or metadatapreview_invoice: Preview an invoice before creating itrefresh_invoice: Refresh a draft invoice to recalculate chargesdownload_invoice: Download an invoice PDFretry_invoice: Retry generation of a failed invoiceretry_invoice_payment: Retry payment collection for an invoicevoid_invoice: Void a finalized invoice to prevent further modifications or payments
Fees
list_fees: List fees with filtering by fee type, billable metric code, customer, subscription, currency, payment status, and date range. Useful for custom revenue reporting and MRR calculations that need to include selected usage charges (e.g., seats, storage) alongside subscription fees.get_fee: Retrieve a specific fee by its Lago ID
Customers
get_customer: Retrieve a customer by external IDlist_customers: List customers with optional filteringcreate_customer: Create or update a customer
Billable Metrics
get_billable_metric: Retrieve a billable metric by codelist_billable_metrics: List billable metrics with optional filteringcreate_billable_metric: Create a new billable metric
Coupons
get_coupon: Retrieve a coupon by codelist_coupons: List all couponscreate_coupon: Create a new couponupdate_coupon: Update an existing coupondelete_coupon: Delete a coupon
Applied Coupons
list_applied_coupons: List applied coupons with optional filteringapply_coupon: Apply a coupon to a customer
Events
get_event: Retrieve a usage event by transaction IDcreate_event: Send a usage event to Lagolist_events: List usage events with optional filtering by subscription, code, and timestamp range
Credit Notes
get_credit_note: Retrieve a specific credit note by Lago IDlist_credit_notes: List credit notes with optional filteringcreate_credit_note: Create a credit note for an invoiceupdate_credit_note: Update a credit note's refund status
Payments
get_payment: Retrieve a specific payment by Lago IDlist_payments: List all payments with optional filtering by customer and invoicelist_customer_payments: List all payments for a specific customercreate_payment: Create a manual payment for an invoice
Activity Logs
get_activity_log: Retrieve a specific activity loglist_activity_logs: List activity logs with optional filtering
API Logs
get_api_log: Retrieve a specific API loglist_api_logs: List API logs with optional filtering
Contributing
Issues and PRs welcome.
About Lago
Lago is the open-source billing platform for AI-native companies. Real-time metering, programmatic invoicing, self-hostable. Used in production by PayPal, Mistral AI, Groq, Synthesia, and Laravel. AI-infrastructure companies such as CoreWeave also run Lago.
- Docs: docs.getlago.com
- Cloud: getlago.com
- Community: Slack
License
MIT License - see LICENSE for details.