Expense Tracker MCP Server

Expense Tracker MCP Server

Enables AI-driven expense tracking and budget management, including adding expenses, setting budgets, analyzing trends, forecasting, and managing savings goals via natural language.

Category
Visit Server

README

๐Ÿ’ฐ Expense Tracker MCP Server

A powerful, AI-ready expense tracking system built with FastMCP (Model Context Protocol) that integrates seamlessly with Claude AI and other LLM applications.

๐ŸŽฏ Status: Production-Ready | ๐Ÿ“Š Database: SQLite | ๐Ÿš€ Framework: FastMCP 3.4.2


โœจ Features

๐ŸŽฏ Core Expense Management

  • โœ… Add Expenses - Track daily spending with category, subcategory, and notes
  • โœ… List Expenses - Query expenses by date range
  • โœ… Summarize - Category-wise expense breakdown with totals

๐Ÿ’ฐ Budget Management

  • โœ… Set Budget - Define monthly budgets per category
  • โœ… Check Budget Status - Real-time budget vs actual spending with ๐Ÿ”ด๐ŸŸก๐ŸŸข status indicators
  • โœ… Budget Alerts - Automatic warnings at 80% budget usage

๐Ÿ“Š Analytics & Insights

  • โœ… Spending Trends - Weekly trend analysis (last 30 days)
  • โœ… Advanced Analytics - Highest/lowest expenses, median, averages per category
  • โœ… Smart Insights - AI-generated spending patterns and recommendations
  • โœ… Monthly Reports - Comprehensive month-end summaries

๐Ÿ”„ Recurring Expenses

  • โœ… Add Recurring Expenses - Subscriptions, rent, bills (daily/weekly/monthly/yearly)
  • โœ… List Recurring - View all active subscriptions with estimated monthly cost

๐ŸŽฏ Savings Goals

  • โœ… Create Savings Goals - Vacation, emergency fund, new gadgets, etc.
  • โœ… Track Progress - Update and monitor goal achievements
  • โœ… View All Goals - Dashboard with progress percentages and deadlines

๐Ÿ”ฎ Forecasting

  • โœ… Expense Forecast - Predict next month expenses (70% historical + 30% recurring)
  • โœ… Spending Prediction - AI-powered forecasting based on patterns

๐Ÿ› ๏ธ Installation

Prerequisites

  • Python 3.8+
  • pip or uv (recommended)

Step 1: Clone Repository

git clone https://github.com/mhd-faraz/Expense-Tracker-MCP.git
cd Expense-Tracker-MCP

Step 2: Create Virtual Environment

# Using uv (faster)
uv venv
source .venv/bin/activate

# Or using Python venv
python3 -m venv .venv
source .venv/bin/activate

Step 3: Install Dependencies

uv add fastmcp aiosqlite

Step 4: Run Server

python3 main.py

Expected Output:

โœ… Database initialized with all tables - write access confirmed
INFO: Uvicorn running on http://0.0.0.0:8321/mcp (Press CTRL+C to quit)

๐Ÿ“– Usage

Option 1: MCP Inspector (Testing)

  1. Open browser: http://localhost:8321/mcp/inspector
  2. Select tool from dropdown
  3. Fill parameters
  4. Click "Run Tool"

Example:

{
  "date": "2026-06-19",
  "amount": 450,
  "category": "Food & Dining",
  "subcategory": "Restaurant",
  "note": "Lunch with team"
}

Option 2: Claude Desktop (Production)

  1. Connect to this MCP server in Claude Desktop
  2. Use natural language:
"Add an expense of โ‚น3000 for groceries today"
"Show my spending trends for the last 30 days"
"What's my budget status for this month?"
"Create a savings goal of โ‚น50000 for vacation by December"
"Forecast my next month expenses"

Claude will automatically call the appropriate tools and update your database!

Option 3: Python Script

import aiosqlite
import asyncio

async def add_expense():
    async with aiosqlite.connect("/tmp/expenses.db") as db:
        await db.execute(
            "INSERT INTO expenses(date, amount, category, note) VALUES (?,?,?,?)",
            ("2026-06-19", 450, "Food & Dining", "Lunch")
        )
        await db.commit()

asyncio.run(add_expense())

๐Ÿ—„๏ธ Database Schema

expenses

CREATE TABLE expenses(
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    date TEXT NOT NULL,
    amount REAL NOT NULL,
    category TEXT NOT NULL,
    subcategory TEXT DEFAULT '',
    note TEXT DEFAULT '',
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)

budgets

CREATE TABLE budgets(
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    category TEXT NOT NULL,
    amount REAL NOT NULL,
    month TEXT NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    UNIQUE(category, month)
)

recurring_expenses

CREATE TABLE recurring_expenses(
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    name TEXT NOT NULL,
    amount REAL NOT NULL,
    category TEXT NOT NULL,
    frequency TEXT NOT NULL,
    start_date TEXT NOT NULL,
    end_date TEXT,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)

savings_goals

CREATE TABLE savings_goals(
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    goal_name TEXT NOT NULL,
    target_amount REAL NOT NULL,
    current_amount REAL DEFAULT 0,
    deadline TEXT NOT NULL,
    category TEXT DEFAULT 'Savings',
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)

Database Location: /tmp/expenses.db (macOS/Linux)


๐Ÿ”ง Available Tools (13 Total)

# Tool Purpose Parameters
1 add_expense() Add new expense date, amount, category, subcategory, note
2 list_expenses() Query expenses start_date, end_date
3 summarize() Category summary start_date, end_date, category
4 set_budget() Set monthly budget category, amount, month
5 check_budget_status() Budget tracking month
6 add_recurring_expense() Add subscription name, amount, category, frequency, start_date
7 list_recurring_expenses() View subscriptions (no params)
8 create_savings_goal() New savings target goal_name, target_amount, deadline, category
9 update_savings_goal_progress() Track progress goal_id, amount_saved
10 get_savings_goals() View all goals (no params)
11 get_spending_trends() Weekly trends days
12 get_expense_analytics() Detailed stats start_date, end_date
13 forecast_expenses() Next month prediction months_ahead
14 get_smart_insights() AI recommendations (no params)
15 generate_monthly_report() Monthly summary month

๐Ÿ“Š Example Outputs

Budget Status:

Category          Budget    Spent     Remaining  Usage%   Status
Food & Dining     โ‚น5000     โ‚น2300     โ‚น2700      46.0%    ๐ŸŸข OK
Transportation    โ‚น3000     โ‚น1200     โ‚น1800      40.0%    ๐ŸŸข OK
Bills & Utilities โ‚น4000     โ‚น2500     โ‚น1500      62.5%    ๐ŸŸข OK

Smart Insights:

๐ŸŽฏ TOP SPENDING
   Food & Dining is your biggest expense (โ‚น2300) - 35.2% of budget

๐Ÿ“Š FREQUENCY
   Transportation has most transactions (4 times). Small amounts add up!

๐Ÿ“ˆ DAILY PACE
   You're spending โ‚น473 per day on average

๐Ÿ’ก OPTIMIZATION
   You have 3 categories eating >20% of budget. Consider consolidating!

Forecast:

Category          Predicted    vs Last Month
Bills & Utilities โ‚น6429.70     โ†‘ +157.2%
Groceries         โ‚น2450.00     โ†“ -30.0%
Food & Dining     โ‚น2060.00     โ†“ -10.4%

๐Ÿš€ Connect to Claude Desktop

Step 1: Get Server URL

http://0.0.0.0:8321/mcp

Step 2: Add to Claude Settings

In Claude Desktop, go to Settings โ†’ Connected Servers:

{
  "mcpServers": {
    "expense-tracker": {
      "command": "python3",
      "args": ["/path/to/main.py"],
      "type": "stdio"
    }
  }
}

Step 3: Start Using!

Now tell Claude:

"I spent โ‚น3000 on groceries today"
"Show my monthly budget status"
"Create a savings goal for my vacation"
"What are my spending trends?"

๐Ÿ“ Project Structure

Expense-Tracker-MCP/
โ”œโ”€โ”€ main.py                      # Main MCP server (13 tools)
โ”œโ”€โ”€ test_expense_tracker.py      # Complete test suite
โ”œโ”€โ”€ categories.json              # Category definitions
โ”œโ”€โ”€ .gitignore                   # Git ignore rules
โ”œโ”€โ”€ README.md                    # This file
โ””โ”€โ”€ .venv/                       # Virtual environment

๐Ÿงช Testing

Run the complete test suite:

python3 test_expense_tracker.py

Output includes:

  • โœ… 10 sample expenses
  • โœ… 5 budget configurations
  • โœ… 5 recurring expenses
  • โœ… 4 savings goals
  • โœ… All 15 tools tested
  • โœ… Formatted analytics and reports

๐Ÿ” Security & Best Practices

  • โœ… Database uses WAL mode for concurrent access
  • โœ… Async/await for non-blocking operations
  • โœ… Input validation on all parameters
  • โœ… Proper error handling with meaningful messages
  • โœ… Database transactions for data integrity

๐Ÿ“ˆ Tech Stack

  • Framework: FastMCP 3.4.2
  • Database: SQLite 3
  • Async Runtime: asyncio + aiosqlite
  • Server: Uvicorn
  • Language: Python 3.12+

๐ŸŽฏ Use Cases

  1. Personal Finance Tracking - Daily expense logging
  2. Budget Planning - Monthly budget management
  3. Goal Tracking - Savings and financial targets
  4. Spending Analysis - Trend analysis and forecasting
  5. AI Integration - Natural language expense tracking via Claude

๐Ÿ“ Categories Supported

Food & Dining      Bills & Utilities    Healthcare
Transportation     Entertainment        Travel
Shopping           Education            Business
Subscriptions      Groceries           Personal Care
Other

๐Ÿค Contributing

This is a portfolio project. Feel free to fork and extend!

Ideas for enhancement:

  • Export to CSV/PDF
  • Multi-user support
  • Cloud sync
  • Mobile app integration
  • Advanced ML predictions

๐Ÿ“„ License

MIT License - Feel free to use and modify!


๐Ÿ‘จโ€๐Ÿ’ป Author

Faraz - CS Engineering Graduate (2025)
Portfolio: faraz-portfolio-ivvo-xi.vercel.app
GitHub: @mhd-faraz


๐Ÿ™‹ FAQ

Q: Database file empty?
A: Database files are binary. Use list_expenses() tool to verify data exists.

Q: Can I use this without Claude Desktop?
A: Yes! Use MCP Inspector or call tools directly via Python.

Q: How do I reset all data?
A: Delete /tmp/expenses.db and restart server.

Q: Can I host this online?
A: Yes! Deploy to MCPCloud, Vercel, or Railway.


๐Ÿš€ Next Steps

  1. โœ… Clone this repo
  2. โœ… Run python3 main.py
  3. โœ… Open http://localhost:8321/mcp/inspector
  4. โœ… Test a tool
  5. โœ… Connect to Claude Desktop
  6. โœ… Start tracking expenses with AI!

Happy Expense Tracking! ๐Ÿ’ฐโœจ

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured