Skip to main content
Glama
expense-tracker-mcp

expense-tracker-mcp

Expense Tracker (MCP)

A single-user, PKR-only personal expense tracker exposed over MCP, so an agent is the primary interface. Log spending in one sentence — "4500 groceries at Imtiaz" — and ask for totals in another.

Storage is SQLite, embedded in the server process. There is no separate database container to run.

Design notes

  • Amounts are integer paisa in storage; rupees are only used at the tool boundary.

  • Only amount is required to log an expense. The date defaults to today, and the category is inferred from previous expenses at the same merchant.

  • Categories are a fixed list (list_categories) so spelling can't fragment your reports.

  • Deletes are soft — undo_last() restores.

  • Duplicates warn, they don't block. An identical amount/merchant/date returns a possible_duplicate id and saves anyway.

  • Recurring expenses post themselves on the first tool call after their day passes, tagged recurring. Nothing is scheduled and nothing double-posts.

  • Payday is the 1st, so every reporting period is a plain calendar month.

Related MCP server: expense-mcp

Run it

The server speaks streamable HTTP at /mcp. It runs as a long-lived container, not one spawned per session.

docker compose up -d --build

That publishes http://127.0.0.1:8000/mcp and restarts with Docker.

docker compose logs -f     # follow
docker compose down        # stop

OpenClaw MCP config

{
  "mcpServers": {
    "expense-tracker": {
      "type": "http",
      "url": "http://localhost:8000/mcp"
    }
  }
}

Security

The endpoint has no authentication — anything that can reach the port can read and edit the ledger. Two things keep that contained, and both matter:

  • Compose publishes on 127.0.0.1 only, so the port is not on your network. Don't change that to 0.0.0.0 without putting auth in front of it.

  • DNS-rebinding protection is on, so a browser page can't quietly drive the server.

If you publish on a host port other than 8000, requests fail with HTTP 421 Misdirected Request — the Host header no longer matches the allowlist. Set EXPENSE_TRACKER_ALLOWED_HOSTS to match, e.g. localhost:9000,127.0.0.1:9000.

stdio instead

Still supported, for debugging or a per-session launch:

docker run -i --rm -e EXPENSE_TRACKER_TRANSPORT=stdio \
  -v "$PWD/data:/data" -v "$PWD/backups:/backups" expense-tracker:latest

-i is required and -t must not be passed — under stdio a TTY corrupts the JSON-RPC framing.

Data and backups

Host

Container

Contents

./data

/data

live expenses.db

./backups

/backups

daily VACUUM INTO snapshots, last 14 kept

Both are gitignored. A snapshot is taken on the first tool call of each day, and backup_now() forces one.

Both directories live inside this project, so deleting it deletes the history and the backups. If this data comes to matter, sync ./backups somewhere off-machine.

If SQLite locking misbehaves over the Docker Desktop bind mount, set EXPENSE_TRACKER_JOURNAL=DELETE.

Environment

Variable

Default (container)

EXPENSE_TRACKER_TRANSPORT

http (or stdio)

EXPENSE_TRACKER_HOST

0.0.0.0 (127.0.0.1 outside Docker)

EXPENSE_TRACKER_PORT

8000

EXPENSE_TRACKER_ALLOWED_HOSTS

localhost:8000,127.0.0.1:8000

EXPENSE_TRACKER_DB

/data/expenses.db

EXPENSE_TRACKER_BACKUP_DIR

/backups

EXPENSE_TRACKER_JOURNAL

WAL

TZ

Asia/Karachi

TZ matters: on UTC the container dates anything logged after 7pm PKT to the previous day, skewing daily totals and month boundaries.

Tools

Write — add_expense, add_expenses, update_expense, update_last, delete_expense, undo_last

Read — list_categories, query_expenses, summarize, search_expenses

Budgets & recurring — set_budget, budget_status, add_recurring, list_recurring, delete_recurring

Maintenance — backup_now

query_expenses defaults to the current month and caps at 50 rows. For totals, use summarize — it aggregates in SQL rather than returning rows to be added up.

Development

uv sync --group dev && uv run pytest

Run the server outside Docker with uv run expense-tracker — HTTP on 127.0.0.1:8000, against ./data/expenses.db.

The suite covers both transports: a real MCP client over HTTP against a booted server, and a stdio startup that must leave stdout completely empty (under stdio, stdout carries the protocol, so a stray print() corrupts it — log to stderr only).

Available Tools

16 tools
add_expenseA

Log an expense in PKR. Only amount is required.

date accepts YYYY-MM-DD, 'today', 'yesterday', '-3d', or a day number; it defaults to today. When category is omitted it is inferred from previous expenses at the same merchant. The returned record reflects what was actually saved, including anything inferred.

Inputs: amount (required), date, note, tags, +2 more. Returns: object

add_expensesA

Log several expenses at once. Each item takes the same fields as add_expense.

Items are validated individually: a bad entry is reported in errors while the rest still save.

Inputs: items (required). Returns: object

add_recurringA

Add a monthly recurring expense (rent, internet, subscriptions).

It posts itself on day_of_month each month, tagged 'recurring'. A day past the end of a short month posts on that month's last day. If the day has already passed this month, it posts immediately.

Inputs: amount (required), day_of_month (required), category, merchant. Returns: object

backup_nowA

Write a consistent snapshot of the database to the backups directory.

Inputs: no named parameters. Returns: object

budget_statusA

Budget vs. actual for a month ('YYYY-MM', default current), with burn pace.

Inputs: month. Returns: object

delete_expenseA

Delete an expense. Soft delete — undo_last() restores it.

Inputs: id (required). Returns: object

delete_recurringA

Stop a recurring expense. Already-posted expenses are left in place.

Inputs: id (required). Returns: object

list_categoriesA

The valid category names. Expenses must use one of these.

Inputs: no named parameters. Returns: result

list_recurringB

All active recurring expenses.

Inputs: no named parameters. Returns: result

query_expensesA

List individual expenses. Defaults to the current month.

For totals use summarize() instead — it is far cheaper than adding up rows here.

Inputs: tags, limit, to_date, category, +4 more. Returns: object

search_expensesA

Free-text search across merchant and note, over all time.

Inputs: text (required), limit. Returns: object

set_budgetB

Set a monthly spending limit in PKR for a category.

Inputs: category (required), monthly_limit (required). Returns: object

summarizeA

Spending totals, pre-computed. Never sum expenses by hand — call this.

group_by is one of category, merchant, month, day, tag. period is one of this_month, last_month, ytd, all; from_date/to_date override it.

Inputs: period, to_date, group_by, from_date. Returns: object

undo_lastB

Restore the most recently deleted expense.

Inputs: no named parameters. Returns: object

update_expenseB

Edit an expense. Omitted fields are left alone; pass "" to clear a text field.

Inputs: id (required), date, note, tags, +3 more. Returns: object

update_lastA

Correct the most recently logged expense without needing its id.

Inputs: date, note, tags, amount, +2 more. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 16 tools

    Disambiguation4/5

    Most tools have clearly distinct roles: adding, editing, deleting, querying, summarizing, budgeting, and recurring expenses. Some pairs like add_expense/add_expenses and query_expenses/search_expenses could be confused, but the descriptions clarify the intended use.

    Naming Consistency4/5

    The majority of tools follow a consistent snake_case verb_noun pattern like add_expense, list_recurring, and delete_expense. A few outliers such as summarize, budget_status, undo_last, and update_last break the pattern slightly, but the overall style is predictable.

    Tool Count4/5

    At 16 tools, the set is slightly above the ideal 3-15 range but still well-scoped for an expense tracker. Each tool covers a meaningful part of the domain without obvious redundancy.

    Completeness5/5

    The tool surface covers the full expense lifecycle: single and bulk creation, updates, deletion, undo, querying, searching, summarizing, budgets, recurring expenses, and backup. Supporting workflows like recurring and budget management have matching setup, status, and teardown tools.

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables users to track personal expenses through natural language interactions with comprehensive category support and financial summaries. Provides both local and remote MCP server options with SQLite storage for fast expense management operations.
      -
    • A
      license
      A
      quality
      D
      maintenance
      Personal expense tracker MCP server that enables tracking expenses, income, budgets, and savings goals through natural language.
      10
      29 PyPI
      1
      MIT
    • F
      license
      B
      quality
      D
      maintenance
      MCP server for tracking personal expenses using FastMCP and SQLite, enabling adding, listing, updating, deleting expenses and summarizing by category via natural language tools.
      5
      1
      -
    • F
      license
      Not graded
      quality
      D
      maintenance
      A lightweight local MCP server for tracking personal or small-team expenses. It lets you add expense entries, list transactions within a date range, and generate simple summaries by category — all backed by a local SQLite database.
      -