电商MCP服务器

Bitrefill MCP服务器是一个参考实现,允许用户通过API购买礼品卡和eSIM,适用于AI助手集成和自定义开发。

  • by bitrefill
  • TypeScript
  • 本地部署
  • 2 星标
  • 更新于
在 GitHub 查看 bitrefill/bitrefill-mcp-server

使用说明

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”用例,更喜欢上面的托管服务器。

配置

  1. 创建API密钥: 比特币充值账户→ 开发者.
  2. 设置在环境中(或 .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-invoice
  • bitrefill://category-slugs:B2B category 产品列表/搜索的查询值
  • 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"
    }
  }
}

文档

许可证

麻省理工学院