ledger-mcp
This server provides double-entry ledger operations via MCP tools.
Create accounts with a name and an account type (asset, liability, equity, revenue, expense).
Record transactions with a transaction ID, optional memo, and an array of entries that include account, amount_cents, and side; debits must equal credits.
Get the balance of an account in cents.
Reconcile the ledger by checking that total debits equal total credits.
Click on "Deploy 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., "@ledger-mcp record a $50 transfer from checking to savings"
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.
ledger-mcp
I built this over two days to figure out where an MCP server's correctness actually lives — in the tool implementation, or in the schemas the model sees.
The domain is a double-entry ledger, because it has a hard definition of "wrong": debits have to equal credits, or the books don't reconcile. So there's no room to hand-wave that the agent did "something reasonable." Either the reconcile call comes back balanced or it doesn't.
What's in the repo
ledger.py is a small SQLite-backed double-entry ledger. Amounts are integer cents so nothing rounds. test_ledger.py covers it with 7 pytest cases.
server.py wraps the ledger as an MCP server with four tools: create_account, record_transaction, get_balance, reconcile.
Day 1 ended there — server running, the four tools discoverable from Claude Desktop, the sample scenario (record a $250 sale, an $80 supplies purchase on account, pay it off) ran end-to-end.
Day 2 is the eval work.
evals/cases.py— 10 test cases split across three buckets: five that should just work, three that probe specific design leaks I noticed in Day 1 (dollar-vs-cent ambiguity, no discovery tool for existing accounts, silent account creation on ambiguous prompts), and two restraint cases where the agent shouldn't touch the ledger at all (accounting theory question, advice question).evals/harness.py— runs each case through Claude via the Anthropic Messages API with the real MCP server spawned as a subprocess. Each case gets its own SQLite file (server.pyreadsLEDGER_DB_PATHfrom the env), so cases are fully isolated. Every tool call is captured, transcripts land inevals/transcripts/.evals/inspect_request.py— dry-runs a case and prints the exact request body the harness would POST. No API key, no cost. This turned out to be the most useful thing in the repo.
Related MCP server: ledgerkit-mcp
What the schema audit found
Before running anything against the API I used inspect_request to look at the tool payload the model would actually receive. The docstrings and the JSON schema were telling different stories.
record_transaction.entries at baseline-v1:
"entries": {
"items": { "additionalProperties": true, "type": "object" },
"type": "array"
}The docstring said each entry needs account, amount_cents, and side. The schema said "array of arbitrary objects." Same pattern on side (no debit/credit enum), on account_type (no enum for the five valid values), and on amount_cents — no type constraint anywhere inside entries.items, so nothing prevents the model from passing 42.50 and getting silently truncated to 42 at the SQLite integer column.
Everything I cared about lived in prose.
Full baseline payload: evals/baseline_schemas/tools_payload_baseline.txt.
What I changed
Four edits to server.py, in expected-impact order:
Introduced a
LedgerEntrypydantic model withaccount: str,amount_cents: int (gt=0),side: Literal["debit","credit"].entries.itemsnow$refs a proper nested type in the schema.Literal["asset","liability","equity","revenue","expense"]onaccount_type. Now visible in the schema as an enum.Rewrote
get_balance's docstring to explain the sign convention — positive means "normal balance" for assets and expenses, the reverse for liabilities/equity/revenue. Signal change, not a schema change, but it's semantic detail types can't carry.Added a concrete example call inside
record_transaction's docstring.
Fixed payload: evals/baseline_schemas/tools_payload_fixed.txt. The two files are meant to be diffed.
7/7 unit tests still pass.
What I did not do
The harness is real. Running it against claude-sonnet-4-5-20250929 takes ~3 minutes and would cost a few cents. I did not run it against both tags for one honest reason: I hit my Anthropic API credit limit before I could. So this README doesn't quote a pass/fail delta — the schema diff is the evidence here. Anyone with a key can reproduce the behavioral run in one command.
Two things I deliberately left out of the M10 fix pass, even though NOTES.md argues for them:
A
list_accountsdiscovery tool. Right now the model has no way to check what accounts exist before referencing them.Structured error objects instead of raw
ValueErrorstrings.
Both are real design improvements, not schema tightening. I kept the fix pass to one thing so the before/after diff would be readable.
Running it
uv sync
uv run pytest -q # unit tests
uv run python -m evals._smoketest # verify MCP plumbing, no API
uv run python -m evals.inspect_request simple_sale # inspect the wire payloadFull agent eval:
export ANTHROPIC_API_KEY="sk-ant-..."
export EVAL_MODEL="claude-sonnet-4-5-20250929"
uv run python -m evals.harnessPer-case transcripts go to evals/transcripts/, and _summary.json collects the pass/fail table.
Tags
baseline-v1— Day 1 tools as originally shipped, schemas untouched.fixes-v1— after the M10 schema tightening.
git diff baseline-v1 fixes-v1 -- server.py is the source-level change. The two files in evals/baseline_schemas/ are the wire-level change.
NOTES.md
The raw build log lives in NOTES.md. It reads rough on purpose — it's the actual notes I wrote while building, not a cleaned-up narrative. If anything in this README seems too tidy, that file has the friction.
Available Tools
4 toolscreate_accountB
Create a new account in the ledger.
account_type must be one of: asset, liability, equity, revenue, expense.
Inputs: name (required), account_type (required).
get_balanceB
Get the balance of an account, in cents.
Inputs: account_name (required).
reconcileA
Check that total debits equal total credits across the ledger.
Inputs: no named parameters.
record_transactionC
Record a transaction in the ledger.
entries is a list of dicts with keys: account, amount_cents, side.
Debits must equal credits.
Inputs: entries (required), transaction_id (required), memo.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool targets a distinct action—account creation, transaction recording, balance retrieval, and reconciliation—with no overlapping responsibilities. The purposes are clearly separated, leaving no ambiguity for an agent to misselect.
Most tool names follow the verb_noun pattern (create_account, record_transaction, get_balance), but 'reconcile' is a single verb without a noun object. This minor deviation is not confusing but breaks the otherwise consistent pattern.
Four tools is well-scoped for a focused ledger server, covering the essential operations of account creation, transaction recording, balance queries, and reconciliation. Each tool earns its place without redundancy.
The core workflow (create account, record transaction, get balance, reconcile) is present, but notable gaps exist: there is no way to list accounts or view transaction history, and no update/delete operations for accounts or transactions. These missing read/audit functions could hinder some workflows.
Maintenance
Related MCP Connectors
Personal finance for AI agents — onboard, import statements, categorize & budget over MCP.
Personal finance ledger for AI agents — query spending, track bills, forecast cash flow.
AI agents for bookkeeping, reconciliation, and financial close for SMBs.
Agent-native double-entry accounting ledger with x402 micropayments
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceDouble-entry accounting ledger MCP server for autonomous agents that enables creating accounts, posting journal entries, and generating financial reports.MIT
- AlicenseAqualityDmaintenanceEnables AI agents to interact with a double-entry ledger, offering tools for account management, balanced journal entries, balance queries, trial balance, and penny-perfect allocation. Built with safety by construction: no update/delete tools, idempotent posting, and an append-only journal.7MIT
- AlicenseNot gradedqualityDmaintenanceProvides financial audit reporting and ledger query tools for AI agents, enabling generation of compliance, risk, and transaction reports and querying of transaction data, balances, and summaries from an in-memory SQLite database via MCP.MIT
- FlicenseAqualityDmaintenanceMCP server for hledger that exposes double-entry accounting tools to AI agents, enabling balance queries, transaction history, budget reports, and adding transactions to a journal.4-