bzheng29/expense-tracker-mcp
If you are the rightful owner of expense-tracker-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
Expense Tracker MCP Server is a comprehensive solution for managing and analyzing personal or business expenses using a modular architecture and professional-grade tools.
get_account_data
Retrieve account configuration and categories
query_transactions
Advanced transaction filtering with pagination
analyze_spending
Category breakdown, trends, and budget variance
get_summary
Period totals, budget status, quick stats
get_record_details
Detailed record information with related data
get_insights_data
Comprehensive data for AI analysis and insights
batch_create_transactions
Bulk transaction creation
export_data
Flexible data export in multiple formats
Expense Tracker MCP Server
A comprehensive expense tracking MCP server for Claude Desktop with 8 professional-grade tools based on simplified design principles and modular architecture.
š Features
- 8 Core Tools: From basic queries to AI-powered insights
- Modular Architecture: Clean separation of concerns with pluggable database support
- Database Agnostic: Support for SQLite (implemented), PostgreSQL, MongoDB, and MySQL (planned)
- Hierarchical Categories: Organized expense/income categories with Markdown tree view
- Advanced Analytics: Category breakdown, time trends, budget variance analysis
- Flexible Exports: JSON, CSV, and Markdown report formats
- Batch Operations: Efficient bulk transaction creation with validation
- Configuration Management: Environment variable support and validation
š ļø Tools
- get_account_data - Retrieve account configuration and categories
- query_transactions - Advanced transaction filtering with pagination
- analyze_spending - Category breakdown, trends, and budget variance
- get_summary - Period totals, budget status, quick stats
- get_record_details - Detailed record information with related data
- get_insights_data - Comprehensive data for AI analysis and insights
- batch_create_transactions - Bulk transaction creation
- export_data - Flexible data export in multiple formats
šļø Architecture
The server follows a modular architecture with clean separation of concerns:
expense-tracker-mcp/
āāā server.js # Main server entry point
āāā src/
ā āāā config.js # Configuration management
ā āāā database/
ā ā āāā interface.js # Database abstraction interface
ā ā āāā factory.js # Database factory pattern
ā ā āāā sqlite-adapter.js # SQLite implementation
ā ā āāā sqlite-methods.js # Extended SQLite methods
ā āāā tools/
ā ā āāā definitions.js # MCP tool schemas
ā ā āāā handlers.js # Tool implementation handlers
ā āāā utils/
ā āāā helpers.js # Utility functions
āāā package.json
Database Abstraction
The server uses a database abstraction layer that allows easy switching between different database backends:
- SQLite: Production-ready implementation (default)
- PostgreSQL: Planned - enterprise-grade support
- MongoDB: Planned - document-based storage
- MySQL: Planned - relational database alternative
Configuration
Environment variables are supported for all configuration options:
# Database configuration
DB_TYPE=sqlite # Database type (sqlite, postgres, mongodb)
DB_PATH=./expense_tracker.db # SQLite database path
DB_HOST=localhost # Database host (for postgres/mysql)
DB_PORT=5432 # Database port
DB_NAME=expense_tracker # Database name
DB_USER=postgres # Database user
DB_PASSWORD= # Database password
# Server configuration
SERVER_NAME=expense-tracker
SERVER_VERSION=1.0.0
DEBUG=false
# Application configuration
DEFAULT_CURRENCY=USD
MAX_TRANSACTION_BATCH=100
MAX_QUERY_LIMIT=100
SEED_DATA=true
š Prerequisites
- Node.js 18+
- Claude Desktop application
š§ Installation
- Clone this repository:
git clone https://github.com/bzheng29/expense-tracker-mcp.git
cd expense-tracker-mcp
- Install dependencies:
npm install
- Configure Claude Desktop by editing
claude_desktop_config.json
:
{
"mcpServers": {
"expense-tracker": {
"command": "node",
"args": ["<path-to-project>/server.js"],
"env": {}
}
}
}
- Restart Claude Desktop to load the MCP server.
š Running the Server
npm start
š Database Schema
The server uses SQLite with these tables:
- users - Account profiles with currency settings
- categories - Hierarchical expense/income categories
- ledgers - Account types (checking, savings, credit, cash)
- budgets - Monthly/weekly/yearly budget tracking
- transactions - Full transaction history with tags
- ai_insights - Stored recommendations and alerts
š Sample Data
The server includes sample data for testing:
- 14 categories in hierarchical structure (Food ā Groceries/Restaurants, etc.)
- 4 ledger accounts with realistic balances
- 4 active budgets with monthly limits
- 8 sample transactions from current month
- 3 AI insights for spending alerts and suggestions
š” Usage Examples
Monthly Budget Review
// Get current budget status
get_summary({
summary_type: 'budget_status',
period: 'this_month',
include_details: true
})
// Analyze spending by category
analyze_spending({
analysis_type: 'category_breakdown',
period: { start: '2024-01-01', end: '2024-01-31' }
})
// Get rich data for AI insights
get_insights_data({
data_scope: 'spending_patterns',
period: {
current: { start: '2024-01-01', end: '2024-01-31' },
comparison: { start: '2023-12-01', end: '2023-12-31' }
},
include_components: {
statistics: true,
historical_averages: true
}
})
Transaction Management
// Find all dining expenses over $50 this year
query_transactions({
type: 'expense',
filters: {
categories: ['dining', 'restaurants'],
min_amount: 50,
date_start: '2024-01-01'
},
sort: { field: 'amount', order: 'desc' }
})
// Create multiple transactions
batch_create_transactions({
transactions: [
{
type: 'expense',
amount: 45.99,
category: 'groceries',
description: 'Weekly shopping'
}
]
})
Data Export
// Generate year-end report
export_data({
export_type: 'summary_report',
format: 'markdown',
filters: {
date_start: '2024-01-01',
date_end: '2024-12-31'
}
})
š Key Features
- Pagination: Max 100 items per page for performance
- Flexible Filtering: By date, category, amount, text search
- Category Trees: Displayed as Markdown hierarchies
- Budget Variance: Analysis with over/under status
- Time Trends: Analysis by day/week/month grouping
- Multiple Export Formats: JSON, CSV, Markdown reports
- Batch Operations: With comprehensive validation
- AI Insights: With metadata and contextual recommendations
š¤ Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
š License
MIT License - see LICENSE file for details
š Links
š Issues
If you encounter any issues, please check:
- Node.js version compatibility
- Claude Desktop configuration
- Database permissions
For support, please open an issue in this repository.