Why MCP
Agents call reserve_credits the same way they call any other tool — no SDK install, no REST plumbing.
The reservation pattern protects against runaway spend: hold credits before the LLM call, settle at the real cost after.
Run locally with npx, or hit the hosted endpoint at mcp.credits.dev from any platform.
Tools (11)
get_balanceAvailable, reserved, and total credit balance.
get_accountProfile (id, externalId, name, email, balance).
reserve_creditsHold N credits before paid work; returns reservationId.
confirm_reservationSettle a reservation at the actual amount used.
cancel_reservationRelease a reservation without spending.
deduct_creditsOne-shot debit when the cost is known up front.
record_usageAttribute token usage to a model for analytics.
list_transactionsRecent debits and credits, newest first.
list_reservationsOpen or all reservations for an account.
calculate_costEstimate credit cost for a model + token counts.
list_modelsCatalog of supported models with pricing.
Write tools accept idempotencyKey. Errors arrive as structured codes (insufficient_credits, etc.) so agents can react without parsing strings.
Install
{
"mcpServers": {
"credits-dev": {
"command": "npx",
"args": ["-y", "@credits-dev/mcp-server"],
"env": { "CREDITS_API_KEY": "sk_live_..." }
}
}
}Get an API key at app.credits.dev/dashboard/api-keys.
Typical flow
// Inside an agent runtime that has the credits.dev MCP server installed
// the agent can call these tools natively — no SDK install required.
// 1. Estimate cost
calculate_cost({ modelId: "gpt-4o", inputTokens: 4000, outputTokens: 800 })
// → { estimatedCostUsd: 0.0220, ... }
// 2. Reserve before the LLM call
reserve_credits({ externalId: "agent_writer_42", amount: 25 })
// → { reservationId: "rsv_abc", status: "pending" }
// 3. Do the paid work, then confirm with the actual amount
confirm_reservation({ reservationId: "rsv_abc", actualAmount: 22 })
// → { transactionId: "txn_xyz", balance: 9978 }
// 4. Attribute usage to a model for the analytics tab
record_usage({
externalId: "agent_writer_42",
transactionId: "txn_xyz",
modelId: "gpt-4o",
inputTokens: 4000,
outputTokens: 800,
})