Hamara Hisaab
Self-hosted household finance app for shared expenses, budgets, investments, loans, and zakat, exposing MCP tools for AI agents to manage finances via natural language.
README
Hamara Hisaab — ghar ka sara hisaab, ek jagah
Self-hosted household finance app: shared expense/income ledger, budgets, an investment portfolio (with automatic PSX + Pakistani mutual fund prices), loans (qarz), recurring bills and a zakat helper. API-first: everything the web app can do, any AI agent can do too — via MCP or plain REST.
Stack
One Node process (Hono) serving the REST API, an MCP endpoint and a React PWA, plus Postgres.
Two containers, one docker compose up.
Quick start
cp .env.example .env # set DB_PASSWORD, BETTER_AUTH_SECRET (openssl rand -base64 32), APP_URL
docker compose up -d --build
Open the app (default http://localhost:3000, change host port with APP_PORT in .env):
- Register — creates your account.
- Create your household — you get an invite code.
- Your spouse registers and joins with the invite code → shared ledger, entries attributed per person.
- More → Agents & API keys — create one API key per agent (one for you, one for your spouse's agent, etc.).
Connecting agents
Every operation is exposed two ways; both authenticate with a per-user API key. The key's owner is recorded as the payer on entries the agent makes.
MCP (Claude, ChatGPT, and any MCP-capable agent)
Streamable-HTTP endpoint at https://your-host/mcp — 26 tools
(add_transaction, get_budget_status, get_portfolio, get_monthly_report, add_loan,
get_zakat_summary, …).
# Claude Code
claude mcp add finance --transport http https://your-host/mcp --header "x-api-key: YOUR_KEY"
Authorization: Bearer YOUR_KEY also works for clients that only support bearer auth.
Daily WhatsApp summary: schedule your agent (Hermes cron, Claude scheduled task, n8n…) to call
get_daily_brief (or GET /api/v1/reports/brief) every morning — it returns yesterday's spending,
month-to-date, budget-pace warnings, bills due within 7 days, open qarz and a zakat reminder,
plus a ready-to-post text rendering for the family group.
REST (Hermes, OpenClaw, scripts, anything)
Same operations at /api/v1/* with the x-api-key header — e.g. your WhatsApp Hermes agent logs an expense with:
curl -X POST https://your-host/api/v1/transactions \
-H "x-api-key: YOUR_KEY" -H "content-type: application/json" \
-d '{"type":"expense","amount":2500,"category":"Groceries","note":"Imtiaz weekly run"}'
Resources: transactions, categories, budgets (+ /budgets/status), accounts,
portfolio, holdings, instruments, prices (+ /prices/refresh), loans (+ /:id/payments),
recurring, reports/monthly, reports/overview?period=week|month|quarter|year&offset=-N
(or ?from=YYYY-MM-DD&to=YYYY-MM-DD for a custom range — totals, previous-period comparison,
trend buckets, category/member breakdowns; also the get_report MCP tool), zakat, household.
Amounts are PKR; dates are YYYY-MM-DD (Asia/Karachi).
Price data (automatic)
A daily job (18:30 & 22:00 PKT) fetches:
- PSX stocks — closing price from
dps.psx.com.pk(unofficial endpoint; fails soft). - Mutual funds — daily NAVs scraped from the MUFAP NAV table.
When adding a fund, use the exact fund name as it appears there (e.g.
Al Meezan Mutual Fund,Mahaana Islamic Cash Fund). - Other assets (gold, property…) — manual valuation via Set price; manual prices always win over fetched ones.
Recurring bills materialize into the ledger on their due day (00:15 PKT, with catch-up after downtime).
Going public with Cloudflare Tunnel
To reach the app (and its /mcp endpoint) from anywhere — phones, WhatsApp agents — without opening ports:
- Add your domain to Cloudflare (free plan is fine).
- Zero Trust dashboard → Networks → Tunnels → Create a tunnel → Cloudflared connector → name it (e.g.
hisaab). - On the connector page pick Docker, copy the token from the shown command, and put it in
.envasTUNNEL_TOKEN=.... - Add a Public hostname:
hisaab.yourdomain.com→ service HTTP →app:3000. - Update
.env:APP_URL=https://hisaab.yourdomain.com TRUSTED_ORIGINS=http://localhost:9700 # keep local login working (match your APP_PORT) docker compose --profile public up -d --build- Register your household members at the public URL, then set
DISABLE_SIGNUPS=truein.envand restart — no strangers can create accounts on your instance.
Agents then connect to https://hisaab.yourdomain.com/mcp (header x-api-key) from anywhere.
Development
docker compose up -d db # Postgres on localhost:5433
npm install
npm run dev # API + SPA-serving on :3000 (PORT=3001 to change)
npm run dev:web # optional: Vite dev server with HMR, proxies /api → :3001
npm run db:generate # regenerate SQL migration after editing src/db/schema.ts
npm run typecheck && npm run build
npm test # integration + unit tests (vitest, real Postgres, no network)
npm run test:e2e # Playwright browser tests against a fresh e2e database
Auth tables (src/db/auth-schema.ts) are generated:
npx @better-auth/cli generate --config scripts/auth-config.ts --output src/db/auth-schema.ts.
Layout: src/services/ holds all business logic; src/routes.ts (REST) and src/mcp.ts (MCP tools)
are thin wrappers over the same services, so the two surfaces can't drift.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。