databasedmcp

← Articles

Alternative to Splitwise: a shared expenses tracker with ChatGPT

Tell ChatGPT who paid for what on the trip. It splits each expense, keeps the balances and tells you who owes whom.

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

Splitwise is how a lot of trips, flats and couples keep money fair: someone pays for dinner, it gets split, and at the end everyone can see who owes whom. Underneath, it's a list of expenses, a split for each and a running balance.

That's four small tables and one query. ChatGPT is good at turning "Ben got dinner, 96 euros, Chiara had the expensive fish" into numbers. The database keeps every expense and payment, so the balance is always the sum of what happened, not a figure someone remembers.

Connect ChatGPT to databasedmcp

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

ChatGPT connects to remote MCP servers as custom connectors in developer mode. That's on paid plans, on the web. Turn on developer mode in ChatGPT's settings, then create a connector: give it a name, enter https://databasedmcp.com/mcp as the URL and choose OAuth. When ChatGPT opens a databasedmcp page, sign in and select Allow. In a new chat, turn the connector on from the tools menu.

ChatGPT moves these menus between releases. If yours look different, search its settings for developer mode and custom connectors.

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

Copy this prompt to build it

Paste this into ChatGPT 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 shared expenses tracker for me in databasedmcp, in one go.

1. Create a database called shared_expenses, described as "Shared expenses: who paid, how it's split and who owes whom".
2. Create four tables:
   - people: id, name (required, unique).
   - expenses: id, spent_on (date, defaults to today), what (required), amount (required), paid_by (references people, required).
   - shares: id, expense_id (references expenses), person_id (references people), amount (required): each person's part of an expense.
   - payments: id, paid_on (date, defaults to today), from_id and to_id (both reference people), amount (required), note. A payment records someone paying someone back. It doesn't move money.
3. Write the database a guide that says what each table is for, that all amounts are in one currency, that an expense's shares add up to its amount, and the queries for "everyone's balance" (paid minus shares, plus payments made, minus payments received) and "expenses whose shares don't add up".

From then on: when I say someone paid for something, add the expense and its shares (split equally unless I say otherwise). When I say someone paid someone back, add a payment. 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 shared expenses tracker in databasedmcp for our Lisbon trip: me (Aino), Ben and Chiara. When I say someone paid for something, split it and keep track of who owes whom. Record it when someone pays someone back.

ChatGPT creates a database called shared_expenses and its tables:

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

CREATE TABLE expenses (
  id INTEGER PRIMARY KEY,
  spent_on TEXT NOT NULL DEFAULT (date('now')),
  what TEXT NOT NULL,
  amount REAL NOT NULL,
  paid_by INTEGER NOT NULL REFERENCES people(id)
);

CREATE TABLE shares (
  id INTEGER PRIMARY KEY,
  expense_id INTEGER NOT NULL REFERENCES expenses(id),
  person_id INTEGER NOT NULL REFERENCES people(id),
  amount REAL NOT NULL
);

CREATE TABLE payments (
  id INTEGER PRIMARY KEY,
  paid_on TEXT NOT NULL DEFAULT (date('now')),
  from_id INTEGER NOT NULL REFERENCES people(id),
  to_id INTEGER NOT NULL REFERENCES people(id),
  amount REAL NOT NULL,
  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. ChatGPT files things the same way next week as today, and so does any other assistant you connect.

guide
# shared_expenses: who paid, who owes

- **people**: everyone sharing costs.
- **expenses**: one row per thing someone paid for. `paid_by` is who paid.
- **shares**: each person's part of an expense. Split equally unless told otherwise; the shares add up to the expense's amount.
- **payments**: someone paying someone back. It records the payment; it doesn't move money.

All amounts are in euros. Positive balance: owed money. Negative: owes money.

Balances: `WITH b AS (SELECT paid_by AS person_id, amount FROM expenses UNION ALL SELECT person_id, -amount FROM shares UNION ALL SELECT from_id, amount FROM payments UNION ALL SELECT to_id, -amount FROM payments) SELECT p.name, round(coalesce(sum(b.amount), 0), 2) AS balance FROM people p LEFT JOIN b ON b.person_id = p.id GROUP BY p.id ORDER BY balance DESC`

Shares that don't add up: `SELECT e.id, e.what, e.amount, coalesce(sum(s.amount), 0) AS shared FROM expenses e LEFT JOIN shares s ON s.expense_id = e.id GROUP BY e.id HAVING abs(e.amount - shared) > 0.01`

Use it

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

It's me, Aino, plus Ben and Chiara.
execute
INSERT INTO people (name) VALUES (?), (?), (?)
-- params: ["Aino","Ben","Chiara"]
I paid 240 euros for the apartment. Split it three ways.
execute
INSERT INTO expenses (what, amount, paid_by) VALUES (?, ?, ?) RETURNING id
-- params: ["Apartment, Alfama",240,1]

ChatGPT splits it equally.

execute
INSERT INTO shares (expense_id, person_id, amount) SELECT ?, id, round(? / (SELECT count(*) FROM people), 2) FROM people
-- params: [1,240]

For an uneven split, the shares get different amounts: "Chiara had the fish" becomes a bigger share for Chiara.

Ben sent me 80 for his part of the apartment.
execute
INSERT INTO payments (from_id, to_id, amount, note) VALUES (?, ?, ?, ?)
-- params: [2,1,80,"Apartment"]

This records that Ben paid. The money itself moves however you usually send it.

Ask it questions

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

Who owes whom?
query
WITH b AS (SELECT paid_by AS person_id, amount FROM expenses UNION ALL SELECT person_id, -amount FROM shares UNION ALL SELECT from_id, amount FROM payments UNION ALL SELECT to_id, -amount FROM payments) SELECT p.name, round(coalesce(sum(b.amount), 0), 2) AS balance FROM people p LEFT JOIN b ON b.person_id = p.id GROUP BY p.id ORDER BY balance DESC

Aino is owed 80, Ben is square and Chiara owes 80. With more people and expenses, ChatGPT reads the balances and suggests the fewest payments that settle everyone.

Is every expense split properly?
query
SELECT e.id, e.what, e.amount, coalesce(sum(s.amount), 0) AS shared FROM expenses e LEFT JOIN shares s ON s.expense_id = e.id GROUP BY e.id HAVING abs(e.amount - shared) > 0.01
What has everyone paid for so far?
query
SELECT p.name, count(e.id) AS expenses, round(coalesce(sum(e.amount), 0), 2) AS paid FROM people p LEFT JOIN expenses e ON e.paid_by = p.id GROUP BY p.id ORDER BY paid DESC

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

What you give up

With Splitwise, everyone in the group has the app, adds their own expenses and gets told when someone adds one. Here, one person keeps the log for the group, or you share your databasedmcp account so the others can see the balances on the website. Adding expenses still goes through an assistant, and nothing notifies anyone.

It doesn't move money or connect to any payment app, and it has no receipt photos. As written, it keeps one currency per database. If the trip crosses currencies, tell ChatGPT the rate you used and store the converted amount. For a household that shares costs every week for years, a dedicated app with everyone on it is easier.

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