Expense_Tracker_MCP

Expense_Tracker_MCP

A production-grade MCP server for personal finance management, enabling AI agents to add, update, search expenses, manage budgets and credit cards, and generate financial reports.

Category
Visit Server

README

Expense Tracker MCP Server

A production-grade Model Context Protocol (MCP) server for comprehensive personal finance management. This server allows AI agents (like Claude or Gemini) to securely interact with your expenses, budgets, credit cards, and generate rich financial reports.

Features

  • Clean Architecture: Built on a solid Service/Repository pattern.
  • Asynchronous: Fully async Python implementation utilizing asyncio and asyncpg.
  • Database: PostgreSQL with SQLAlchemy 2.0 and Alembic for robust schema migrations.
  • Data Validation: Strict schemas powered by Pydantic v2.
  • MCP Protocol: Exposes tools dynamically using FastMCP.
  • Audit Trails: Immutable JSONB audit logs for all mutations to track financial changes accurately.
  • Export Capabilities: Generates Excel (.xlsx) and PDF reports.

System Requirements

  • Python 3.12+
  • PostgreSQL 16+
  • uv (Recommended for fast dependency management)

Installation

  1. Clone the repository:

    git clone https://github.com/satyam0singh/Expense_Tracker_MCP.git
    cd Expense_Tracker_MCP
    
  2. Set up the environment: Create a virtual environment and install dependencies.

    uv venv
    uv pip install -e .
    
  3. Configure Database: Ensure PostgreSQL is running. Create a .env file from the provided .env.docker or .env.example:

    DATABASE_URL=postgresql+asyncpg://user:pass@localhost:5432/expense_db
    
  4. Run Migrations:

    uv run alembic upgrade head
    

Usage

Claude Desktop Configuration (Standard MCP)

To connect this server to Claude Desktop, you need to add it to your claude_desktop_config.json file.

Note: You must set USER_ID in the env block. If you are sharing a cloud PostgreSQL database, this UUID isolates your expenses from other users.

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

Available Tools

The server registers 17 powerful tools with the LLM context:

  1. add_expense - Add a new expense record (auto-updates the matching budget)
  2. update_expense - Edit an existing expense (amount, category, date, notes, etc.)
  3. delete_expense - Soft-delete an expense record
  4. search_expenses - Search expenses by title/notes, with optional date range
  5. list_categories - List all expense categories and subcategories
  6. set_budget - Set a monthly budget for a category
  7. update_budget - Update an existing budget amount
  8. get_budget_status - Check budget usage/status for a month
  9. get_category_breakdown - Spending breakdown by category for a month
  10. analyze_spending - High-level spending summary for a month
  11. get_spending_trends - Monthly totals over the last N months
  12. add_credit_card - Add a credit card to track
  13. get_active_cards - List active cards with usage/limits
  14. record_card_payment - Log a payment made toward a card
  15. export_csv - Export a month's expenses as CSV
  16. export_excel - Export a month's expenses as Excel
  17. export_pdf - Export a month's expenses as PDF

Docker (Production)

To spin up the server and a PostgreSQL instance using Docker Compose:

docker-compose up -d

Note: The mcp-server container in compose is primarily set up to tail logs or run migrations. To connect an AI agent to a dockerized MCP server, you typically pipe stdio through docker run -i.

Testing

Tests are written using pytest and use an in-memory SQLite database for rapid execution.

uv run pytest tests

Architecture

This project strictly follows layered Clean Architecture:

  • Tools (expense_tracker/tools/): The presentation layer defining MCP endpoints using FastMCP.
  • Services (expense_tracker/services/): Orchestrates business logic across repositories (e.g., syncing budget when an expense is added).
  • Repositories (expense_tracker/repositories/): Abstract data access and domain queries.
  • Models (expense_tracker/database/models/): SQLAlchemy 2.0 ORM definitions.
  • Schemas (expense_tracker/schemas/): Pydantic v2 schemas for strict I/O validation.

License

MIT License

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
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

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