README
🚀 BitRefill MCP 服务器
BitRefill MCP 服务器是基于 TypeScript 的最小可行产品(MCP)服务器,借助 Model Context Protocol 提供 BitRefill 服务。它能实现礼品卡与电子货币搜索、手机充值等功能,为用户使用比特币购买礼品卡和充值手机提供便利。
🚀 快速开始
BitRefill MCP 服务器通过 Model Context Protocol (MCP) 提供工具,让 AI 助手(如 Claude)调用 BitRefill 的功能。其工作流程如下:
- 注册工具:服务器启动时向 MCP 注册可用工具。
- 处理请求:收到工具请求,执行相应操作。
- 返回响应:以结构化的 JSON 格式返回结果。
- 错误处理:若发生错误,返回包含错误信息的 JSON 响应。
由于服务器通过标准输入输出 (stdio) 进行通信,可使用任何支持 MCP 的工具进行调试。
✨ 主要特性
- 搜索礼品卡和电子货币。
- 手机充值。
- 其他相关服务。
📦 安装指南
使用 npm 安装
- 克隆仓库:
git clone https://github.com/bitrefill/bitrefill-mcp-server.git
cd bitrefill-mcp-server
- 安装依赖:
npm install
使用 Smithery 安装
要通过 Smithery 自动安装 BitRefill:
npx -y @smithery/cli install @bitrefill/bitrefill-mcp-server --client claude
使用 Docker
docker build -t bitrefill-mcp-server .
docker run -it --rm -e BITREFILL_API_SECRET=your_api_key_here -e BITREFILL_API_ID=your_api_id_here bitrefill-mcp-server
💻 使用示例
配置
在根目录下创建一个 .env 文件(可参考 .env.example),并添加以下内容:
BITREFILL_API_SECRET=your_api_key_here
BITREFILL_API_ID=your_api_id_here
可用工具
- search:搜索可用的礼品卡和电子货币。
- invoice:创建一个发票请求(需要 API 凭证)。
注意:如果没有设置 API 凭证,create_invoice 工具将不可用,并且不会注册到 MCP 服务器中。
开发
构建
npm run build
监控开发
npm run watch
调试
由于 BitRefill MCP 服务器通过 stdio 进行通信,调试可能具有挑战性。我们推荐使用 MCP Inspector:
npm run inspector
Inspector 将提供一个 URL,用于在浏览器中访问调试工具。
在不同环境中使用
在 Claude Desktop 中使用
在以下路径添加服务器配置:
- MacOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%/Claude/claude_desktop_config.json
配置内容如下:
{
"mcpServers": {
"bitrefill": {
"command": "npx",
"args": ["@smithery/cli", "start"],
"env": {
"BITREFILL_API_SECRET": "your_api_key_here",
"BITREFILL_API_ID": "your_api_id_here"
}
}
}
}
在 Cline 中使用
在 ~/.config/eline/mcp-config.json 文件中添加以下内容:
{
"servers": {
"bitrefill": {
"command": "npx",
"args": ["@smithery/cli", "start"],
"env": {
"BITREFILL_API_SECRET": "your_api_key_here",
"BITREFILL_API_ID": "your_api_id_here"
}
}
}
}
在 Cursor 中使用
在 config/cursor.mcp.json 文件中添加以下内容:
{
"servers": {
"bitrefill": {
"command": "npx",
"args": ["@smithery/cli", "start"],
"env": {
"BITREFILL_API_SECRET": "your_api_key_here",
"BITREFILL_API_ID": "your_api_id_here"
}
}
}
}
📚 详细文档
目录结构
bitrefill-mcp-server/
├── src/ # 源代码
│ ├── server.ts # 主服务器文件
│ └── tools/ # 可用工具
└── package.json # 项目依赖和配置
Scan to join WeChat group