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.
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
asyncioandasyncpg. - 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
-
Clone the repository:
git clone https://github.com/satyam0singh/Expense_Tracker_MCP.git cd Expense_Tracker_MCP -
Set up the environment: Create a virtual environment and install dependencies.
uv venv uv pip install -e . -
Configure Database: Ensure PostgreSQL is running. Create a
.envfile from the provided.env.dockeror.env.example:DATABASE_URL=postgresql+asyncpg://user:pass@localhost:5432/expense_db -
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:
add_expense- Add a new expense record (auto-updates the matching budget)update_expense- Edit an existing expense (amount, category, date, notes, etc.)delete_expense- Soft-delete an expense recordsearch_expenses- Search expenses by title/notes, with optional date rangelist_categories- List all expense categories and subcategoriesset_budget- Set a monthly budget for a categoryupdate_budget- Update an existing budget amountget_budget_status- Check budget usage/status for a monthget_category_breakdown- Spending breakdown by category for a monthanalyze_spending- High-level spending summary for a monthget_spending_trends- Monthly totals over the last N monthsadd_credit_card- Add a credit card to trackget_active_cards- List active cards with usage/limitsrecord_card_payment- Log a payment made toward a cardexport_csv- Export a month's expenses as CSVexport_excel- Export a month's expenses as Excelexport_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
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
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.
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.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
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.
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.
Neon Database
MCP server for interacting with Neon Management API and databases
E2B
Using MCP to run code via e2b.
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.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.