使用说明
拆分MCP服务器
Ruby MCP服务器通过 模型上下文协议。适用于任何兼容MCP的客户端——Claude Code、Claude Desktop、Cursor等。
先决条件
- Ruby 3.x
- 打包机
安装
# install homebrew if not installed
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install ruby
git clone https://github.com/imtheaman/splitwise_mcp.git
cd splitwise_mcp
bundle install
cp .env.example .env # optional — only needed for MCP Inspector / standalone use
如果使用 .env,编辑它并添加您的Splitwise API密钥。使用MCP客户端(Claude Code、Cursor等)时,您可以通过 "env" 请改为在客户端配置中使用块。
获取API密钥
- 在以下网址注册应用程序https://secure.splitwise.com/apps
- 在应用程序的详细信息页面上,生成个人API密钥
- 或者,使用OAuth 2.0访问令牌
配置
| 变量 | 必填 | 默认 | 描述 |
|---|---|---|---|
SPLITWISE_API_KEY |
是* | - | 个人API密钥 |
SPLITWISE_OAUTH_ACCESS_TOKEN |
是* | -- | OAuth 2.0访问令牌 |
SPLITWISE_CACHE_TTL |
没有 | 86400 |
缓存TTL(秒) |
SPLITWISE_MATCH_THRESHOLD |
没有 | 70 |
模糊匹配阈值(0-100) |
SPLITWISE_RESOLVER_CACHE_TTL |
没有 | 300 |
解析器缓存TTL(秒) |
*其中之一 SPLITWISE_API_KEY 或 SPLITWISE_OAUTH_ACCESS_TOKEN 是必需的。
Claude代码设置
将此添加到您的 ~/.mcp.json:
{
"mcpServers": {
"splitwise_mcp": {
"command": "ruby",
"args": ["server.rb"],
"cwd": "/path/to/splitwise-mcp",
"env": {
"SPLITWISE_API_KEY": "YOUR_API_KEY"
}
}
}
}
Claude桌面设置
将此添加到您的 claude_desktop_config.json:
{
"mcpServers": {
"splitwise_mcp": {
"command": "ruby",
"args": ["server.rb"],
"cwd": "/path/to/splitwise-mcp",
"env": {
"SPLITWISE_API_KEY": "YOUR_API_KEY"
}
}
}
}
光标设置
将其添加到项目级别 .cursor/mcp.json 或全球 ~/.cursor/mcp.json:
{
"mcpServers": {
"splitwise_mcp": {
"command": "ruby",
"args": ["server.rb"],
"cwd": "/path/to/splitwise-mcp",
"env": {
"SPLITWISE_API_KEY": "YOUR_API_KEY"
}
}
}
}
提示示例
以下是一些可用于此MCP服务器的示例提示:
How much does John owe me?
Here's the bill image — split it between me, John, and Sarah in the NYC Trip group. I had the burger, John had pasta, and Sarah had the salad
Show me all expenses from last month in the Roommates group
Create a new group called 'Goa Trip' and add john@example.com and sarah@example.com
Delete the duplicate lunch expense from yesterday
What are my recent notifications?
Show me my balance with Sarah
Here's a photo of the receipt — read it and add the expense split between me and my roommates
MCP检查员
与MCP检查器交互的测试工具:
npx @modelcontextprotocol/inspector ruby server.rb
可用工具(35)
| 类别 | 工具 |
|---|---|
| 用户 (3) | GetCurrentUser, GetUser, UpdateUser |
| 费用 (6) | GetExpenses, GetExpense, CreateExpense, UpdateExpense, DeleteExpense, UndeleteExpense |
| 群组 (7) | GetGroups, GetGroup, CreateGroup, DeleteGroup, UndeleteGroup, AddUserToGroup, RemoveUserFromGroup |
| 老友记 (5) | GetFriends, GetFriend, CreateFriend, CreateFriends, DeleteFriend |
| 评论 (3) | GetComments, CreateComment, DeleteComment |
| 通知 (1) | GetNotifications |
| 决心 (3) | ResolveFriend, ResolveGroup, ResolveCategory |
| 公用事业 (2) | GetCategories, GetCurrencies |
| 算术 (5) | AddTool, SubtractTool, MultiplyTool, DivideTool, ModuloTool |
项目结构
splitwise-mcp/
├── server.rb # Entry point — registers tools, starts MCP server
├── Gemfile # Dependencies
├── .env.example # Environment variable template
├── openapi.json # Splitwise OpenAPI spec (reference)
└── lib/
├── cache.rb # In-memory TTL cache
├── client.rb # Splitwise HTTP client
├── errors.rb # Custom error classes
├── resolver.rb # Fuzzy name-to-ID resolution
├── validators.rb # Input validation helpers
└── tools/
├── arithmetic_tools.rb # Add, Subtract, Multiply, Divide, Modulo
├── comment_tools.rb # GetComments, CreateComment, DeleteComment
├── expense_tools.rb # CRUD + undelete for expenses
├── friend_tools.rb # CRUD for friends
├── group_tools.rb # CRUD + member management for groups
├── notification_tools.rb # GetNotifications
├── resolution_tools.rb # ResolveFriend, ResolveGroup, ResolveCategory
├── user_tools.rb # GetCurrentUser, GetUser, UpdateUser
└── utility_tools.rb # GetCategories, GetCurrencies