个人开支追踪服务

一款基于MCP协议的个人开支追踪服务,支持从Claude Desktop添加、分类、统计和分析开支数据,并提供AI驱动的消费习惯分析。

  • by AmeyMedewar
  • Python
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 AmeyMedewar/Expense-tracker-mcp-server

使用说明

💰 费用跟踪MCP服务器

一个模型上下文协议(MCP)服务器,可帮助您直接从Claude Desktop跟踪和管理个人开支。添加支出、分类支出、查看摘要,并在人工智能的帮助下分析您的财务习惯。

✨ 特性

  • 添加费用:记录费用,包括金额、类别和描述
  • 类别跟踪:按定制类别(食品、交通、娱乐等)组织费用
  • 总计算:获取所有费用或按类别的即时总计
  • 费用清单:查看所有记录的费用及其详细信息
  • 删除费用:删除不正确或重复的条目
  • 类别摘要:请参阅按类别分列的支出明细和总额
  • 持久化存储:节省的所有费用 expenses.json 自动地
  • AI分析:让克劳德分析你的支出模式并提供见解

🚀 快速开始

先决条件

  • Python 3.8+
  • 支持MCP的Claude Desktop应用程序
  • fastmcp 包裹

安装

# Clone the repository
git clone <repository-url>
cd expense-tracker

# Install dependencies
pip install fastmcp

配置MCP服务器

添加到您的Claude Desktop配置文件中:

MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json 视窗: %APPDATA%/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "expense-tracker": {
      "command": "python",
      "args": ["/path/to/your/expense_tracker_mcp.py"]
    }
  }
}

更新配置后重新启动Claude Desktop。

📖 如何使用

增加费用

Add an expense of $45.50 for groceries at Whole Foods
Add $12 for lunch, category: Food
Record $60 expense for Uber rides in Transport category

查看总费用

What's my total spending?
Show me all my expenses
How much have I spent so far?

类别分析

Show me all my Food expenses
How much did I spend on Transport?
Get expenses in Entertainment category

总结与见解

Give me a category summary
What's my spending breakdown by category?
Analyze my spending patterns
Which category do I spend most on?

删除费用

Delete expense with ID 5
Remove the last expense I added

🛠️ 可用工具

add_expense

参数:

  • amount (浮动):费用金额
  • category (str):费用类别
  • description (str,可选):其他详细信息

例子:

add_expense(amount=25.99, category="Food", description="Lunch at cafe")

get_total_expenses

返回所有支出的总金额

get_expenses_by_category

参数:

  • category (str):要筛选的类别名称

返回特定类别中的所有费用及其总计

list_all_expenses

返回所有记录费用的详细列表

delete_expense

参数:

  • expense_id (int):要删除的费用ID

从记录中删除费用

get_category_summary

返回按类别分组、按总额排序的支出明细

📁 项目结构

expense-tracker/
├── expense_tracker_mcp.py    # MCP server code
├── expenses.json             # Auto-generated expense data
└── README.md                 # This file

💡 使用技巧

智能类别:使用一致的类别名称以更好地跟踪:

  • 食品、杂货、餐饮
  • 交通、通勤、天然气
  • 娱乐、电影、游戏
  • 购物、服装、电子
  • 账单、水电费、租金
  • 健康、医疗、健身

描述性注释:在费用中添加详细信息,以便更好地召回:

Add $45 for groceries - weekly shopping at Target
Add $8.50 for coffee - morning meeting at Starbucks

定期评论:请克劳德分析你的支出:

Analyze my spending from the past week
What categories should I reduce spending on?
Compare my Food vs Entertainment expenses

AI洞察:让克劳德帮忙做预算:

I want to save $500/month. Analyze my expenses and suggest where to cut back
Create a monthly budget based on my spending patterns
What's my average daily spending?

📊 工作流示例

You: "Add $52.30 for groceries at Trader Joe's, category Food"
Claude: ✅ Expense added successfully! ID: 1, Amount: $52.30, Category: Food

You: "Add $15 for Uber to work, Transport"
Claude: ✅ Expense added successfully! ID: 2, Amount: $15.00, Category: Transport

You: "Add $45 for dinner with friends, Food"
Claude: ✅ Expense added successfully! ID: 3, Amount: $45.00, Category: Food

You: "Give me a category summary"
Claude: 
Expense Summary by Category:

Food: $97.30 (2 transactions)
Transport: $15.00 (1 transaction)

Grand Total: $112.30

You: "What percentage of my spending is on food?"
Claude: Based on your expenses, Food accounts for 86% of your total spending 
($97.30 out of $112.30). This is quite high - would you like suggestions 
for reducing food expenses?

🔧 数据存储

  • 费用存储在 expenses.json 与脚本位于同一目录中
  • 数据在Claude Desktop会话中持续存在
  • JSON格式使备份或迁移数据变得容易
  • 每项费用都有一个唯一的ID、时间戳和分类

示例expenses.json:

[
  {
    "id": 1,
    "amount": 52.30,
    "category": "Food",
    "description": "Groceries at Trader Joe's",
    "date": "2025-11-02 14:30:22"
  },
  {
    "id": 2,
    "amount": 15.00,
    "category": "Transport",
    "description": "Uber to work",
    "date": "2025-11-02 15:45:10"
  }
]

🚧 未来的增强功能

  • []日期范围筛选(每周、每月、每年查看)
  • []每个类别的预算限制和警报
  • []导出到CSV或Excel
  • []经常性支出模板
  • []多币种支持
  • []可视化图表
  • []分摊成本的费用分摊
  • []收据图像附件
  • []月度/年度比较报告
  • []自定义类别创建和管理

🔒 隐私和安全

  • 本地存储在计算机上的所有数据
  • 没有云同步或外部服务
  • expenses.json 包含您的财务数据-确保其安全
  • 考虑定期备份文件

💰 高级用例

预算跟踪:

I have a $500/month food budget. How am I doing this month?
Alert me if my Transport spending exceeds $100

支出分析:

What's my average weekly spending?
Compare my spending this month vs last month
Show me my top 5 most expensive purchases

财务规划:

Based on my spending, how much can I save monthly?
What's the best category to cut back on?
Project my annual expenses based on current patterns

🤝 贡献

欢迎投稿、问题和功能请求!

📝 许可证

MIT许可证


由以下材料制成❤️ 使用FastMCP和Claude AI 更聪明地追踪,更明智地花钱! 💸