Skip to main content
Glama
satyam0singh

Expense_Tracker_MCP

by satyam0singh

🌟 Overview

Expense Tracker MCP Server bridges the gap between Large Language Models (LLMs) and Personal Financial Intelligence. Traditional finance tools force users to perform manual data entry across complex tabular interfaces. By introducing a standardized Model Context Protocol (MCP) backend, AI assistants can converse with your local database to manage transactions, monitor budgets, and audit financial health autonomously.

IMPORTANT

Why MCP? Standard APIs require custom LLM integrations and continuous maintenance. MCP provides an open, universal standard connecting AI applications to data sources securely, preserving local privacy without third-party SaaS cloud lock-in.

πŸ’‘ Core Value Drivers

  • 🧠 Natural Language Accounting: Simply say "I spent $45 on groceries today" and let the AI extract merchants, categories, amounts, and dates with full validation.

  • πŸ›‘οΈ Zero Cloud Leakage & Isolation: All transactions are stored locally or in your private PostgreSQL instance. Multi-tenant UUID isolation keeps user records compartmentalized.

  • πŸ“Š Proactive Financial Intelligence: Beyond storage, the server empowers AI clients to run spending trend analyses, calculate category distribution metrics, and flag budget overruns dynamically.

  • πŸ“‘ Executive Exports: Instant generation of production-ready CSV, Excel spreadsheets, and formatted PDF reports straight from chat windows.


Related MCP server: accounting-mcp-server

πŸ›οΈ System Architecture

Built from the ground up using clean Layered & Repository Architecture patterns to enforce strict separation of concerns, complete testability, and asynchronous performance.

graph TD
    %% Styling Definitions
    classDef client fill:#1e293b,stroke:#38bdf8,stroke-width:2px,color:#f8fafc;
    classDef mcp fill:#0f172a,stroke:#818cf8,stroke-width:2px,color:#f8fafc;
    classDef service fill:#1e1b4b,stroke:#c084fc,stroke-width:2px,color:#f8fafc;
    classDef repo fill:#111827,stroke:#34d399,stroke-width:2px,color:#f8fafc;
    classDef db fill:#064e3b,stroke:#10b981,stroke-width:2px,color:#f8fafc;

    subgraph LLM_Clients[" Client Integration Layer "]
        Claude[" πŸ€– Claude Desktop Client "]:::client
        Cursor[" πŸ’» Cursor IDE / VS Code "]:::client
        Gemini[" πŸš€ Gemini CLI / Custom Agent "]:::client
    end

    subgraph MCP_Server[" Model Context Protocol (FastMCP) "]
        ToolRegistry[" ⚑ Tools Layer (17 Endpoint Handlers) "]:::mcp
        Schemas[" πŸ›‘οΈ Pydantic v2 Schema Validation "]:::mcp
    end

    subgraph Application_Core[" Business & Persistence Layer "]
        Services[" βš™οΈ Service Layer (Business Logic & Audit Logs) "]:::service
        Repos[" πŸ“¦ Repository Layer (Async Queries & Data Access) "]:::repo
    end

    subgraph Database_Layer[" Storage Engine "]
        PostgreSQL[(" 🐘 PostgreSQL 16 DB\n(SQLAlchemy 2.0 Async + JSONB Audits) ")]:::db
    end

    Claude -->|stdio / JSON-RPC| ToolRegistry
    Cursor -->|stdio / JSON-RPC| ToolRegistry
    Gemini -->|stdio / JSON-RPC| ToolRegistry

    ToolRegistry --> Schemas
    Schemas --> Services
    Services --> Repos
    Repos --> PostgreSQL

✨ Key Feature Cards


πŸ”„ MCP Execution Workflow

sequenceDiagram
    autonumber
    actor User as πŸ‘€ User
    participant Claude as πŸ€– Claude Desktop
    participant MCP as ⚑ MCP Server (FastMCP)
    participant Service as βš™οΈ Service / Repo
    participant DB as 🐘 PostgreSQL DB

    User->>Claude: "Add β‚Ή450 spent on Pizza yesterday under Food"
    Claude->>Claude: Parse Intent & Select Tool `add_expense`
    Claude->>MCP: Call `add_expense(amount=450, category="Food", title="Pizza", date="2026-07-23")`
    MCP->>MCP: Validate Input Schema via Pydantic v2
    MCP->>Service: Dispatch to `ExpenseService.create()`
    Service->>DB: Execute Async INSERT & Update Budget Totals
    DB-->>Service: Return Transaction Record + Audit ID
    Service-->>MCP: Format Structured Response
    MCP-->>Claude: JSON Tool Result (Success Payload)
    Claude-->>User: "Expense of β‚Ή450 logged successfully! Monthly Food budget remaining: β‚Ή3,550."

πŸ“‚ Project Structure

Expense_Tracker_MCP/
β”œβ”€β”€ πŸ“ expense_tracker/            # Main Application Package
β”‚   β”œβ”€β”€ πŸ“ database/               # Database Connection & Migration Setup
β”‚   β”‚   β”œβ”€β”€ πŸ“ models/             # SQLAlchemy 2.0 ORM Models (Expense, Budget, CreditCard, Audit)
β”‚   β”‚   β”œβ”€β”€ πŸ“„ connection.py       # Async Engine & Session Generators
β”‚   β”‚   └── πŸ“„ base.py             # Declarative Base & Mixins
β”‚   β”œβ”€β”€ πŸ“ repositories/           # Data Access Layer (Decoupled SQLAlchemy Queries)
β”‚   β”‚   β”œβ”€β”€ πŸ“„ expense_repo.py
β”‚   β”‚   β”œβ”€β”€ πŸ“„ budget_repo.py
β”‚   β”‚   └── πŸ“„ card_repo.py
β”‚   β”œβ”€β”€ πŸ“ services/               # Core Business Logic & Audit Trail Handlers
β”‚   β”‚   β”œβ”€β”€ πŸ“„ expense_service.py
β”‚   β”‚   β”œβ”€β”€ πŸ“„ budget_service.py
β”‚   β”‚   └── πŸ“„ report_service.py
β”‚   β”œβ”€β”€ πŸ“ schemas/                # Pydantic v2 Request/Response Validation Models
β”‚   β”‚   └── πŸ“„ financial_schemas.py
β”‚   β”œβ”€β”€ πŸ“ tools/                  # FastMCP Endpoint Registration Handlers (17 Tools)
β”‚   β”‚   β”œβ”€β”€ πŸ“„ expense_tools.py
β”‚   β”‚   β”œβ”€β”€ πŸ“„ budget_tools.py
β”‚   β”‚   β”œβ”€β”€ πŸ“„ card_tools.py
β”‚   β”‚   └── πŸ“„ report_tools.py
β”‚   └── πŸ“„ server.py               # FastMCP Server Entrypoint & Initialization
β”œβ”€β”€ πŸ“ alembic/                    # Database Schema Migration Scripts
β”‚   β”œβ”€β”€ πŸ“ versions/               # Sequential Version Stamps
β”‚   └── πŸ“„ env.py                  # Migration Environment Config
β”œβ”€β”€ πŸ“ tests/                      # Pytest Test Suite (SQLite In-Memory / Asyncpg)
β”‚   β”œβ”€β”€ πŸ“„ test_expenses.py
β”‚   β”œβ”€β”€ πŸ“„ test_budgets.py
β”‚   └── πŸ“„ test_reports.py
β”œβ”€β”€ πŸ“„ docker-compose.yml          # Production PostgreSQL & MCP Stack Containerization
β”œβ”€β”€ πŸ“„ Dockerfile                  # Multi-stage Lightweight Python 3.12 Build
β”œβ”€β”€ πŸ“„ pyproject.toml              # UV / Hatchling Project Configuration
β”œβ”€β”€ πŸ“„ alembic.ini                 # Alembic Configuration Settings
└── πŸ“„ README.md                   # Project Documentation

πŸš€ Quick Start Guide

Prerequisites

Ensure you have the following software installed on your host system:

  • Python: v3.12+

  • PostgreSQL: v16+ (or Docker)

  • uv: v0.1.0+ (Fast Python package installer and resolver)

Step 1: Clone Repository

git clone https://github.com/satyam0singh/Expense_Tracker_MCP.git
cd Expense_Tracker_MCP

Step 2: Set Up Virtual Environment

# Create virtual environment with uv
uv venv

# Activate Virtual Environment
# On Linux/macOS:
source .venv/bin/activate
# On Windows (PowerShell):
.venv\Scripts\Activate.ps1

# Install package dependencies in editable mode
uv pip install -e .

Step 3: Configure Environment Variables

Create a .env file in the root directory (or copy from .env.docker):

DATABASE_URL=postgresql+asyncpg://postgres:postgres@localhost:5432/expense_db
USER_ID=123e4567-e89b-12d3-a456-426614174000
ENVIRONMENT=production
LOG_LEVEL=INFO

Step 4: Run Database Migrations

Apply database schemas using Alembic:

uv run alembic upgrade head

βš™οΈ Claude Desktop Configuration

To allow Claude Desktop to control the server, register it inside your local configuration file.

Location of claude_desktop_config.json:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

  • Windows: %APPDATA%\Claude\claude_desktop_config.json

  • Linux: ~/.config/Claude/claude_desktop_config.json

Add Configuration:

{
  "mcpServers": {
    "expense-tracker": {
      "command": "uv",
      "args": [
        "--directory",
        "C:/path/to/Expense_Tracker_MCP",
        "run",
        "python",
        "-m",
        "expense_tracker.server"
      ],
      "env": {
        "DATABASE_URL": "postgresql+asyncpg://postgres:postgres@localhost:5432/expense_db",
        "USER_ID": "123e4567-e89b-12d3-a456-426614174000"
      }
    }
  }
}
TIP

Understanding USER_ID Scoping The USER_ID environment variable is a unique UUID assigned to your client instance. If you run multiple Claude instances or share a remote PostgreSQL database, changing USER_ID guarantees complete isolation between financial profiles.


πŸ› οΈ Available MCP Tools

The server dynamically exposes 17 robust endpoints directly into the LLM context window:

Icon

Tool Name

Category

Description / Purpose

Return Type

Natural Language Example

βž•

add_expense

Expense

Records new transaction & adjusts budget caps

ExpenseRead

"Add β‚Ή450 for Pizza yesterday"

✏️

update_expense

Expense

Modifies fields of an existing record

ExpenseRead

"Change expense #12 category to Dining"

πŸ—‘οΈ

delete_expense

Expense

Soft-deletes a record with audit tracking

StatusMessage

"Delete expense #45"

πŸ”

search_expenses

Query

Filters transactions by date, merchant, or notes

List[Expense]

"Find all electronics expenses last week"

🏷️

list_categories

Metadata

Retrieves hierarchy of categories & subcategories

List[Category]

"What categories can I log expenses under?"

🎯

set_budget

Budget

Configures monthly spending limit for category

BudgetRead

"Set a β‚Ή10,000 budget for Food this month"

πŸ”„

update_budget

Budget

Adjusts existing category spending ceiling

BudgetRead

"Increase my Shopping budget to β‚Ή15,000"

πŸ“ˆ

get_budget_status

Budget

Reports consumed % and remaining balance

BudgetStatus

"How much budget is left in Groceries?"

🍰

get_category_breakdown

Analytics

Category percentage breakdown for a month

CategoryDistribution

"Show category spending pie chart breakdown"

πŸ”¬

analyze_spending

Analytics

High-level summary, average ticket, & peak days

FinancialSummary

"Analyze my spending habits for July"

πŸ“‰

spending_trends

Analytics

Multi-month velocity & month-over-month delta

TrendAnalysis

"Compare spending over the past 6 months"

πŸ’³

add_credit_card

Credit Card

Registers a new credit card line & limit

CardRead

"Add HDFC card with limit β‚Ή2,000,000"

πŸ’³

get_active_cards

Credit Card

Displays active cards, utilization, & due dates

List[CardRead]

"List all my active credit cards"

πŸ’Έ

record_card_payment

Credit Card

Logs payments made against credit balances

PaymentRead

"Record β‚Ή5,000 payment to HDFC card"

πŸ“Š

export_csv

Reports

Generates raw CSV export file path

FilePath

"Export July expenses to CSV"

πŸ“—

export_excel

Reports

Generates formatted Excel workbook with formulas

FilePath

"Generate Excel report for Q2"

πŸ“•

export_pdf

Reports

Generates printable PDF statement document

FilePath

"Create a PDF summary of my expenses"


πŸ’» Visual Technology Stack

Domain

Technologies Used

Language & Core

Python 3.12 asyncio

Protocol Framework

FastMCP JSON-RPC

Database & Engine

PostgreSQL 16 asyncpg

ORM & Migrations

SQLAlchemy 2.0 Alembic

Validation & Schemas

Pydantic v2

Containerization

Docker Docker Compose

Testing & Quality

pytest pytest-asyncio


πŸ–ΌοΈ Application Interfaces

+-----------------------------------------------------------------------------------+
|                            CLAUDE DESKTOP DEMO PLACEHOLDER                        |
|                                                                                   |
|  User: "Add β‚Ή450 spent on Pizza yesterday."                                        |
|  Claude: [Executing Tool: add_expense]                                            |
|          -> Amount: β‚Ή450.00 | Category: Food | Date: 2026-07-23                       |
|          "Successfully recorded expense #104. Remaining Food Budget: β‚Ή3,550.00"   |
+-----------------------------------------------------------------------------------+

Interface

Preview Mockup

Claude Desktop Integration

Claude Demo

Budget Analytics Dashboard

Budget Report

Executive PDF Financial Statement

PDF Report


πŸ’¬ Real-World AI Conversation Example

πŸ’¬ User
"Add β‚Ή450 spent on Pizza yesterday."

πŸ€– Claude (via Expense Tracker MCP)
Calling tool: add_expense(amount=450, category="Food & Dining", title="Pizza", date="2026-07-23")

Response:
βœ… Expense recorded successfully!
β€’ Transaction ID: #104
β€’ Amount: β‚Ή450.00
β€’ Category: Food & Dining
β€’ Date: July 23, 2026

πŸ“Š Budget Update:
You have spent β‚Ή6,450 of your β‚Ή10,000 Food budget for July. (64.5% consumed, β‚Ή3,550 remaining).
πŸ’¬ User
"How much did I spend on Food this month? Show me a breakdown."

πŸ€– Claude (via Expense Tracker MCP)
Calling tool: get_category_breakdown(month=7, year=2026)

Response:
Here is your Food spending summary for July 2026:

 Total Spent: β‚Ή6,450.00 (14 transactions)

Breakdown:
 πŸ›’ Groceries:     β‚Ή3,800.00 (58.9%)
 πŸ• Dining Out:    β‚Ή2,150.00 (33.3%)
 β˜• Coffee Shops:  β‚Ή500.00   (7.8%)

πŸ’‘ Insight: Your dining out expenses increased by 12% compared to June.

πŸ“‘ Multi-Format Report Generation Engine

The server includes dedicated export services to render financial files dynamically:

  • πŸ“Š CSV Export (export_csv): Standard RFC 4180 formatted flat CSV files ideal for importing into Google Sheets, ledger tools, or custom data pipelines.

  • πŸ“— Excel Workbook Export (export_excel): Uses openpyxl to build structured spreadsheets featuring automated column width calculation, styled header banners, currency formatting, and SUM total formulas.

  • πŸ“• PDF Executive Statement (export_pdf): Built using reportlab to construct clean vector PDF reports containing table summaries, category distribution graphics, audit footers, and page numbers.


⚑ Performance Benchmarks

Engineered for lightning-fast execution times, minimizing LLM tool call latency:

Operation Metric

Mean Duration

Throughput / Capacity

Benchmark Notes

Tool Execution Latency

~12ms

~85 req/sec

Standard local PostgreSQL connection

Async Connection Pool

< 2ms

20 Pool Connections

Powered by asyncpg connection pool

Pydantic Validation Time

~0.4ms

2,500 validation/sec

Pydantic v2 Compiled Rust Core

PDF Report Generation

~110ms

Single-page document

Complete PDF rendering with ReportLab

Memory Footprint

~45MB

Idle RAM Usage

Optimized Python 3.12 footprint


πŸ›‘οΈ Security & Data Governance

  • πŸ”’ User Scoping & Isolation: Enforced USER_ID filter predicate across all queries prevents horizontal data leakage.

  • πŸ“œ Immutable JSONB Audit Logs: All state-modifying tools capture original state, target state, timestamps, and caller IDs in an audit_logs table.

  • πŸ’‰ SQL Injection Prevention: Built entirely on SQLAlchemy 2.0 ORM query builders using parameterized input bindings.

  • πŸ—‘οΈ Soft-Delete Lifecycle: Records are marked with a soft is_deleted flag, preserving data integrity and permitting recovery if directed by users.


πŸ—ΊοΈ Product Roadmap

  • v1.0.0 β€” Core Engine Release

    • Asynchronous FastMCP Server core integration

    • PostgreSQL + SQLAlchemy 2.0 async persistence layer

    • 17 Core Tools for expenses, budgets, credit cards, and exports

    • Comprehensive Pytest suite and Docker containerization

  • v1.1.0 β€” Smart Subscriptions & Rules (In Progress)

    • Recurring expense automation (Subscriptions, Rent, Bills)

    • Custom categorization rule engine with regex matching

  • v1.2.0 β€” Auth & Multi-User

    • OAuth2 / API Key authentication handshake

    • Multi-currency support with real-time FX conversion rates

  • v2.0.0 β€” Web Interface & Ecosystem

    • Full-fledged Next.js Web Dashboard for graphical inspection

    • Cloud sync adapter for Supabase and AWS RDS


🀝 Contributing

Contributions are warmly welcomed! To contribute:

  1. Fork the Repository: git checkout -b feature/amazing-feature

  2. Commit your changes: git commit -m 'feat: Add amazing feature'

  3. Push to the Branch: git push origin feature/amazing-feature

  4. Open a Pull Request for review.

Please ensure all pytest checks pass prior to opening a PR:

uv run pytest tests

πŸ“„ License

Distributed under the MIT License. See LICENSE for complete terms and details.


πŸ‘¨β€πŸ’» Author & Maintainer


A
license - permissive license
-
quality - not tested
B
maintenance

Maintenance

–Maintainers
–Response time
–Release cycle
–Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    A
    quality
    D
    maintenance
    Personal expense tracker MCP server that enables tracking expenses, income, budgets, and savings goals through natural language.
    10
    MIT
  • -
    license
    -
    quality
    -
    maintenance
    A personal accounting MCP server that enables AI assistants to record and query financial transactions through natural language, supporting income/expense tracking, balance inquiry, and monthly summaries.
  • F
    license
    -
    quality
    C
    maintenance
    A cloud-deployed MCP server for managing personal expenses and providing financial analytics. It enables AI assistants like Claude Desktop to add, update, delete, and retrieve expenses, with features like budgeting assistance and category-wise summaries.
  • F
    license
    A
    quality
    B
    maintenance
    A lightweight MCP server for managing personal finances locally. It allows users to log transactions, view summaries, manage categories, and interact with their budget via any MCP-compatible LLM client.
    12

View all related MCP servers

Related MCP Connectors

  • Hosted MCP server for Mini Accountant: invoices, expenses, customers, analytics, tax estimates.

  • MCP server for Gainium β€” manage trading bots, deals, and balances via AI assistants

  • MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/satyam0singh/Expense_Tracker_MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server