expense-tracker-mcp

expense-tracker-mcp

A personal expense tracker exposed over MCP, enabling users to log and query expenses in natural language sentences. It features category inference, recurring expenses, soft deletes, and SQLite storage with no external database.

Category
访问服务器

README

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 softundo_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.

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

Writeadd_expense, add_expenses, update_expense, update_last, delete_expense, undo_last

Readlist_categories, query_expenses, summarize, search_expenses

Budgets & recurringset_budget, budget_status, add_recurring, list_recurring, delete_recurring

Maintenancebackup_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).

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选