ExpenseTracker MCP Server
Enables AI assistants to manage personal expenses by adding, querying, and summarizing expense data through a SQLite database and configurable categories.
README
ExpenseTracker MCP Server
A Model Context Protocol (MCP) server for managing personal expenses. Built with FastMCP, this server provides tools for tracking, querying, and summarizing expenses through an AI-ready interface.
Overview
ExpenseTracker is a lightweight MCP server that enables Claude and other AI applications to:
- Add expenses to a SQLite database with categories and notes
- Query expenses by date range for review and analysis
- Summarize expenses by category to understand spending patterns
- Manage categories through a configurable JSON file
This project demonstrates how to build a practical MCP server that integrates with AI assistants for real-world expense management.
What is MCP?
The Model Context Protocol (MCP) is an open standard that allows AI applications to interact with local tools and data sources safely. MCP servers expose resources and tools that AI models can access through a standardized interface, enabling features like:
- Tool use and automation
- Resource access and management
- Server-side processing with client-side oversight
Learn more at modelcontextprotocol.io
Features
- 📊 Add Expenses - Log expenses with date, amount, category, subcategory, and notes
- 🔍 Query Expenses - Retrieve expenses within a date range with full filtering
- 💰 Summarize Spending - Get expense totals by category for budget analysis
- 📁 Category Management - Maintain a flexible list of expense categories via JSON
- 🗄️ SQLite Backend - Persistent storage with no external dependencies
- 🤖 MCP Integration - Works seamlessly with Claude and other MCP-compatible clients
Installation
Prerequisites
- Python 3.14+
- pip or uv package manager
Setup
-
Clone the repository
git clone https://github.com/yourusername/local-mcp-server.git cd local-mcp-server -
Create a virtual environment
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate -
Install dependencies
pip install -e . # Or with uv: uv sync -
Create categories file (optional)
cat > categories.json << 'EOF' { "categories": [ "Food & Dining", "Transportation", "Entertainment", "Shopping", "Bills & Utilities", "Health & Fitness", "Travel", "Other" ] } EOF
Usage
Running the Server
Start the MCP server:
python main.py
The server will initialize the SQLite database and listen for MCP connections.
Available Tools
add_expense
Add a new expense entry to the database.
Parameters:
date(string, required): Date in YYYY-MM-DD formatamount(number, required): Expense amountcategory(string, required): Expense categorysubcategory(string, optional): Subcategory for detailed trackingnote(string, optional): Additional notes or description
Example:
{
"date": "2024-06-14",
"amount": 45.50,
"category": "Food & Dining",
"subcategory": "Restaurant",
"note": "Lunch at Italian place"
}
list_expenses
Retrieve expenses within a date range.
Parameters:
start_date(string, required): Start date in YYYY-MM-DD format (inclusive)end_date(string, required): End date in YYYY-MM-DD format (inclusive)
Example:
{
"start_date": "2024-06-01",
"end_date": "2024-06-30"
}
Returns: Array of expense objects with id, date, amount, category, subcategory, and note fields.
summarize
Get a summary of expenses by category within a date range.
Parameters:
start_date(string, required): Start date in YYYY-MM-DD format (inclusive)end_date(string, required): End date in YYYY-MM-DD format (inclusive)category(string, optional): Filter by specific category
Example:
{
"start_date": "2024-06-01",
"end_date": "2024-06-30",
"category": "Food & Dining"
}
Returns: Array of category summary objects with category and total_amount fields.
Resources
expense://categories
Access the current list of expense categories. The categories file is read fresh on each access, allowing modifications without server restart.
MIME Type: application/json
Configuration
Database
The SQLite database file is stored as expenses.db in the project root. The database is automatically initialized on first run with the expenses table.
Schema:
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
Edit categories.json to customize the list of expense categories available for your use case. Changes are reflected immediately without restarting the server.
Project Structure
local-mcp-server/
├── main.py # MCP server implementation
├── expenses.db # SQLite database (auto-created)
├── categories.json # Category definitions
├── pyproject.toml # Project configuration
├── uv.lock # Dependency lock file
├── LICENSE # GPL 3.0 license
└── README.md # This file
Technical Details
- Framework: FastMCP
- Database: SQLite3 (built-in Python library)
- Protocol: Model Context Protocol (MCP)
- Language: Python 3.14+
Integration with Claude
To use this server with Claude or other MCP clients, configure your client to connect to this server. Consult your client's documentation for MCP server setup instructions.
Development
Running Tests
Currently, no automated tests are included. Manual testing via an MCP client is recommended.
Code Style
The project follows standard Python conventions. Use of type hints and docstrings is encouraged for future contributions.
License
This project is licensed under the GNU General Public License v3.0. See the LICENSE file for details.
Contributing
Contributions are welcome! To contribute:
- Fork the repository
- Create a feature branch (
git checkout -b feature/your-feature) - Commit your changes (
git commit -am 'Add new feature') - Push to the branch (
git push origin feature/your-feature) - Open a Pull Request
Roadmap
Future enhancements may include:
- [ ] Budget tracking and alerts
- [ ] Recurring expenses
- [ ] Multi-user support
- [ ] Export functionality (CSV, PDF)
- [ ] Advanced analytics and reports
- [ ] Tagging system for expenses
- [ ] Receipt attachment storage
Support
For issues, questions, or suggestions, please open an issue on GitHub or contact the maintainers.
Acknowledgments
- Built with FastMCP
- Implements the Model Context Protocol
- Inspired by the need for AI-friendly expense tracking tools
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。