Expense Tracker MCP Server
Enables natural language expense management by converting user requests into validated database operations, including adding, searching, updating, deleting, and summarizing expenses through MCP tools over SQLite.
README
Expense Tracker Agent
An AI-powered personal expense tracker that turns natural-language requests into structured database operations. The project combines a responsive Streamlit interface, Claude tool use, an MCP server, and local SQLite storage.
What this project demonstrates
- Agentic, multi-step tool use for real database workflows
- A clean separation between the language model, MCP transport, and data layer
- A direct Claude tool-calling loop without an orchestration framework
- Input validation, scoped assistant behavior, and safe local data handling
- Automated smoke tests and continuous integration
- A responsive user interface for entry, conversation, and spending insights
Product features
- Add expenses through a form or a natural-language request
- Store the date, amount, category, and description for each transaction
- Search, update, delete, and summarize expenses through MCP tools
- Review totals, recent transactions, and category-level spending
- Ask the focused financial assistant for database-backed insights
- Keep expense data local in a SQLite file
Architecture
flowchart LR
U[User] --> UI[Streamlit or CLI]
UI --> A[Claude agent]
A -->|Tool request| C[MCP client]
C -->|stdio| S[MCP server]
S -->|DB-API 2.0| D[(SQLite)]
D --> S
S -->|Structured result| A
A --> UI
Claude never accesses SQLite directly. It selects from the MCP tool schemas, and the server owns every validated database read and write.
Example agent workflows
| User intent | Tool sequence |
|---|---|
| Add a lunch expense | find_category → add_expense |
| Change yesterday's gas amount | search_expenses → update_expense |
| Delete a matching purchase | search_expenses → delete_expense |
| Review monthly spending | monthly_summary |
Technology
| Layer | Technology |
|---|---|
| Interface | Streamlit, pandas |
| Language model | Anthropic Claude |
| Agent integration | Direct Messages API tool-use loop |
| Tool protocol | Model Context Protocol over stdio |
| Data | SQLite through Python DB-API 2.0 |
| Quality | pytest, Black, GitHub Actions |
Quick start
Requirements:
- Python 3.11 or newer
- An Anthropic API key for the assistant
Create and activate a virtual environment:
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install -r requirements.txt
For macOS or Linux, activate the environment with:
source .venv/bin/activate
Create a local environment file and add ANTHROPIC_API_KEY:
Copy-Item .env.example .env
Create the database schema and starter categories, then launch the app:
python db_setup.py
streamlit run streamlit_app.py
The MCP server uses stdio and starts automatically when a client connects.
Quality checks
Install development dependencies and run the same checks used in CI:
python -m pip install -r requirements-dev.txt
python -m black --check .
python -m compileall -q agent.py client_test.py db_setup.py mcp_client.py server.py streamlit_app.py
python -m pytest -q
python client_test.py
client_test.py exercises all 18 MCP tools and removes its temporary records
when the smoke test finishes.
MCP tools
The server exposes 18 tools:
- Category management:
list_categories,add_category,rename_category,delete_category,get_category_name - Expense management:
add_expense,update_expense,delete_expense,list_expenses,search_expenses,expenses_by_category,total_expense_by_category,total_expense,monthly_summary - Supporting queries:
current_date,find_category,get_expense,expenses_between
Project structure
| Path | Purpose |
|---|---|
streamlit_app.py |
Form, assistant, and insights interface |
agent.py |
Claude tool-calling loop and command-line interface |
server.py |
Validated SQLite operations exposed as MCP tools |
mcp_client.py |
Reusable stdio MCP client |
db_setup.py |
Schema and starter-category initialization |
client_test.py |
End-to-end MCP tool smoke test |
tests/ |
Automated database and UI checks |
.github/workflows/ci.yml |
Continuous-integration pipeline |
Configuration
| Variable | Required | Default |
|---|---|---|
ANTHROPIC_API_KEY |
Yes | — |
ANTHROPIC_MODEL |
No | claude-sonnet-5 |
AGENT_EFFORT |
No | medium |
EXPENSE_DB |
No | expenses.db beside the source files |
The .env file and expenses.db are excluded from Git. API keys and personal
expense data stay outside the repository.
To recreate the database with an empty expenses table:
python db_setup.py --reset
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。