费用追踪服务

一个基于SQLite数据库的Model Context Protocol (MCP)服务器,用于管理、追踪和分析个人或团队的支出。

  • by ivardu
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 ivardu/test-mcp

使用说明

费用跟踪MCP服务器

用于管理SQLite数据库后端费用的模型上下文协议(MCP)服务器。与Claude Desktop无缝集成,帮助您跟踪和分析支出。

特性

  • 添加费用:记录费用,包括类别、金额、描述和日期
  • 查询费用:通过可选的按类别筛选来检索费用
  • 费用汇总:按类别获取详细的统计数据和细分
  • 删除费用:删除费用条目
  • SQLite存储:持久本地数据库

安装和设置

1.安装依赖项

uv sync

2.运行MCP服务器

uv run fastmcp dev main.py

可用工具

add_expense

将新费用添加到数据库中。

参数:

  • category (字符串,必填):费用类别(例如,“食品”、“交通”、“公用事业”、“娱乐”)
  • amount (浮动,必填):支出金额
  • description (字符串,可选):其他详细信息
  • date (字符串,可选):YYYY-MM-DD格式的日期(默认为今天)

例子:

{
  "category": "food",
  "amount": 15.50,
  "description": "Lunch at cafe",
  "date": "2026-03-27"
}

get_expenses

从数据库中检索费用。

参数:

  • category (字符串,可选):按特定类别筛选
  • limit (整数,可选):最大结果数(默认值:50)

例子:

{
  "category": "food",
  "limit": 10
}

get_expense_summary

获取费用的汇总统计数据。

参数:

  • category (字符串,可选):按特定类别筛选
  • start_date (字符串,可选):开始日期(YYYY-MM-DD)
  • end_date (字符串,可选):结束日期(YYYY-MM-DD)

例子:

{
  "start_date": "2026-03-01",
  "end_date": "2026-03-31"
}

delete_expense

按ID删除支出。

参数:

  • expense_id (整数,必填):要删除的费用ID

Claude桌面集成

配置

  1. 找到配置文件:

    • 窗户: %APPDATA%\Claude\claude_desktop_config.json
    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Linux: ~/.config/Claude/claude_desktop_config.json
  2. 添加MCP服务器配置:

{
  "mcpServers": {
    "expense_tracker": {
      "command": "uv",
      "args": [
        "run",
        "--with",
        "fastmcp",
        "python",
        "D:\\Agentic AI\\Claude\\MCP\\main.py"
      ]
    }
  }
}

Windows用户注意事项: 使用正斜杠(/)或双反睫毛(\\)在路上。

  1. 重新启动克劳德桌面 应用更改

使用Claude Desktop

配置后,您可以:

  • 让克劳德加一笔费用:“加一笔20美元的杂货费”
  • 查询你的开支:“显示我所有的食物开支”
  • 获取摘要:“我这个月的总支出是多少?”
  • 分析模式:“按类别比较我的支出”

数据库模式

SQLite数据库包括 expenses 桌子上有:

  • id:主键(自动递增)
  • category:费用类别
  • amount:支出金额
  • description:可选描述
  • date:支出日期(YYYY-MM-DD)
  • created_at:数据库条目的时间戳

Claude使用示例

User: Add a $45.99 restaurant expense for dinner last night
Claude: [Uses add_expense tool to record the expense]

User: How much did I spend on food this month?
Claude: [Uses get_expense_summary to calculate totals]

User: Show me my top spending categories
Claude: [Analyzes the data and presents a breakdown]

故障排除

MCP服务器无法启动:

uv run fastmcp dev main.py

数据库错误:

  • 确保项目目录可写
  • 删除 expenses.db 重置数据库

Claude Desktop未连接:

  1. 检查配置路径是否正确
  2. 验证中的命令路径 claude_desktop_config.json
  3. 完全重新启动克劳德桌面
  4. 检查Claude Desktop日志中的错误消息

许可证

麻省理工学院