mcpField
M
MCP Billing Gateway

MCP Billing Gateway

リモート
github.com/sapph1re金融データ210 週間前に更新
リポジトリ

MCP Billing Gateway について

MCP Billing Gatewayは、MCPサーバーを有料化したい運営者向けのホスト型課金プロキシです。呼び出し元と上流サーバーの間で決済確認、利用状況の記録、料金プランの適用を行います。

主な機能

  1. 01ツール呼び出しごとの課金
  2. 02Stripeサブスクリプションと段階制料金
  3. 03x402によるUSDCマイクロペイメント
  4. 04運営者向け収益・利用状況ダッシュボード
  5. 05課金を適用するプロキシ転送

活用シーン

  1. 01MCPサーバーに従量課金を設定
  2. 02開発者向けの月額・年額プランを提供
  3. 03AIエージェントがBase上のUSDCで支払い

MCP 対応

ローカルMCPサーバーは、機能を確認する`get_billing_info`ツールを提供します。ホスト型ゲートウェイはStreamable HTTPでMCPサーバーをプロキシし、呼び出しに課金を適用します。

設定

リモートサーバーはインストール不要です。クライアントを選んで設定をコピーするか、ワンクリックで導入できます。

エンドポイントhttps://mcp-billing-gateway-production.up.railway.app/mcp/
インストールコマンドをコピー
Claude CodeTerminal
Cursor.cursor/mcp.json
VS Code.vscode/mcp.json
Claude Desktopclaude_desktop_config.json
Windsurf~/.codeium/windsurf/mcp_config.json

コマンドはターミナルで実行し、JSON は各クライアントの MCP 設定に貼り付けて再起動します。認可が必要なサーバーは初回接続時にログインを求めます。

パッケージ
pypimcp-billing-gateway0.1.2

ツール

12
パラメーター型必須説明
namestringはいオペレーターまたは会社名
emailstringはいオペレーターのメールアドレス

詳細

MCP Billing Gateway

Glama MCP Server MCP.Directory

Stripe サブスクリプション、呼び出しごとのクレジット、x402 暗号資産決済を、課金コードを書くことなく、あらゆる MCP サーバーに追加できます。

MCP Billing Gateway は、AI エージェントと MCP サーバーの間に配置されるホスト型の課金プロキシです。決済の検証、使用状況の追跡、プランごとの利用制限を自動で処理します。サーバーを登録して料金プランを設定し、呼び出し元にプロキシ URL を案内するだけです。課金コードを書く必要はありません。

稼働中のサービス:https://mcp-billing-gateway-production.up.railway.app

チュートリアル:あらゆる MCP サーバーを 10 分で収益化 — 動作するコードを使った手順ごとのデモ

インストール

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 サーバーを有効にします。

ツール

ツール説明
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 マイクロペイメント — API キーなしで AI エージェントから 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": "[email protected]", "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": "[email protected]", "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/registerPOST運営者アカウントを作成します
/api/v1/operator/profileGETプロフィールと API キーを表示します
/api/v1/operator/statsGET収益と使用状況の統計を表示します
サーバー管理
エンドポイントメソッド説明
/api/v1/serversPOSTMCP サーバーを登録します
/api/v1/serversGET登録済みサーバーの一覧を表示します
/api/v1/servers/{id}/plansPOST料金プランを作成します
プロキシ
エンドポイントメソッド説明
/proxy/{slug}/*ANY課金処理を適用したプロキシ経由の呼び出し
/mcp/ANYストリーミング可能な 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

コメント

MCP は初めてですか?

プロトコルの概要から最初のサーバーの導入まで、よくある疑問にまとめて答えます。

AI アプリケーションが外部のツールやデータソースに統一的な方法で接続するためのオープンなプロトコルです。クライアントはモデルとの対話を担い、MCP サーバーはツール・リソース・プロンプトテンプレートを提供します。標準メッセージでやり取りするため、1 つのサーバーを複数のクライアントで再利用できます。