这是一个基于 TypeScript 的 MCP 服务器,提供对接 Bitrefill 服务的访问,允许您搜索礼品卡、手机充值等。此服务器实现了模型上下文协议(Model Context Protocol),以将 Bitrefill 功能暴露给 AI 助手。
该服务器使用模型上下文协议(MCP)与 Claude 和类似的 AI 助手进行通信。它:
应用服务器遵循以下架构:
src/
├── index.ts # 主入口点
├── constants/ # 静态数据
│ ├── categories.ts # 产品类别
│ └── payment_methods.ts # 支付方式
├── handlers/ # MCP 请求处理器
│ ├── resources.ts # 资源端点
│ └── tools.ts # 工具实现
├── schemas/ # 数据验证模式
│ ├── detail.ts # 产品详情响应类型
│ ├── invoice.ts # 发票模式
│ ├── misc.ts # 杂项模式
│ ├── order.ts # 订单模式
│ └── search.ts # 搜索参数和响应类型
├── services/ # API 服务
│ ├── invoices.ts # 发票服务
│ ├── misc.ts # 杂项服务
│ ├── orders.ts # 订单服务
│ ├── products.ts # 产品详情服务
│ └── search.ts # 搜索功能
└── utils/ # 实用函数
├── index.ts # 错误日志等
└── api/ # API 客户端
├── authenticated.ts # 认证的 API 客户端
├── base.ts # 基础 API 客户端
└── public.ts # 公共 API 客户端
bitrefill://product-types - Bitrefill 上可用的产品类型列表bitrefill://categories/{type} - 特定产品类型可用的类别列表(例如,bitref fill://categories/gift-cards)search - 搜索礼品卡、esims、手机充值等
query(例如,'Amazon','Netflix','AT&T' 或 '*' 表示所有)country,language,limit,skip,categorydetail - 获取产品的详细信息
id(产品标识符)categories - 获取完整的产品类型/类别映射
create_invoice - 创建购买产品的新发票(需要 API 密钥)
products(要包含在发票中的产品数组)
product_idquantity,value,package_id,phone_number,email,send_email,send_smspayment_method(其中之一:"balance","bitcoin","lightning")webhook_url,auto_payget_invoices - 检索带有可选过滤器的发票列表
start,limit,after,beforeget_invoice - 根据 ID 检索特定发票的详细信息
id(发票标识符)pay_invoice - 支付未支付的发票(仅适用于“余额”支付方式)
id(发票标识符)get_orders - 检索带有可选过滤器的订单列表
start,limit,after,beforeget_order - 根据 ID 检索特定订单的详细信息
id(订单标识符)unseal_order - 根据 ID 揭示特定订单的代码和 PIN
id(订单标识符)get_account_balance - 检索您的账户余额
ping - 检查 Bitrefill API 是否可用
要使用除 search、categories 和 detail 之外的所有依赖于 Bitrefill API 的工具,您需要设置 Bitrefill API 凭据:
.env 文件(您可以从 .env.example 复制)BITREFILL_API_SECRET=your_api_key_here
BITREFILL_API_ID=your_api_id_here
只有设置了 API 凭据时,create_invoice 工具才会可用。如果未设置 API 凭据,则不会注册该工具,也不会出现在可用工具列表中。
安装依赖项:
npm install
构建服务器:
npm run build
开发时自动重建:
npm run watch
由于 MCP 服务器通过标准 I/O 进行通信,调试可能会很困难。我们推荐使用 MCP Inspector,它作为一个包脚本提供:
npm run inspector
Inspector 将提供一个 URL,以便您可以在浏览器中访问调试工具。
要通过 Smithery 自动安装 Bitrefill for Claude Desktop:
npx -y @smithery/cli install @bitrefill/bitrefill-mcp-server --client claude
在以下位置添加服务器配置:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%/Claude/claude_desktop_config.json{
"mcpServers": {
"bitrefill": {
"command": "npx",
"args": ["-y", "bitrefill-mcp-server"],
"env": {
"BITREFILL_API_SECRET": "your_api_key_here",
"BITREFILL_API_ID": "your_api_id_here"
}
}
}
}
{
"mcpServers": {
"github.com/bitrefill/bitrefill-mcp-server": {
"command": "npx",
"args": ["-y", "bitrefill-mcp-server"],
"disabled": false,
"autoApprove": ["search", "detail", "categories"],
"env": {
"BITREFILL_API_ID": "your_api_id_here",
"BITREFILL_API_SECRET": "your_api_key_here"
}
}
}
}
额外的 Cline 配置选项:
disabled:设置为 false 启用服务器autoApprove:不需要每次使用都明确批准的工具列表npx -y bitrefill-mcp-server
create_invoice 工具,请添加环境变量:
您还可以使用 Docker 运行服务器。首先,构建镜像:
docker build -t bitrefill-mcp-server .
然后运行容器:
docker run -e BITREFILL_API_SECRET=your_api_key_here -e BITREFILL_API_ID=your_api_id_here bitrefill-mcp-server
对于开发,您可能希望将源代码挂载为卷:
docker run -v $(pwd):/app --env-file .env bitrefill-mcp-server