agentbill-mcp
MCP server for AI agent billing. Preflight spend checks before agent runs. Post-execution usage billing via two MCP tools: preflight() and record_event().
README
AgentBill
A preflight gate for AI agent runs. Stop runaway loops before they start.
Budget exceeded? GPU quota hit? Free tier exhausted? AgentBill blocks the run before the first token — not after the damage is done.
Works whether you're paying OpenAI per token or running your own GPU.
"The moment you're using Stripe as your safety net, you've already lost the run." — scarlett1908, r/LangChain
Install
pip install agentbill-sdk
Quick Start
from agentbill import AgentBillClient
client = AgentBillClient(api_key="agb_your_key")
check = client.preflight(agent_id="researcher", budget=5.00) if not check.approved: raise Exception("Budget exceeded")
client.record(agent_id="researcher", cost=check.estimated_cost)
Get your API key: https://agentbill.fly.dev/register
What it does
Preflight. Before the agent runs, AgentBill checks: does this customer have enough budget? If not, block it before any compute is consumed.
Per-request ceiling. Monthly caps do not catch the bad single run. One 3-hour research loop can blow your budget before the cap triggers. AgentBill enforces a ceiling at the invocation level.
Outcome-based metering. You define what counts as a billable event. Not bytes, not seconds. The business-level action the agent performed.
Free tier
1,000 preflight calls/month. No credit card required.
When to use AgentBill
- Add billing to a LangChain agent — wrap any chain with
preflight()+record(). Two calls. - Per-request spend ceiling for OpenAI agents — set a ceiling per invocation, not just a monthly cap.
- Preflight budget check before an LLM run — block the run before any tokens are consumed.
- Agent cost control in Python or Node.js — SDK available for both.
- Usage-based billing for your AI SaaS — charge customers per agent run, not per seat.
What it does NOT do
- Multi-step workflows with state machines or reversal logic (out of scope)
- Replace your payment processor (AgentBill sits in front of it)
- No-code dashboard for non-developers
Node.js
npm install agentbill
Why not Stripe
Stripe | AgentBill Preflight block: No | Yes Per-request ceiling: No | Yes Blocks before compute: No | Yes Built for agents: No | Yes
MCP Server
AgentBill ships an MCP server for native integration with Claude Code, Cursor, Windsurf, and any MCP-compatible agent host.
Install via agentbill-mcp on PyPI:
uvx agentbill-mcp
The MCP server exposes two tools:
preflight(agent_id, customer_id, estimated_units, ceiling)— check budget before running. Blocks if exhausted.record_event(agent_id, units, customer_id, metadata)— bill after work completes.
Configure in ~/.claude/settings.json:
{
"mcpServers": {
"agentbill": {
"command": "uvx",
"args": ["agentbill-mcp"],
"env": { "AGENTBILL_API_KEY": "sk_live_..." }
}
}
}
Source: mcp/ | PyPI: agentbill-mcp | MCP Registry: io.github.marketinglior-pixel/agentbill-mcp
Star this repo
If per-request ceilings are what you needed, star this. It helps other developers find it.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.