Skip to main content

MarginFront MCP Tools Reference

This is a complete list of every tool the MarginFront MCP server provides. There are 13 tools total, organized into four groups: read-only, write, diagnostic, and destructive. Your AI assistant calls these tools automatically when you ask it questions about your MarginFront data. You don’t need to memorize tool names — just ask in plain English and the AI picks the right tool.

Read-Only Tools (8)

These tools look things up without changing anything.

1. verify

What it does: Checks that your API key is valid and shows which organization it belongs to. This is the “hello world” of MCP — call it first to make sure everything is wired up. Parameters: None. What it returns: Your organization name and a verified status. Example prompt: “Verify my MarginFront connection”

2. list_customers

What it does: Lists your customers with optional search and pagination. Good for browsing your customer list or finding a specific customer by name. Parameters:
NameTypeRequiredDefaultDescription
pagenumberNo1Which page of results to show
limitnumberNo20How many results per page (1-100)
searchstringNoSearch by customer name or external ID
What it returns: A list of customers with their names, MarginFront UUIDs, external IDs, and status. Example prompt: “Show me my MarginFront customers”

3. get_customer

What it does: Gets detailed information about one specific customer, including their subscriptions. Parameters:
NameTypeRequiredDescription
customerIdstringYesThe customer’s MarginFront UUID (not their external ID)
What it returns: Full customer details — name, email, phone, external ID, status, and all their subscriptions. Example prompt: “Tell me about customer 7a2b3c4d-5e6f-7890-abcd-ef1234567890”
Note: This tool needs the MarginFront UUID, not the external ID you use in your own system. Use list_customers first to find the UUID.

4. list_invoices

What it does: Lists invoices with optional filters by status or customer. Parameters:
NameTypeRequiredDefaultDescription
statusstringNoFilter by status: "draft", "pending", "paid", "overdue", or "void"
customerIdstringNoFilter by customer UUID
pagenumberNo1Which page of results
limitnumberNo20Results per page (1-100)
What it returns: A list of invoices showing status, amounts, customer name, and dates. Example prompt: “Show me all pending invoices”

5. get_invoice

What it does: Gets full details about one invoice, including every line item and payment history. Parameters:
NameTypeRequiredDescription
invoiceIdstringYesThe invoice’s UUID
What it returns: The complete invoice — line items (what was billed), amounts, payment status, customer info, and dates. Example prompt: “Show me the details on invoice 1a2b3c4d-5e6f-7890-abcd-ef1234567890”

6. list_events

What it does: Lists usage events (the raw records of what your customers actually used) with optional filters. Parameters:
NameTypeRequiredDefaultDescription
pagenumberNo1Which page of results
limitnumberNo20Results per page (1-100)
customerIdstringNoFilter by customer UUID
agentIdstringNoFilter by agent UUID
signalIdstringNoFilter by signal UUID
startDatestringNoOnly show events after this date (ISO 8601 format, e.g. "2026-04-01")
endDatestringNoOnly show events before this date (ISO 8601 format)
What it returns: A list of events, each showing the model used, token counts, calculated cost, customer, and timestamp. Example prompt: “What events were logged today?“

7. get_usage_analytics

What it does: Gets aggregated usage analytics (totals and trends) for a date range. Unlike list_events which shows individual events, this gives you the big picture — totals, breakdowns, and time-series data. Parameters:
NameTypeRequiredDefaultDescription
startDatestringYesStart of the date range (ISO 8601, e.g. "2026-04-01")
endDatestringYesEnd of the date range (ISO 8601, e.g. "2026-04-12")
groupBystringNoHow to break down the data: "agent", "customer", "signal", "model", or "day"
What it returns: Summary totals (total cost, total events, total tokens) plus a breakdown grouped however you specified. Example prompt: “Show me usage analytics for April grouped by customer”

8. list_subscriptions

What it does: Lists customer subscriptions (which customer is on which pricing plan). Parameters:
NameTypeRequiredDefaultDescription
statusstringNoFilter by status: "active", "canceled", "past_due", "trialing"
customerIdstringNoFilter by customer UUID
pagenumberNo1Which page of results
limitnumberNo20Results per page (1-100)
What it returns: A list of subscriptions showing status, plan name, billing dates, and customer info. Example prompt: “Show me all active subscriptions”

Write Tools (3)

These tools create or modify data. They change things in MarginFront, so the AI will usually confirm before calling them.

9. record_usage

What it does: Records a single usage event — one measurement of a customer using your AI agent. This is how MarginFront learns what to bill for. There are two kinds of events:
  • LLM events (chatbots, summarizers, etc.): pass inputTokens and outputTokens.
  • Non-LLM events (SMS, web scraping, API calls, etc.): pass quantity instead.
Parameters:
NameTypeRequiredDefaultDescription
customerExternalIdstringYesYour customer’s ID in your system, e.g. "acme-001"
agentCodestringYesThe agent/product code from your dashboard, e.g. "cs-bot-v2"
signalNamestringYesThe metric being tracked, e.g. "messages" or "pages_processed"
modelstringYesThe model identifier, e.g. "gpt-4o", "claude-sonnet-4-6", "twilio-sms"
modelProviderstringYesThe provider name in lowercase, e.g. "openai", "anthropic", "twilio"
inputTokensnumberNoNumber of input/prompt tokens (for LLM events)
outputTokensnumberNoNumber of output/completion tokens (for LLM events)
quantitynumberNo1Number of billing units (for non-LLM events)
usageDatestringNonowISO 8601 date for backdating, e.g. "2026-04-01T00:00:00Z"
metadataobjectNoCustom key-value pairs stored with the event (not used for billing)
What it returns: The event ID, calculated cost (in USD), and timestamp. If the model isn’t in the pricing table, the event is still saved but cost will be null — use get_needs_attention and map_model to fix it. Example prompt: “Record a usage event: customer acme-001 used cs-bot, signal messages, gpt-4o from openai, 500 input tokens, 120 output tokens”
Important: If you get a “NEEDS_COST_BACKFILL” response, do NOT re-send the event. The event was saved. The model just isn’t in the pricing table yet. Use get_needs_attention to see which models need mapping, then map_model to fix them.

10. record_usage_batch

What it does: Records multiple usage events at once (1 to 100 per request). Each record has the same fields as record_usage. You can mix LLM events and non-LLM events in the same batch. Parameters:
NameTypeRequiredDescription
recordsarrayYesAn array of 1-100 usage records. Each record has the same fields as record_usage (see above).
What it returns: A summary showing how many succeeded, how many failed, and per-record details for each. Failed records that were still saved (like NEEDS_COST_BACKFILL) are flagged — do NOT retry those. Example prompt: “Record these usage events: customer acme-001 sent 3 messages on cs-bot using gpt-4o from openai (200 input / 50 output tokens each)“

11. create_customer

What it does: Creates a new customer in MarginFront. Parameters:
NameTypeRequiredDefaultDescription
namestringYesCustomer’s display name, e.g. "Acme Corp"
externalIdstringNoYour system’s ID for this customer, e.g. "acme-001"
emailstringNoCustomer’s email address
phonestringNoCustomer’s phone number
What it returns: The newly created customer with their MarginFront UUID. Example prompt: “Create a customer called Beta Corp with external ID beta-001”
Tip: Always set externalId when creating a customer. That’s the ID you’ll use when recording usage events later, so it should match whatever ID you use for this customer in your own system.

Diagnostic Tool (1)

This tool helps you find and fix data issues.

12. get_needs_attention

What it does: Finds usage events where the model+provider combination isn’t in the pricing table. These events were saved (the data isn’t lost), but their cost is null because MarginFront doesn’t know how much that model costs. Parameters:
NameTypeRequiredDefaultDescription
startDatestringNo30 days agoOnly look at events after this date (ISO 8601)
endDatestringNonowOnly look at events before this date (ISO 8601)
What it returns: Groups of unrecognized model+provider combinations, each with a count of how many events are affected. Example prompt: “Are there any MarginFront events with unknown models?”
Important: These events ARE saved — they just have cost=null. Do NOT re-send them. Use map_model (below) to tell MarginFront what pricing to use, and it will backfill the costs automatically.

Destructive Tool (1)

This tool modifies existing data. “Destructive” sounds scary, but it’s actually a fix-it tool — and it’s safe to run more than once (it’s idempotent, meaning running it twice produces the same result as running it once).

13. map_model

What it does: Maps an unknown model to a known one in the pricing table, then backfills costs for all affected events. This creates a permanent, organization-scoped mapping — once you map it, future events with the same model+provider will have their costs calculated automatically. You tell it the “source” (the unknown model) and the “target” (the known model to price it as). You can identify the target two ways:
  • By name: pass targetModel + targetProvider (e.g., map “gpt-4o-2024-08-06” to “gpt-4o” from “openai”).
  • By ID: pass targetPricingId (the UUID of the specific pricing table row).
Parameters:
NameTypeRequiredDescription
sourceModelstringYesThe unknown model name to map FROM, e.g. "gpt-4o-2024-08-06"
sourceProviderstringYesThe unknown provider to map FROM, e.g. "openai"
targetPricingIdstringNo*UUID of the target pricing row to map TO
targetModelstringNo*Known model name to map TO, e.g. "gpt-4o"
targetProviderstringNo*Known provider to map TO, e.g. "openai"
*You must provide either targetPricingId OR both targetModel + targetProvider. One or the other, not both.
What it returns: Confirmation of the mapping, how many events had their costs backfilled, and the mapping ID. Example prompt: “Map model gpt-4o-2024-08-06 from openai to gpt-4o from openai”
Safe to run again: If you accidentally run this twice with the same inputs, nothing bad happens. It’s idempotent.