AdvancedExpenseTracker
# AdvancedExpenseTracker (FastMCP)
An **AI-powered Expense & Budget Management MCP Server** built using **FastMCP**, **SQLite**, and Python.
This project exposes structured financial tools (expenses, income, budgets, recurring bills, analytics) that can be used by an LLM (like Claude Desktop or Cursor) as a **personal financial advisor**.
---
## ๐ Features Overview
- โ
**Expense Tracking:** Categories, subcategories, tags, notes, and payment methods.
- โ
**Income & Cashflow:** Log earnings and analyze net savings in real-time.
- โ
**Recurring Engine:** Auto-generate daily, weekly, monthly, or yearly bills.
- โ
**Smart Budgeting:** Set limits per category and get "Over Budget" warnings.
- โ
**Search & Filtering:** Find transactions by note, tag, or amount.
- โ
**Metadata Management:** Dynamic control over valid categories & payment methods.
- โ
**Zero-Setup Database:** SQLite database initializes automatically.
---
## ๐๏ธ Architecture
```text
AdvancedExpenseTracker
โ
โโโ expenses.db # SQLite database (auto-created on first run)
โโโ metadata.json # Categories & payment methods (auto-created)
โโโ main.py # MCP server implementation
โโโ README.md
```
---
## ๐ฆ Tech Stack
- **Python 3.10+**
- **FastMCP** (The only external dependency)
- **SQLite** (Built-in, serverless storage)
- **uv** (For ultra-fast dependency management)
---
## โ๏ธ Installation (using uv)
This project is designed to run instantly with **[uv](https://github.com/astral-sh/uv)**. You do not need to manually create virtual environments.
### 1๏ธโฃ Install uv (if not installed)
```bash
# macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# Windows (PowerShell)
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
```
### 2๏ธโฃ Clone the Repository
```bash
git clone <your-repo-url>
cd AdvancedExpenseTracker
```
### 3๏ธโฃ Test Run
You can verify the script works without installing anything globally:
```bash
uv run --with fastmcp main.py
```
*On the first run, this will create `expenses.db` and `metadata.json` automatically.*
---
## ๐ Configuration (Connect to AI)
To use this with Claude Desktop or Cursor, you need to tell them where the script is.
### Option A: Claude Desktop App
1. Open your config file:
* **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
* **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
2. Add the following (Replace `/ABSOLUTE/PATH/TO/` with your real file path):
```json
{
"mcpServers": {
"finance": {
"command": "uv",
"args": [
"run",
"--with",
"fastmcp",
"/ABSOLUTE/PATH/TO/main.py"
]
}
}
}
```
### Option B: Cursor (IDE)
1. Go to **Cursor Settings** > **Features** > **MCP**.
2. Click **+ Add New MCP Server**.
3. **Name:** `Expense Tracker`
4. **Type:** `command`
5. **Command:** `uv run --with fastmcp /ABSOLUTE/PATH/TO/main.py`
---
## ๐ง MCP Capabilities (Detailed)
### ๐ Expense Management
#### โ Add Expense
```python
add_expense(
date="2026-01-05",
amount=250,
category="Food",
subcategory="Dining",
payment_method="Credit Card",
note="Dinner with friends",
tags="restaurant,weekend"
)
```
#### โ๏ธ Update Expense
Update only the fields you want to change:
```python
update_expense(expense_id=1, amount=300, note="Updated bill amount")
```
#### โ Delete Expense
```python
delete_expense(expense_id=1)
```
#### ๐ List Expenses
```python
list_expenses(
start_date="2026-01-01",
end_date="2026-01-31",
category="Food",
limit=50
)
```
#### ๐ Search Expenses
Search across category, subcategory, notes, and tags:
```python
search_expenses(query="restaurant")
```
---
### ๐ฐ Income & Cashflow
#### โ Add Income
```python
add_income(
date="2026-01-01",
amount=5000,
source="Salary",
note="January Paycheck"
)
```
#### ๐ Cashflow Analysis
```python
get_cashflow(start_date="2026-01-01", end_date="2026-01-31")
```
**Returns:**
```json
{
"total_income": 5000,
"total_expenses": 1800,
"net_savings": 3200,
"savings_rate": "64.0%"
}
```
---
### ๐ Recurring Expenses Engine
#### โ Add Recurring Expense
```python
add_recurring_expense(
name="Netflix",
amount=15.99,
category="Entertainment",
frequency="monthly",
start_date="2026-01-01"
)
```
*Supported frequencies: `daily`, `weekly`, `monthly`, `yearly`.*
#### ๐ Process/Refresh Bills
Run this to generate actual expense entries from your templates:
```python
process_recurring_expenses(target_date="2026-03-31")
```
---
### ๐ Budgeting & Alerts
#### ๐ฏ Set Monthly Budget
```python
set_monthly_budget(category="Food", amount=500)
```
#### ๐ Budget Report
```python
get_budget_report(month_str="2026-01")
```
*Status logic:*
* โ
**OK**
* โ ๏ธ **WARNING** (>90% used)
* โ **OVER BUDGET**
---
### ๐งพ Metadata Management
#### ๐ฅ Get Metadata (Resource)
The AI reads this to know which categories are allowed.
```text
expense://metadata
```
#### โ Manage Categories/Methods
```python
manage_metadata(action="add", type="categories", value="Education")
manage_metadata(action="remove", type="payment_methods", value="Cash")
```
---
## ๐ค Built-in LLM Prompt
### ๐ง Financial Advisor Prompt
```python
financial_advisor()
```
This prompt instructs the LLM to:
* Act as a data-driven financial advisor.
* Always validate metadata before logging.
* Prioritize cashflow health and budget warnings.
* Proactively manage recurring subscriptions.
---
## ๐ Data Safety
* All data is stored **locally** in `expenses.db`.
* No external API calls or cloud syncing.
* To backup your data, simply copy the `.db` file.
---
## ๐ License
MIT License โ free to use, modify, and distribute.
---
## ๐ Author
**Anubhab Das**TDQS
Scored across 12 tools
Each tool targets a fairly distinct resource+action (expense CRUD, income, budget, recurring, metadata), and descriptions clarify the tricky pairs like add_recurring_expense vs process_recurring_expenses. The main soft spots are list_expenses vs search_expenses (both return filtered expense sets) and get_cashflow being derivable from expense/income data, but these are reasonably separable.
All twelve names are snake_case verb_noun (add_expense, update_expense, set_monthly_budget, get_budget_report), with no style mixing. The pattern reads predictably and maps cleanly to actions.
Twelve tools is squarely in the ideal 3-15 range and each maps to a real workflow (expenses, income, recurring bills, budgets, metadata). No tool appears redundant or filler.
Expense lifecycle is fully covered (add/update/delete/list/search), but income only has add_income with no update/delete/list, and recurring bills have no way to list or cancel templates once created. Budget also lacks a remove/clear operation, leaving several dead ends an agent will hit.