bhavuk1409/expense-tracker-mcp-server
If you are the rightful owner of expense-tracker-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
The MCP Expense Tracker Server is a Model Context Protocol server designed for managing personal expenses using an SQLite database for storage. It allows users to add, list, and manage expense entries through any MCP-compatible client.
MCP Expense Tracker Server
A Model Context Protocol (MCP) server for managing personal expenses with SQLite database storage. This server provides tools for adding, listing, and managing expense entries through any MCP-compatible client like Claude Desktop.
Features
- Add new expense entries
- List expenses within date ranges
- SQLite database for persistent storage
- Predefined expense categories
- Subcategory support
- Notes and descriptions
- MCP-compliant for seamless integration
Prerequisites
- Python 3.13 or higher
- uv package manager
- Claude Desktop (for testing) or any MCP-compatible client
Installation
-
Clone the repository:
git clone <repository-url> cd mcp-expense-tracker-server -
Install dependencies:
uv sync -
Verify installation:
uv run python main.py
Usage
Running the Server
Development Mode (with FastMCP Inspector)
uv run fastmcp dev main.py
This starts the server with a web interface at http://127.0.0.1:6274 for testing.
Production Mode
uv run fastmcp run main.py
Integration with Claude Desktop
uv run fastmcp install claude-desktop main.py
Available Tools
add_expense
Add a new expense entry to the database.
Parameters:
date(string): Date in YYYY-MM-DD formatamount(float): Expense amountcategory(string): Expense categorysubcategory(string, optional): Subcategorynote(string, optional): Additional notes
Example:
{
"date": "2024-10-02",
"amount": 25.50,
"category": "Food & Dining",
"subcategory": "groceries",
"note": "Weekly grocery shopping"
}
list_expenses
List expense entries within a date range.
Parameters:
start_date(string): Start date in YYYY-MM-DD formatend_date(string): End date in YYYY-MM-DD format
Example:
{
"start_date": "2024-10-01",
"end_date": "2024-10-31"
}
get_categories
Retrieve all available expense categories and subcategories.
Returns: JSON object with category structure
Available Resources
expense://categories
Access the categories configuration as a JSON resource.
Database Schema
The SQLite database contains an expenses table with the following structure:
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 ''
);
Categories Configuration
The categories.json file contains predefined expense categories and subcategories:
{
"food": ["groceries", "dining_out", "coffee_tea", ...],
"transportation": ["gas", "public_transport", "taxi", ...],
"entertainment": ["movies", "games", "books", ...],
...
}
You can modify this file to customize categories for your needs.
File Structure
mcp-expense-tracker-server/
├── main.py # Main MCP server implementation
├── categories.json # Expense categories configuration
├── expenses.db # SQLite database (auto-created)
├── pyproject.toml # Project configuration
├── uv.lock # Dependency lock file
└── README.md # This file
Development
Running Tests
# Test the server directly
uv run python main.py
# Test with FastMCP inspector
uv run fastmcp dev main.py
Adding New Features
- New Tools: Add new
@mcp.tool()decorated functions inmain.py - New Resources: Add new
@mcp.resource()decorated functions - Database Changes: Modify the
init_db()function for schema updates
Debugging
Common Issues
-
"Connection Error - Did you add the proxy session token in Configuration?"
- Make sure the server is running
- Use the pre-filled URL with session token
- Check that ports 6274 and 6277 are available
-
"ProgrammingError: Error binding parameter"
- Ensure parameters are in correct format (not dictionaries)
- Check data types match function signatures
-
"File not found: categories.json"
- Ensure
categories.jsonexists in the project directory - Run the server from the correct directory
- Ensure
Logs
The server logs are displayed in the terminal when running in development mode.
Integration with Claude Desktop
-
Install the server:
uv run fastmcp install claude-desktop main.py -
Restart Claude Desktop
-
Test the integration:
- Ask Claude: "Add an expense for $15 lunch today"
- Ask Claude: "Show me my expenses for this month"
Contributing
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes
- Test thoroughly
- Submit a pull request
License
[Add your license here]
Troubleshooting
Port Conflicts
If you get port conflicts, you can:
- Kill existing processes:
pkill -f fastmcp - Use different ports by modifying the FastMCP configuration
Database Issues
- Delete
expenses.dbto reset the database - The database will be recreated automatically on next run
Permission Issues
Make sure you have write permissions in the project directory for database creation.
Examples
Sample Expense Entries
# Adding various expenses
add_expense("2024-10-02", 50.00, "groceries", "", "Weekly shopping")
add_expense("2024-10-02", 12.50, "transportation", "gas", "Gas station")
add_expense("2024-10-02", 8.75, "entertainment", "coffee", "Morning coffee")
Sample Queries
# List all October expenses
list_expenses("2024-10-01", "2024-10-31")
# List expenses for a specific week
list_expenses("2024-10-01", "2024-10-07")
Support
For issues and questions:
- Check the troubleshooting section
- Review the FastMCP documentation
- Open an issue in the repository
Built with FastMCP - A fast, simple framework for building MCP servers.