内容
# ledger-service MCP Server
用于通过 Claude 访问和管理账本文件的 MCP Server。
## 组件
### 工具
该服务器实现了三个用于账本管理的工具:
- **list-accounts**: 列出账本中的所有账户
- 接受 "year" 作为必需参数
- 返回所有可用账户的格式化列表
- **account-balance**: 获取特定账户的余额
- 接受 "year" 和 "account" 作为必需参数
- 返回指定账户的当前余额
- **account-register**: 显示账户的交易登记
- 接受 "year" 和 "account" 作为必需参数
- 返回指定账户的详细交易历史
## 安装
### 前提条件
- Python 3.13 或更高版本
- `uv` 包管理器
- Node.js 和 npm(用于调试)
### 从 PyPI 安装
```bash
uv pip install ledger-service
```
## 调试
使用 inspector 调试服务器:
```bash
npx @modelcontextprotocol/inspector \
uv \
--directory /path/to/ledger-service \
run \
ledger-service
```
<img src="mcp-server-debug.png" alt="MCP Inspector debugging interface">
### 配置 Claude Desktop
将服务器配置添加到 Claude Desktop 的配置文件中:
在 MacOS 上:`~/Library/Application\ Support/Claude/claude_desktop_config.json`
在 Windows 上:`%APPDATA%/Claude/claude_desktop_config.json`
<details>
<summary>开发配置</summary>
```json
"mcpServers": {
"ledger-service": {
"command": "uv",
"args": [
"--directory",
"/path/to/ledger-service",
"run",
"ledger-service"
]
}
}
```
</details>
<details>
<summary>生产配置</summary>
```json
"mcpServers": {
"ledger-service": {
"command": "uvx",
"args": [
"ledger-service"
]
}
}
```
</details>
## 开发
### 本地设置
1. 克隆存储库
2. 创建并激活虚拟环境
3. 安装依赖项:
可以通过修改 `server.py` 中的 `LEDGER_BASE_PATH` 常量来配置基本路径。
## 许可证
GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007