使用说明
费用跟踪器-远程MCP服务器
使用FastMCP构建的用于跟踪费用的远程MCP(模型上下文协议)服务器。此服务器可以通过HTTP访问,使其适用于远程部署和云托管。
🌟 特性
- 远程HTTP服务器:可通过网络从任何MCP客户端访问
- 异步SQLite:使用非阻塞数据库操作
aiosqlite - 费用跟踪:按类别添加、列出和汇总费用
- 类别资源:预定义的支出类别
📋 先决条件
- Python 3.11+
- 紫外线 包管理器
🚀 安装
# Clone the repository
git clone https://github.com/farhanrhine/remote-mcp-server.git
cd remote-mcp-server
# Install dependencies
uv sync
🏃 运行服务器
选项1:作为HTTP服务器运行(远程)
uv run python main.py
服务器将在以下位置可用: http://0.0.0.0:8000/mcp
选项2:使用fastmcp命令
uv run fastmcp run main.py --transport http --host 0.0.0.0 --port 8000
选项3:使用MCP检查器运行(开发)
端子1 -启动服务器:
uv run python main.py
2号航站楼 -启动检查器:
uv run fastmcp dev main.py
选项4:安装到Claude桌面(本地)
uv run fastmcp install claude-desktop main.py
📁 项目结构
remote-mcp-server/
├── main.py # MCP server with expense tracking tools
├── pyproject.toml # Project dependencies
├── categories.json # Custom expense categories (optional)
└── README.md # This file
🛠️ MCP工具
| 工具 | 说明 | 参数 |
|---|---|---|
add_expense |
添加新费用 | date, amount, category, subcategory, note |
list_expenses |
按日期范围列出费用 | start_date, end_date |
summarize |
按类别汇总 | start_date, end_date, category (可选) |
📦 MCP资源
| 资源URI | 描述 |
|---|---|
expense:///categories |
费用类别列表 |
🔄 运行命令备忘单
| 任务 | 命令 |
|---|---|
| 运行HTTP服务器 | uv run python main.py |
| 用fastmcp跑步 | uv run fastmcp run main.py --transport http --host 0.0.0.0 --port 8000 |
| 运行stdio模式 | uv run fastmcp run main.py |
| 开发模式(检查器) | uv run fastmcp dev main.py (要求服务器先运行) |
| 安装到Claude | uv run fastmcp install claude-desktop main.py |
| 添加依赖关系 | uv add <package> |
| 同步依赖关系 | uv sync |
⚙️ 运输方式
| 模式 | 命令 | 用例 |
|---|---|---|
| HTTP | mcp.run(transport="http", host="0.0.0.0", port=8000) |
远程访问、云部署 |
| 流式HTTP | mcp.run(transport="streamable-http", ...) |
流媒体响应 |
| 站立 | mcp.run() 或 mcp.run(transport="stdio") |
本地CLI客户端(Claude Desktop) |
🔧 配置
数据库位置
SQLite数据库存储在系统的temp目录中:
- 视窗:
C:\Users\<user>\AppData\Local\Temp\expenses.db - Linux/Mac:
/tmp/expenses.db
自定义类别
创建一个 categories.json 项目根目录中的文件:
{
"categories": [
"Food & Dining",
"Transportation",
"Shopping",
"Entertainment",
"Bills & Utilities"
]
}
📚 相关链接
📄 许可证
麻省理工学院