Skip to content

feat(mcp): add list_fees and get_fee tools#51

Merged
vladmarascu merged 2 commits into
mainfrom
feat/list-fees-tool
May 20, 2026
Merged

feat(mcp): add list_fees and get_fee tools#51
vladmarascu merged 2 commits into
mainfrom
feat/list-fees-tool

Conversation

@vladmarascu
Copy link
Copy Markdown
Contributor

@vladmarascu vladmarascu commented May 20, 2026

Summary

Adds two read-only MCP tools that expose Lago's /fees endpoint to AI agents:

  • list_fees — list with rich filters (fee type, billable metric code, customer, subscription, currency, payment status, created-at date range, pagination)
  • get_fee — single fee by Lago ID (UUID)

This is the third PR in a chain. Depends on:

Code changes

File Change
mcp/src/tools/fee.rs (new) ListFeesArgs, GetFeeArgs, FeeService with build_request, list_fees, get_fee handlers. Mirrors the existing invoice.rs pattern.
mcp/src/tools.rs pub mod fee;
mcp/src/server.rs Imports FeeService, adds field to LagoMcpServer, instantiates in new(), registers two #[tool(description=...)] methods.
mcp/Cargo.toml Bumps lago-client to 0.1.25 and lago-types to 0.1.23.
README.md New ### Fees section under Available Tools.

Tool descriptions (what the LLM reads)

The #[tool(description=...)] strings shape when the model decides to call these tools:

  • list_fees description explicitly mentions "MRR calculations" and "selected usage charges (e.g., seats, storage)". This is the surface that connects "What's our MRR including seats?" to a list_fees call with billable_metric_code=seats.
  • get_fee is a standard drill-down by Lago ID — used as a follow-up to a list_fees result.

Happy to adjust wording if there's a preferred phrasing.

What this PR does NOT do

  • Mistral agent config sync. The function schemas in Mistral's agent console are hand-maintained today. After this merges and the MCP server is deployed, someone needs to paste the list_fees and get_fee schemas into the Mistral agent. Tracked as operational followup.
  • Schema-level per_page max enforcement. The arg description says "max: 100" but the JSON Schema doesn't enforce it. Matches the existing pattern in invoice.rs and every other paginated tool. Worth a separate cleanup PR.
  • Destructive-op safety scaffolding. Both new tools are read-only, so unaffected. The pattern still needs designing for the existing mutating tools — separate effort.

Test plan

Verified end-to-end locally against a real Lago account (4,521 fees in test data):

  • cargo build — clean
  • cargo fmt --all -- --check — clean
  • cargo clippy --all-targets -- -D warnings — clean
  • cargo test — passes
  • MCP server boots on port 3000, /health responds
  • tools/list advertises both new tools (55 total, up from 53)
  • tools/call list_fees with per_page=3 returned 3 real fees with valid pagination metadata
  • tools/call get_fee with a UUID from the list response returned the matching single fee
  • tools/call list_fees with fee_type=subscription correctly filtered server-side

Commits

0a3ee19 chore(mcp): bump lago-client to 0.1.25 and lago-types to 0.1.23
7621e71 feat(mcp): add list_fees and get_fee MCP tools

## Context

Customers building custom revenue and MRR reporting (initial driver:
Foxglove) need fee-level access through the AI assistant. Today the MCP
exposes invoice-level operations but no way to drill into the fee
breakdown — so MRR variants that include selected usage charges
(e.g., seats, storage) alongside subscription fees are impossible to
compute from agentic tooling.

## Description

Adds two read-only MCP tools backed by Lago's `/fees` endpoint:

- **list_fees**: list with optional filtering by fee_type, billable
  metric code, customer, subscription, currency, payment status, and
  created-at date range. The tool description specifically calls out
  the MRR use case so the LLM surfaces this tool for revenue questions.
- **get_fee**: retrieve a single fee by its Lago ID.

Implementation mirrors the existing `invoice.rs` pattern: schemars-derived
args structs, a FeeService that maps args to a ListFeesRequest, and
explicit `#[tool(description=...)]` registrations on LagoMcpServer.
## Context

`lago-client 0.1.25` (with `list_fees` / `get_fee` methods) and
`lago-types 0.1.23` (with the fee filter/request/response types) are
now published on crates.io. Consuming them unlocks the MCP fee tools
added in the previous commit.

## Description

- `mcp/Cargo.toml`: `lago-client = "0.1.23"` → `"0.1.25"`
- `mcp/Cargo.toml`: `lago-types = "0.1.21"` → `"0.1.23"`
- `mcp/Cargo.lock`: regenerated; both deps resolve from the registry
@vladmarascu vladmarascu merged commit 92e5832 into main May 20, 2026
1 check passed
@vladmarascu vladmarascu deleted the feat/list-fees-tool branch May 20, 2026 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants