Skip to main content
Glama
Jiliar

Personal Expense Manager

by Jiliar

šŸ“Š MCP Server - Personal Expense Manager

An MCP (Model Context Protocol) server for managing and analyzing personal expenses from CSV files.

šŸš€ Features

  • Add expenses to a CSV file with categorization

  • Get recent expenses with day-based filtering

  • MCP Resource for direct access to all expenses

  • Specialized prompt that generates automatic analytical summaries

  • Analysis by category and payment method

  • Trend detection and spending patterns

Related MCP server: Trackor

šŸ“‹ Requirements

pip install fastmcp mcp

šŸ—‚ļø Project Structure

expenses-mcp-server/
ā”œā”€ā”€ server.py              # Main MCP server
ā”œā”€ā”€ data/
│   └── expenses.csv      # Expenses file (created automatically)
ā”œā”€ā”€ requirements.txt
└── README.md

šŸ› ļø Installation & Usage

1. Clone or create the project

mkdir expenses-mcp-server
cd expenses-mcp-server
python -m venv venv
source venv/bin/activate  # Linux/Mac
# or
venv\Scripts\activate     # Windows

3. Install dependencies

pip install fastmcp mcp

4. Run the server

python server.py

šŸ”§ Available Functionalities

Tools

1. agregar_gasto (Add Expense)

Adds a new expense to the system.

Parameters:

  • fecha: Date in 'YYYY-MM-DD' format

  • categoria: Expense category (e.g., "Food", "Transport")

  • cantidad: Expense amount (float)

  • metodo_pago: Payment method used

Example:

agregar_gasto("2024-01-15", "Groceries", 150.75, "Debit Card")

2. obtener_gastos_recientes (Get Recent Expenses)

Gets expenses from the last N days.

Parameters:

  • dias: Number of days to query (default: 5)

Example:

obtener_gastos_recientes(7)  # Last 7 days

Resource

resource://gastos

Direct access to all stored expenses.

Specialized Prompt

Resumen de Gastos Recientes (Recent Expenses Summary)

Generates a prompt with structured data for AI to create a complete analysis including:

  • šŸ“ˆ Statistical calculations (totals, averages)

  • šŸ·ļø Category analysis

  • šŸ’³ Payment method distribution

  • šŸ” Trend identification

  • šŸ’” Personalized recommendations

šŸ“Š CSV Structure

The data/expenses.csv file has the following structure:

fecha,categoria,cantidad,metodo_pago
2024-01-15,Groceries,150.75,Debit Card
2024-01-16,Transport,45.50,Cash
2024-01-17,Entertainment,89.99,Credit Card

šŸ”Œ MCP Client Integration

Python Client Example

import asyncio
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client

async def main():
    server_params = StdioServerParameters(
        command="python",
        args=["server.py"]
    )
    
    async with stdio_client(server_params) as (read, write):
        async with ClientSession(read, write) as session:
            # Initialize session
            await session.initialize()
            
            # Add expense
            result = await session.call_tool(
                "agregar_gasto",
                {
                    "fecha": "2024-01-18",
                    "categoria": "Restaurant", 
                    "cantidad": 85.50,
                    "metodo_pago": "Credit Card"
                }
            )
            print(result)
            
            # Get recent expenses
            expenses = await session.call_tool(
                "obtener_gastos_recientes", 
                {"dias": 5}
            )
            print(expenses)

if __name__ == "__main__":
    asyncio.run(main())

šŸŽÆ Use Cases

1. Daily Expense Tracking

# Add transport expense
agregar_gasto("2024-01-18", "Transport", 35.00, "Cash")

# Add food expense
agregar_gasto("2024-01-18", "Food", 120.00, "Debit Card")

2. Weekly Analysis

# Get last week summary
obtener_gastos_recientes(7)

3. Monthly Report

# Complete 30-day analysis
obtener_gastos_recientes(30)

šŸ“ˆ Example Generated Analysis

The specialized prompt generates analysis like:

šŸ“Š EXPENSE SUMMARY - LAST 5 DAYS

šŸ’° TOTAL SPENT: $1,245.75
šŸ“… DAILY AVERAGE: $249.15
šŸ”¢ TRANSACTIONS: 8 purchases

šŸ·ļø CATEGORY DISTRIBUTION:
• Groceries: 45% ($560.25)
• Transport: 25% ($311.44)  
• Entertainment: 20% ($249.15)
• Restaurant: 10% ($124.58)

šŸ’³ PAYMENT METHODS:
• Credit Card: 60%
• Debit Card: 30%
• Cash: 10%

šŸ“ˆ OBSERVATIONS:
• Highest spending on Wednesday ($420.50)
• "Groceries" category represents almost half of expenses
• Growing trend in credit card usage

šŸ’” RECOMMENDATIONS:
• Consider bulk purchases to reduce grocery expenses
• Diversify payment methods for better control
• Set weekly limit for entertainment

šŸ› ļø Troubleshooting

Error: "FileNotFoundError"

  • Ensure the data/ directory exists

  • Server creates the file automatically with the first expense

Error: "Encoding issues"

  • Server uses UTF-8 for special character compatibility

Error: "Invalid date format"

  • Use exact format: YYYY-MM-DD

  • Example: 2024-01-18

šŸ“ License

MIT License

šŸ“ž Support

For issues and questions, open a ticket in the project repository.


Start tracking your expenses intelligently! šŸš€

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables personal expense management through CSV storage, allowing AI agents to add, query, and analyze expenses with automatic categorization and payment method validation.
    -
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables users to track and manage personal expenses through natural language, including adding entries, filtering by date/category, viewing statistics, and exporting data in JSON or CSV format.
    3
    -
  • F
    license
    C
    quality
    D
    maintenance
    Enables personal expense management with SQLite storage, allowing users to add, update, delete, list, and summarize expenses by category through natural language interactions.
    5
    -
  • F
    license
    C
    quality
    D
    maintenance
    Enables AI assistants to manage personal finances by storing, analyzing, and exporting expense data using a persistent PostgreSQL database. Supports adding/editing expenses, generating spending summaries, detecting top categories, and creating monthly reports.
    12
    -