databasedmcp

← Articles

How to build a budget and expense tracker with Claude

Set a monthly budget per category, tell Claude what you spent, and ask how much is left before you buy the thing.

6 min read

databasedmcp gives your AI assistant databases it keeps between conversations, so everything in this article works from the day you connect it. Free to start, no card.

Get started free

Why build it yourself

Budgeting apps like YNAB give every category a monthly amount and show what's left as you spend. The method is the valuable part, and it needs less than you'd think: categories, a budget per month and a list of what you spent.

Claude can file a purchase from a sentence, or a whole card statement you paste in, and put each line in the right category. "Can I afford dinner out this week?" becomes a question you ask, not a screen you look for.

Connect Claude to databasedmcp

databasedmcp is a remote MCP server that gives AI assistants private SQLite databases, with nothing to install.

In Claude on the web, desktop or mobile, open Settings → Connectors, choose Add custom connector and enter https://databasedmcp.com/mcp. Select Connect, sign in to databasedmcp with your email or Google, and select Allow. Then turn databasedmcp on for a conversation from the tools menu.

Claude asks before it runs anything that changes or deletes data. Reading runs without asking.

Any other MCP client works the same way; the docs have the details.

Copy this prompt to build it

Paste this into Claude to set up the database, its tables and its guide in one go. The rest of this article walks through what it makes and how you use it.

prompt
Set up a budget for me in databasedmcp, in one go.

1. Create a database called budget, described as "Budget: categories, monthly budgets and transactions in cents, filed by Claude from what I tell it or paste in".
2. Create three tables:
   - categories: id, name (required, unique).
   - budgets: id, month (YYYY-MM, required), category_id (references categories), amount_cents (required, whole cents). One budget per category per month: make month and category_id unique together.
   - transactions: id, spent_on (date, defaults to today), amount_cents (required, whole cents: negative for spending, positive for income), payee (required), category_id (references categories, NULL for income), note.
3. Write the database a guide that says what each table is for, to reuse an existing category before adding another, never to store card or account numbers since payee and amount are enough, to insert a pasted statement in one statement and tell me which lines you weren't sure how to categorise, and the query for "how much is left in each category this month" (budget, spent and remaining per category).

From then on: when I tell you about a purchase, refund or payment in, add a transaction in the right category. When I paste lines from a statement, file them all at once. When I set a month's budget, add a row per category. Show me the tables when you're finished.

Ask for the database

You don't write the schema. Describe what you want:

Set up a budget in databasedmcp: spending categories, a budget per category per month, and every transaction I tell you about or paste in. Store amounts in cents, spending as negative and income as positive. Don't store card or account numbers.

Claude creates a database called budget and its tables:

schema
CREATE TABLE categories (
  id INTEGER PRIMARY KEY,
  name TEXT NOT NULL UNIQUE
);

CREATE TABLE budgets (
  id INTEGER PRIMARY KEY,
  month TEXT NOT NULL,
  category_id INTEGER NOT NULL REFERENCES categories(id),
  amount_cents INTEGER NOT NULL,
  UNIQUE (month, category_id)
);

CREATE TABLE transactions (
  id INTEGER PRIMARY KEY,
  spent_on TEXT NOT NULL DEFAULT (date('now')),
  amount_cents INTEGER NOT NULL,
  payee TEXT NOT NULL,
  category_id INTEGER REFERENCES categories(id),
  note TEXT
);

It also writes the database a guide on how the tables are meant to be used. The guide comes back with the schema whenever an assistant looks the database up. Claude files things the same way next week as today, and so does any other assistant you connect.

guide
# budget: categories, monthly budgets, transactions

- **categories**: what money goes to. Reuse an existing one before adding another.
- **budgets**: one row per category per month (`month` is YYYY-MM), in cents.
- **transactions**: one row per purchase, refund or payment in. `amount_cents` is negative for spending, positive for income. `category_id` is NULL for income. Never store card or account numbers: payee and amount are enough.

Left this month: `SELECT c.name, b.amount_cents / 100.0 AS budget, -coalesce(sum(t.amount_cents), 0) / 100.0 AS spent, (b.amount_cents + coalesce(sum(t.amount_cents), 0)) / 100.0 AS remaining FROM budgets b JOIN categories c ON c.id = b.category_id LEFT JOIN transactions t ON t.category_id = b.category_id AND strftime('%Y-%m', t.spent_on) = b.month WHERE b.month = strftime('%Y-%m', 'now') GROUP BY b.id ORDER BY remaining`

When I paste a statement, insert all lines in one statement and tell me which ones you weren't sure how to categorise.

Use it

From here on you talk, and Claude writes the rows. Each request below is one statement:

My categories are rent, groceries, eating out and transport.
execute
INSERT INTO categories (name) VALUES (?), (?), (?), (?)
-- params: ["Rent","Groceries","Eating out","Transport"]
This month: 1,200 for rent, 450 for groceries, 150 for eating out and 80 for transport.
execute
INSERT INTO budgets (month, category_id, amount_cents) VALUES (strftime('%Y-%m', 'now'), 1, ?), (strftime('%Y-%m', 'now'), 2, ?), (strftime('%Y-%m', 'now'), 3, ?), (strftime('%Y-%m', 'now'), 4, ?)
-- params: [120000,45000,15000,8000]

Cents, not decimals, so sums never come out as 449.99999.

Got paid today, 3,150.
execute
INSERT INTO transactions (amount_cents, payee) VALUES (?, ?)
-- params: [315000,"Salary, Halden Works"]
Here's my card from this week: Corner Market 64.20, Tram pass 49.00, Luna Noodle Bar 31.50, Corner Market 18.75.
execute
INSERT INTO transactions (spent_on, amount_cents, payee, category_id) VALUES (date('now', '-4 days'), ?, ?, 2), (date('now', '-3 days'), ?, ?, 4), (date('now', '-2 days'), ?, ?, 3), (date('now', '-1 day'), ?, ?, 2)
-- params: [-6420,"Corner Market",-4900,"Tram pass",-3150,"Luna Noodle Bar",-1875,"Corner Market"]
Paid rent.
execute
INSERT INTO transactions (amount_cents, payee, category_id) VALUES (?, ?, ?)
-- params: [-120000,"Rent",1]

Ask it questions

Once there's data, each report you'd pay for is a single query:

How much is left in each category this month?
query
SELECT c.name, b.amount_cents / 100.0 AS budget, -coalesce(sum(t.amount_cents), 0) / 100.0 AS spent, (b.amount_cents + coalesce(sum(t.amount_cents), 0)) / 100.0 AS remaining FROM budgets b JOIN categories c ON c.id = b.category_id LEFT JOIN transactions t ON t.category_id = b.category_id AND strftime('%Y-%m', t.spent_on) = b.month WHERE b.month = strftime('%Y-%m', 'now') GROUP BY b.id ORDER BY remaining
Where does my money go? Top payees over the last three months.
query
SELECT payee, count(*) AS times, -sum(amount_cents) / 100.0 AS spent FROM transactions WHERE amount_cents < 0 AND spent_on >= date('now', '-3 months') GROUP BY payee ORDER BY spent DESC LIMIT 10
Am I spending less than I earn, month by month?
query
SELECT strftime('%Y-%m', spent_on) AS month, sum(CASE WHEN amount_cents > 0 THEN amount_cents ELSE 0 END) / 100.0 AS income, -sum(CASE WHEN amount_cents < 0 THEN amount_cents ELSE 0 END) / 100.0 AS spending, sum(amount_cents) / 100.0 AS saved FROM transactions GROUP BY month ORDER BY month DESC

You can also open the database on the website, page through its rows and run read-only SQL yourself.

What you give up

There's no bank sync, and that's the big one. YNAB and other budgeting apps pull transactions from your bank by themselves. Here, a transaction exists because you said it or pasted it. Some people find that typing it in is what makes them notice the spending. If you'd rather not, the sync is what you pay for.

There's no reconciling against your account balance, no shared budget app for a partner and no goals screen. Your partner, if you invite them, can see the database and run queries, but the writing goes through an assistant.

Try it

databasedmcp is free to start, with no card. Free has 100 tool calls a week, enough to set this up and try it for a week. Starter has 1,000 for everyday use.

Create an account

More articles · databasedmcp · Docs