RevenueCat MCP服务器
模型上下文协议(MCP)服务器,公开完整的RevenueCat v2 REST API,用于与人工智能代理和IDE(如Cursor和VS Code)无缝集成。
特性
- API全面覆盖:5个RevenueCat资源中的所有25个CRUD操作
- IDE集成:原生MCP支持游标、VS代码和其他兼容IDE
- 类型安全:具有全面验证的完整TypeScript实现
- 生产就绪:重试逻辑、错误处理和结构化日志记录
- 轻量级:5MB以下的单个可执行文件
支持的资源
| 资源 | 创建 | 读取 | 更新 | 删除 | 列表 |
|---|---|---|---|---|---|
| 供品✅ | ✅ | ✅ | ✅ | ✅ | |
| 产品 | ✅ | ✅ | ✅ | ✅ | ✅ |
| 权利 | ✅ | ✅ | ✅ | ✅ | ✅ |
| 套餐 | ✅ | ✅ | ✅ | ✅ | ✅ |
| 价格实验 | ✅ | ✅ | ✅ | ✅ | ✅ |
安装
选项1:全局安装(推荐)
npm install -g revenuecat-mcp选项2:来源
git clone https://github.com/iamhenry/revenuecat-mcp.git
cd revenuecat-mcp
npm install
npm run build
npm install -g .配置
1.环境设置
创建一个 .env 在项目中创建文件或设置环境变量:
REVENUECAT_SECRET_KEY=sk_your_secret_key_here
RC_API_URL=https://api.revenuecat.com/v2 # Optional
LOG_LEVEL=info # Optional2.获取您的RevenueCat凭证
- 登录到您的 RevenueCat仪表板
- 导航到项目设置
- 生成具有适当权限的密钥
- 从URL或项目设置中记录您的项目ID
IDE集成
光标
# Add the MCP server to Cursor
claude mcp add revenuecat revenuecat-mcp
# Test the integration
claude mcp test revenuecatVS代码
添加到MCP配置文件中:
{
"servers": {
"revenuecat": {
"command": "revenuecat-mcp"
}
}
}使用示例
产品列表
echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": {"name": "ListProducts", "arguments": {"project_id": "your_project_id"}}}' | revenuecat-mcp创建产品
echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": {"name": "CreateOffering", "arguments": {"project_id": "your_project_id", "name": "Premium Offering", "description": "Our premium subscription offering"}}}' | revenuecat-mcp获取产品详细信息
echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": {"name": "GetProduct", "arguments": {"project_id": "your_project_id", "id": "prod_123456"}}}' | revenuecat-mcp可用的MCP工具
供品
CreateOffering-创建新产品GetOffering-检索产品详细信息UpdateOffering-更新产品属性DeleteOffering-删除产品ListOfferings-按页码列出所有产品
产品
CreateProduct-创建新产品GetProduct-检索产品详细信息UpdateProduct-更新产品属性DeleteProduct-删除产品ListProducts-列出所有带页码的产品
权益
CreateEntitlement-创建新权限GetEntitlement-检索权限详细信息UpdateEntitlement-更新权限属性DeleteEntitlement-删除权限ListEntitlements-按页码列出所有权限
包裹
CreatePackage-创建新包GetPackage-检索包裹详细信息UpdatePackage-更新包属性DeletePackage-删除包ListPackages-列出所有带分页的包
价格实验
CreatePriceExperiment-创建新的价格实验GetPriceExperiment-检索价格实验详细信息UpdatePriceExperiment-更新价格实验属性DeletePriceExperiment-删除价格实验ListPriceExperiments-按页码列出所有价格实验
错误处理
服务器将RevenueCat HTTP错误映射到相应的MCP错误代码:
400 Bad Request→VALIDATION_ERROR401 Unauthorized→UNAUTHENTICATED403 Forbidden→FORBIDDEN404 Not Found→NOT_FOUND429 Too Many Requests→RATE_LIMITED500+ Server Errors→INTERNAL
发展
先决条件
- Node.js≥18
- npm或纱线
- 具有API访问权限的RevenueCat帐户
地方发展
# Clone the repository
git clone https://github.com/iamhenry/revenuecat-mcp.git
cd revenuecat-mcp
# Install dependencies
npm install
# Set up environment
cp .env.example .env
# Edit .env with your credentials
# Build the project
npm run build
# Test locally
npm run dev项目结构
src/
├── index.ts # MCP server entry point
├── core/
│ ├── config.ts # Environment configuration
│ ├── entities/ # TypeScript interfaces
│ ├── use-cases/ # Business logic
│ └── validation/ # Input validation
├── infrastructure/
│ ├── revenuecat-client.ts # HTTP client
│ └── logger.ts # Structured logging
└── presentation/
└── mcp-server.ts # MCP protocol handler安全
- 不记录任何秘密(自动编辑)
- 启动时验证环境变量
- 所有API调用的输入验证
- 安全错误处理,无数据泄露
贡献
- 分叉存储库
- 创建要素分支:
git checkout -b feature-name - 进行更改并添加测试
- 承诺:
git commit -am 'Add feature' - 推:
git push origin feature-name - 提交拉取请求
许可证
MIT许可证-请参阅 许可证 文件以获取详细信息。
支持
- 📚 RevenueCat文档
- 🐛 问题追踪
- 💬 讨论
更新日志
v1.0.0
- 具有完整的RevenueCat v2 API覆盖范围的首次发布
- 支持所有5种资源,并具有完整的CRUD操作
- 流行IDE的MCP集成
- 生产就绪错误处理和记录
