MCP Billing Gateway について
MCP Billing Gatewayは、MCPサーバーを有料化したい運営者向けのホスト型課金プロキシです。呼び出し元と上流サーバーの間で決済確認、利用状況の記録、料金プランの適用を行います。
主な機能
- 01ツール呼び出しごとの課金
- 02Stripeサブスクリプションと段階制料金
- 03x402によるUSDCマイクロペイメント
- 04運営者向け収益・利用状況ダッシュボード
- 05課金を適用するプロキシ転送
活用シーン
- 01MCPサーバーに従量課金を設定
- 02開発者向けの月額・年額プランを提供
- 03AIエージェントがBase上のUSDCで支払い
MCP 対応
ローカルMCPサーバーは、機能を確認する`get_billing_info`ツールを提供します。ホスト型ゲートウェイはStreamable HTTPでMCPサーバーをプロキシし、呼び出しに課金を適用します。
設定
リモートサーバーはインストール不要です。クライアントを選んで設定をコピーするか、ワンクリックで導入できます。
https://mcp-billing-gateway-production.up.railway.app/mcp/claude mcp add --transport http sapph1re-mcp-billing-gateway https://mcp-billing-gateway-production.up.railway.app/mcp/{"mcpServers":{"sapph1re-mcp-billing-gateway":{"type":"http","url":"https://mcp-billing-gateway-production.up.railway.app/mcp/"}}}Cursor で開く{"servers":{"sapph1re-mcp-billing-gateway":{"type":"http","url":"https://mcp-billing-gateway-production.up.railway.app/mcp/"}}}VS Code で開く{"mcpServers":{"sapph1re-mcp-billing-gateway":{"type":"http","url":"https://mcp-billing-gateway-production.up.railway.app/mcp/"}}}{"mcpServers":{"sapph1re-mcp-billing-gateway":{"serverUrl":"https://mcp-billing-gateway-production.up.railway.app/mcp/"}}}コマンドはターミナルで実行し、JSON は各クライアントの MCP 設定に貼り付けて再起動します。認可が必要なサーバーは初回接続時にログインを求めます。
ツール
12| パラメーター | 型 | 必須 | 説明 |
|---|---|---|---|
| name | string | はい | オペレーターまたは会社名 |
| string | はい | オペレーターのメールアドレス |
詳細
MCP Billing Gateway
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)
- 運営者として登録し、API キーを取得します
- MCP サーバーの URL と料金プランを登録します
- 呼び出し元にプロキシのスラッグを案内します:
https://mcp-billing-gateway-production.up.railway.app/proxy/{your-slug}/mcp - 呼び出し元は 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/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 | ストリーミング可能な 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
ライセンス
コメント
AI アプリケーションが外部のツールやデータソースに統一的な方法で接続するためのオープンなプロトコルです。クライアントはモデルとの対話を担い、MCP サーバーはツール・リソース・プロンプトテンプレートを提供します。標準メッセージでやり取りするため、1 つのサーバーを複数のクライアントで再利用できます。