Bitrepull MCP服务器(示例实现)
这是一个示例/参考实现。 对于生产用途,请连接到 官方托管的Bitrefill电子商务MCP 在 https://api.bitrefill.com/mcp 相反。它由Bitrefill维护,支持OAuth,并公开相同的工具,而无需运行、部署或更新任何东西。 如果需要,请使用此存储库 了解如何构建Bitrefill MCP, 叉它, 扩展它,或 自宿主定制变体 在上面 Bitrellow API v2.此服务器包装 Bitrellow API v2 (https://api.bitrefill.com/v2)使用 Authorization: Bearer ${BITREFILL_API_KEY}.只有 请求 用Zod对参数进行验证;API响应以不变的JSON文本形式返回。
使用官方远程MCP(建议用于生产)
这 Bitrefill电子商务MCP 由Bitrefill托管,是与ChatGPT、Claude Desktop/Code、Cursor和任何其他MCP兼容客户端集成的推荐方式。
- OAuth(推荐)。将您的客户指向:
https://api.bitrefill.com/mcp您将被重定向到Bitrefill进行登录和授权访问。不需要API密钥处理。
- API密钥.从以下位置添加密钥 bitrepull.com/account/developers:
https://api.bitrefill.com/mcp/YOUR_API_KEY每个客户端的设置指南: ChatGPT, 克劳德桌面, 克劳德代码, 光标.
何时使用此仓库
仅在需要时运行此本地MCP:
- 研究Bitrefill MCP服务器的工作参考实现。
- 分叉它以添加自定义工具、提示、验证、日志记录或路由。
- 私有网络或空气间隙环境中的自主机。
- 尝试使用更广泛的v2端点集(此示例公开了18个工具,而官方远程MCP有意公开了一组精心策划的7个工具;请参阅 电子商务MCP).
对于日常的“从我的人工智能助手那里购买礼品卡/eSIM”用例,更喜欢上面的托管服务器。
配置
- 创建API密钥: 比特币充值账户→ 开发者.
- 设置在环境中(或
.env对于本地跑步):
BITREFILL_API_KEY=your_api_key_here如果 BITREFILL_API_KEY 缺失, 无工具 已注册(v2甚至需要身份验证 ping).
工具(v1.0.0)
| 工具 | API |
|---|---|
search-products | GET /products/search (与 q)或 GET /products (浏览) |
product-details | GET /products/{id} |
buy-products | POST /invoices |
get-invoice-by-id | GET /invoices/{id} |
get-order-by-id | GET /orders/{id} |
list-invoices | GET /invoices |
list-orders | GET /orders |
pay-invoice | POST /invoices/{id}/pay |
get-account-balance | GET /accounts/balance |
check-phone-number | GET /check_phone_number |
ping | GET /ping |
list-esim-products | GET /products/esims |
get-esim-product | GET /products/esims/{id} |
create-esim-invoice | POST /esims |
get-esim-invoice | GET /esims/invoice/{id} |
pay-esim-invoice | POST /esims/invoice/{id}/pay |
list-esims | GET /esims |
get-esim | GET /esims/{id} |
与0.x相比的突破性变化: 旧snake_case工具名称(search, create_invoice, unseal_order, ...)已删除。使用上面的名字。没有 unseal_order 在v2中; GET /orders/{id} 回报 redemption_info 交付时。
资源
bitrefill://payment-methods:允许payment_method字符串用于buy-products/create-esim-invoicebitrefill://category-slugs:B2Bcategory产品列表/搜索的查询值bitrefill://product-types:产品系列密钥bitrefill://product-types/{productType}:每个家庭的蛞蝓类别
项目布局
src/
index.ts
types/api.ts # Optional TS shapes for API JSON (not validated at runtime)
constants/ # payment_method list, category slugs
handlers/ # resources.ts, tools.ts
schemas/ # Zod: inputs only
services/ # API calls (search, products, invoices, orders, esims, misc)
utils/api/ # base (BitrefillApiError), authenticated (Bearer v2)发展
pnpm install
pnpm run build
pnpm run typecheck
pnpm run lint烟雾测试(仅此回购的MCP)
烟雾测试始终开始 这个包裹的 服务器(node build/index.js 之后 pnpm run build).他们确实如此 不 打开 https://api.bitrefill.com/mcp 或任何其他远程MCP URL。
推荐:MCP客户端正在处理中(stdio到 build/index.js):
pnpm run build
pnpm run smoke同 pnpm run test-services (别名)。
可选的: MCP检查员 CLI,仍然只是反对 这 服务器:
pnpm run build
pnpm run smoke:inspector全部18个工具 (Inspector CLI、摘要行、故意使用的虚拟ID):
pnpm run test:inspector:all-tools检查员使用 --tool-arg key=value (对多个键重复),而不是单个JSON blob。对于嵌套数据,在值中使用JSON,例如。\ --tool-arg 'products=[{"product_id":"x","value":10}]'.
交互式UI(仅限本地服务器):
pnpm run build
pnpm run inspector示例:
pnpm dlx @modelcontextprotocol/inspector node build/index.js --cli --method tools/call --tool-name ping
pnpm dlx @modelcontextprotocol/inspector node build/index.js --cli --method tools/call --tool-name product-details --tool-arg id=test-gift-card-code客户端示例(自托管示例)
提醒:对于生产,更喜欢托管 https://api.bitrefill.com/mcp (OAuth)通过下面的stdio配置。光标/克劳德风格MCP配置,把钥匙递进去 env:
{
"mcpServers": {
"bitrefill": {
"command": "npx",
"args": ["-y", "bitrefill-mcp-server"],
"env": {
"BITREFILL_API_KEY": "your_api_key_here"
}
}
}
}码头工人例如。 -e BITREFILL_API_KEY=... 或 --env-file .env.
托管远程MCP (不安装,推荐):
{
"mcpServers": {
"bitrefill": {
"url": "https://api.bitrefill.com/mcp"
}
}
}文档
- 比特币充值文档 (llms指数)
- Bitrefill电子商务MCP(托管):官方远程服务器,建议用于生产
- 安装指南:ChatGPT、克劳德、光标
许可证
麻省理工学院
