llm-ledger
Allows importing OpenAI usage CSVs and syncing OpenAI Organization Costs via an Admin API key into a local spend ledger for tracking costs, budgets, and invoice-style summaries.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@llm-ledgerImport this month's OpenAI usage CSV and show spend by project"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
llm-ledger
Local-first FinOps ledger for AI contractors.
Import provider usage CSVs (OpenAI, Anthropic, OpenRouter) — or sync OpenRouter Activity / OpenAI Organization Costs into a local SQLite database — and query spend, budgets, and invoice-style summaries through MCP tools — from Cursor, Claude Desktop, or any MCP client.
This is not an LLM gateway. It does not proxy prompts. OpenRouter sync needs a Management API key; OpenAI costs sync needs an Admin API key (regular sk- keys will not work). Keys are only used at sync time and are never stored in the ledger.
Why
Freelancers and small agencies juggling multiple AI providers need a single place to answer:
How much did I spend this month?
Which client/project ate the budget?
Am I over the retainer ceiling?
What would an invoice line-item look like by model?
llm-ledger keeps that data on your machine (~/.llm-ledger/ledger.db by default).
Related MCP server: ExpenseTracker MCP Server
Install
git clone https://github.com/Zacsladden1/llm-ledger.git
cd llm-ledger
npm install
npm run buildRequires Node.js 20+. Native module better-sqlite3 needs build tools on some platforms (Xcode CLT on macOS, build-essential + python on Linux).
MCP tools
Tool | Purpose |
| Import a usage CSV ( |
| Pull OpenRouter Activity API spend (Management key) into the ledger |
| Pull OpenAI Organization Costs API spend (Admin key) into the ledger |
| Total spend for current month (or |
| Spend breakdown by project |
| Lines by provider + model (+ project) |
| Set monthly USD budget for a project |
| Compare MTD spend vs budget |
| List CSV / OpenRouter / OpenAI sync import batches |
CSV columns (resilient aliases)
Importers tolerate common export header names. Cost is optional — when missing, a built-in pricing fallback map estimates USD from tokens.
OpenAI — date / usage_date / timestamp, model, input_tokens / prompt_tokens, output_tokens / completion_tokens, optional cost / cost_usd, optional project.
Anthropic — date / created_at, model, input_tokens / tokens_input, output_tokens / tokens_output, optional cost / spend, optional project / workspace.
OpenRouter — date / created_at / generation_time, model, prompt_tokens / input_tokens, completion_tokens / output_tokens, optional cost, optional project / app.
Database
Default path:
~/.llm-ledger/ledger.dbOverride with env
LLM_LEDGER_DB=/path/to/ledger.db
No cloud sync of the ledger itself. No telemetry. API keys are read from the environment (or an optional tool arg) at sync time and are not written to SQLite.
OpenRouter Activity sync (sync_openrouter)
OpenRouter's /api/v1/activity (and analytics) endpoints require a Management API key (also called a provisioning key). Ordinary inference / chat keys return 401/403.
Create a Management key at openrouter.ai/settings → Management Keys (direct link).
Set env
OPENROUTER_MANAGEMENT_KEYin your MCP server config (preferred), or passapi_keyto the tool once (never logged or echoed in tool results).Ask your MCP client, e.g. "Sync OpenRouter last 30 days" / call
sync_openrouterwith optionalsince/until(YYYY-MM-DD) orproject.
Example Cursor env block:
{
"mcpServers": {
"llm-ledger": {
"command": "node",
"args": ["/absolute/path/to/llm-ledger/dist/index.js"],
"env": {
"LLM_LEDGER_DB": "/absolute/path/to/optional-custom.db",
"OPENROUTER_MANAGEMENT_KEY": "sk-or-…"
}
}
}
}Sync is idempotent: rows are keyed by day + model + endpoint (+ workspace when present), so re-running skips duplicates and records an import batch visible via list_imports. The Activity API covers roughly the last 30 completed UTC days.
OpenAI Costs sync (sync_openai)
OpenAI's /v1/organization/costs endpoint requires an Organization Admin API key. Regular project sk- inference keys will not work.
Create an Admin key at platform.openai.com/settings/organization/admin-keys.
Set env
OPENAI_ADMIN_KEYin your MCP server config (preferred), or passapi_keyto the tool once (never logged or echoed in tool results).Ask your MCP client, e.g. "Sync OpenAI last 30 days" / call
sync_openaiwith optionalsince/until(YYYY-MM-DD),start_time(unix),limit(1–180), orproject.
Example Cursor env block (combined with OpenRouter):
{
"mcpServers": {
"llm-ledger": {
"command": "node",
"args": ["/absolute/path/to/llm-ledger/dist/index.js"],
"env": {
"LLM_LEDGER_DB": "/absolute/path/to/optional-custom.db",
"OPENROUTER_MANAGEMENT_KEY": "sk-or-…",
"OPENAI_ADMIN_KEY": "sk-admin-…"
}
}
}
}Sync is idempotent: rows are keyed as oai:costs:{date}:{line_item|project|bucket} (day + line item + project when present). v0.3 is costs-only (token columns are 0). Import batches appear in list_imports.
Cursor config
Add to your MCP settings (e.g. Cursor Settings → MCP):
{
"mcpServers": {
"llm-ledger": {
"command": "node",
"args": ["/absolute/path/to/llm-ledger/dist/index.js"],
"env": {
"LLM_LEDGER_DB": "/absolute/path/to/optional-custom.db"
}
}
}
}npx (once on the public registry)
{
"mcpServers": {
"llm-ledger": {
"command": "npx",
"args": ["--yes", "llm-ledger"]
}
}
}Or after a local build, point command at node with args to dist/index.js. See PUBLISH.md for registry release steps.
Claude Desktop config
Edit claude_desktop_config.json:
{
"mcpServers": {
"llm-ledger": {
"command": "node",
"args": ["/absolute/path/to/llm-ledger/dist/index.js"]
}
}
}Scripts
npm run build # compile TypeScript → dist/
npm test # vitest (CSV parse + aggregation + sync mocks)
npm start # run MCP server on stdioExample flow
Export usage CSV from OpenAI / Anthropic / OpenRouter, or set the env var and call the sync tool for the last 30 days.
Ask your MCP client: Import this OpenAI CSV tagged as project
acme.Set budget for acme to $150/month.
Check budget for acme. / Invoice summary for September.
License
MIT — see LICENSE.
Attribution
Built as an open-source TypeScript MCP server using @modelcontextprotocol/sdk, better-sqlite3, and csv-parse.
Pricing fallbacks are approximate public list rates and may drift — prefer CSVs that include USD cost when accuracy matters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
No tool schema history has been recorded yet.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
- ManiloOAuthapp.manilo
Log, query, and edit expenses, budgets, and accounts in Manilo from any MCP-compatible AI assistant.
Personal finance for AI agents — onboard, import statements, categorize & budget over MCP.
Log, query, and edit expenses, budgets, and accounts in Ledgy from any MCP-compatible AI assistant.
- ManiloOAuthapp.ledgy.api
Log, query, and edit expenses, budgets, and accounts in Manilo (formerly Ledgy) from any MCP-compatible AI assistant.
Related MCP Servers
- AlicenseAqualityAmaintenanceA local-first, multi-provider cost meter for LLM usage, exposed as MCP tools. Captures every call into a local SQLite ledger and lets any coding agent query spend, compare providers, and get recommendations — no cloud, no account. First-class support for Chinese providers (Qwen, DeepSeek) alongside Anthropic and OpenAI.73MIT
- FlicenseNot gradedqualityBmaintenanceA lightweight MCP server that lets LLM clients track, query, and summarize personal expenses using a local SQLite database.-
- FlicenseNot gradedqualityBmaintenanceTracks personal expenses and budgets via MCP, storing entries in SQLite and supporting category-based queries.-
- FlicenseNot gradedqualityCmaintenanceEnables local analysis of personal finance data from a Monter JSON export, answering questions about spending, subscriptions, debts, and more via MCP-capable assistants without any cloud servers.-
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Zacsladden1/llm-ledger'
If you have feedback or need assistance with the MCP directory API, please join our Discord server