Skip to main content
Glama
sapph1re

MCP Billing Gateway SDK

by sapph1re

MCP 计费网关

Glama MCP Server

为任何 MCP 服务器添加 Stripe 订阅按调用计费x402 加密货币支付 功能 —— 无需编写任何计费代码。

MCP 计费网关是一个托管的计费代理,位于 AI 代理和您的 MCP 服务器之间。它会自动处理支付验证、使用量跟踪和层级强制执行。您只需注册服务器、设置定价计划,并将调用者指向代理 URL 即可。无需编写计费代码。

实时服务:https://mcp-billing-gateway-production.up.railway.app

安装

pip install mcp-billing-gateway

或者使用 uvx:

uvx mcp-billing-gateway

Claude Desktop 配置

添加到 ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) 或 %APPDATA%\Claude\claude_desktop_config.json (Windows):

{
  "mcpServers": {
    "mcp-billing-gateway": {
      "command": "uvx",
      "args": ["mcp-billing-gateway"]
    }
  }
}

Cursor 配置

添加到项目中的 .cursor/mcp.json

{
  "mcpServers": {
    "mcp-billing-gateway": {
      "command": "uvx",
      "args": ["mcp-billing-gateway"]
    }
  }
}

添加配置后重启编辑器以激活 MCP 服务器。

Related MCP server: Agent Bazaar

工具

工具

描述

get_billing_info

返回服务能力、支持的支付方式、功能和集成文档

本地 MCP 服务器提供服务发现功能。完整的计费功能在托管网关上运行 —— 请注册为运营商并通过它代理您的 MCP 服务器。

工作原理

AI Agent → MCP Billing Gateway → Your MCP Server
            (billing enforced here)
  1. 注册为运营商并获取 API 密钥

  2. 注册您的 MCP 服务器 URL 和定价计划

  3. 将调用者指向您的代理别名:https://mcp-billing-gateway-production.up.railway.app/proxy/{your-slug}/mcp

  4. 调用者通过 Stripe API 密钥或 x402 USDC 支付 —— 计费过程透明处理

功能

  • 按调用计费 —— 按工具调用次数向调用者收费(法币或加密货币)

  • 订阅 —— 带有调用限制的月度/年度 Stripe 计划

  • 分级定价 —— 免费层级 + 基于使用量的付费层级

  • x402 微支付 —— AI 代理无需 API 密钥即可在 Base 链上使用 USDC 支付

  • 运营商仪表板 —— 实时跟踪收入、使用量和调用者

  • MCP 传输 —— /mcp/ 端点提供完整的 Streamable HTTP MCP 传输

快速入门

1. 注册为运营商

curl -X POST https://mcp-billing-gateway-production.up.railway.app/api/v1/operator/register \
  -H "Content-Type: application/json" \
  -d '{"email": "you@example.com", "name": "Your Name"}'

响应:

{
  "operator_id": "op_abc123",
  "api_key": "bg_live_xxxxxxxxxxxx",
  "message": "Operator registered successfully"
}

2. 注册您的 MCP 服务器

curl -X POST https://mcp-billing-gateway-production.up.railway.app/api/v1/servers \
  -H "Authorization: Bearer bg_live_xxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My MCP Server",
    "upstream_url": "https://your-mcp-server.com/mcp",
    "proxy_slug": "my-server"
  }'

3. 创建定价计划

curl -X POST https://mcp-billing-gateway-production.up.railway.app/api/v1/servers/{server_id}/plans \
  -H "Authorization: Bearer bg_live_xxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Pay as you go",
    "billing_model": "per_call",
    "price_per_call_usd_micro": 10000,
    "free_calls_per_month": 100
  }'

4. 将调用者连接到您的代理服务器

{
  "mcpServers": {
    "my-server": {
      "url": "https://mcp-billing-gateway-production.up.railway.app/proxy/my-server/mcp",
      "headers": {
        "Authorization": "Bearer CALLER_API_KEY"
      }
    }
  }
}

支付方式

方式

适用对象

如何操作

Stripe 订阅

人类开发者

通过 Stripe Checkout 进行月度或年度计划

Stripe 按调用计费

人类开发者

每次工具调用消耗积分

x402 微支付

AI 代理

Base 链上的 USDC,无需 API 密钥

示例

检查网关能力

# Using the MCP client
result = await session.call_tool("get_billing_info")
print(result)
# {
#   "service": "MCP Billing Gateway",
#   "version": "0.1.0",
#   "payment_methods": ["stripe_subscription", "stripe_metered", "x402_crypto"],
#   "features": ["Per-call usage tracking", "Tiered pricing", ...],
#   "live_service": "https://mcp-billing-gateway-production.up.railway.app"
# }

注册并变现现有的 MCP 服务器

# 1. Register
API_KEY=$(curl -s -X POST .../api/v1/operator/register \
  -H "Content-Type: application/json" \
  -d '{"email": "dev@example.com", "name": "Dev"}' | jq -r .api_key)

# 2. Add your server
SERVER_ID=$(curl -s -X POST .../api/v1/servers \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "my-tool", "upstream_url": "https://my-tool.com/mcp", "proxy_slug": "my-tool"}' \
  | jq -r .server_id)

# 3. Set pricing: $0.01 per call, 100 free calls/month
curl -X POST .../api/v1/servers/$SERVER_ID/plans \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "Starter", "billing_model": "per_call", "price_per_call_usd_micro": 10000, "free_calls_per_month": 100}'

# Callers now connect via: .../proxy/my-tool/mcp

运营商仪表板

访问您的仪表板:

https://mcp-billing-gateway-production.up.railway.app/dashboard

实时跟踪收入、使用量、活跃调用者并配置您的服务器。

API 参考

运营商端点

端点

方法

描述

/api/v1/operator/register

POST

创建运营商账户

/api/v1/operator/profile

GET

查看个人资料和 API 密钥

/api/v1/operator/stats

GET

收入和使用统计信息

服务器管理

端点

方法

描述

/api/v1/servers

POST

注册 MCP 服务器

/api/v1/servers

GET

列出您的服务器

/api/v1/servers/{id}/plans

POST

创建定价计划

代理

端点

方法

描述

/proxy/{slug}/*

ANY

带有计费强制执行的代理调用

/mcp/

ANY

Streamable HTTP MCP 传输

架构

┌─────────────┐     ┌──────────────────────┐     ┌──────────────────┐
│  AI Agent /  │────▶│  MCP Billing Gateway │────▶│  Your MCP Server │
│  MCP Client  │◀────│  (hosted on Railway)  │◀────│  (upstream)      │
└─────────────┘     └──────────────────────┘     └──────────────────┘
                         │
                         ├── Payment verification (Stripe / x402)
                         ├── Usage tracking & rate limiting
                         ├── Tier enforcement
                         └── Operator dashboard

网关是一个透明代理。调用者正常与您的 MCP 服务器交互 —— 网关拦截请求、验证支付、跟踪使用量并转发到您的上游服务器。

自托管

网关可在上述托管 URL 上使用。如需自托管部署,请克隆服务器仓库并通过 Docker 部署:

docker build -t mcp-billing-gateway .
docker run -p 3000:3000 mcp-billing-gateway

许可证

MIT

Install Server
A
license - permissive license
B
quality
D
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    A comprehensive framework for building and deploying commercial MCP servers with integrated billing, usage metering, and Stripe payment processing. It enables developers to monetize AI tools through a complete ecosystem including API key management, affiliate tracking, and automated deployment scripts.
  • A
    license
    Not graded
    quality
    C
    maintenance
    Per-call billing and metering proxy for MCP tool servers. Providers set pricing via the open MCP Billing Spec (MIT), consumers pay through Stripe Connect with signed receipts and SLA monitoring.
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Template for creating MCP servers with a server-side paywall gate, enabling free local usage and premium hosted tier with Stripe and x402 payment lanes.
    MIT

View all related MCP servers

Related MCP Connectors

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sapph1re/mcp-billing-gateway-sdk'

If you have feedback or need assistance with the MCP directory API, please join our Discord server