{
  "markdown": "<!-- mcp-name: io.github.sapph1re/mcp-billing-gateway -->\n# MCP Billing Gateway\n\n[![Glama MCP Server](https://glama.ai/mcp/servers/sapph1re/mcp-billing-gateway-sdk/badge)](https://glama.ai/mcp/servers/sapph1re/mcp-billing-gateway-sdk)\n[![MCP.Directory](https://img.shields.io/badge/MCP.Directory-listed-blue)](https://mcp.directory/servers?q=mcp-billing-gateway)\n\nAdd **Stripe subscriptions**, **per-call credits**, and **x402 crypto payments** to any MCP server — without writing billing code.\n\nMCP Billing Gateway is a hosted billing proxy that sits between AI agents and your MCP server. It handles payment verification, usage tracking, and tier enforcement automatically. You register your server, set a pricing plan, and point callers to the proxied URL. No billing code required.\n\nLive service: **https://mcp-billing-gateway-production.up.railway.app**\n\n**Tutorial:** [Monetize any MCP server in 10 minutes](https://github.com/sapph1re/mcp-billing-demo) — step-by-step demo with working code\n\n## Installation\n\n```bash\npip install mcp-billing-gateway\n```\n\nOr with [uvx](https://docs.astral.sh/uv/):\n\n```bash\nuvx mcp-billing-gateway\n```\n\n### Configuration for Claude Desktop\n\nAdd to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\\Claude\\claude_desktop_config.json` (Windows):\n\n```json\n{\n  \"mcpServers\": {\n    \"mcp-billing-gateway\": {\n      \"command\": \"uvx\",\n      \"args\": [\"mcp-billing-gateway\"]\n    }\n  }\n}\n```\n\n### Configuration for Cursor\n\nAdd to `.cursor/mcp.json` in your project:\n\n```json\n{\n  \"mcpServers\": {\n    \"mcp-billing-gateway\": {\n      \"command\": \"uvx\",\n      \"args\": [\"mcp-billing-gateway\"]\n    }\n  }\n}\n```\n\nRestart your editor after adding the configuration to activate the MCP server.\n\n## Tools\n\n| Tool | Description |\n|------|-------------|\n| `get_billing_info` | Returns service capabilities, supported payment methods, features, and integration docs |\n\nThe local MCP server provides service discovery. The full billing functionality runs on the hosted gateway — register as an operator and proxy your MCP servers through it.\n\n## How it works\n\n```\nAI Agent → MCP Billing Gateway → Your MCP Server\n            (billing enforced here)\n```\n\n1. Register as an operator and get an API key\n2. Register your MCP server URL + pricing plan\n3. Point callers to your proxy slug: `https://mcp-billing-gateway-production.up.railway.app/proxy/{your-slug}/mcp`\n4. Callers pay via Stripe API key or x402 USDC — billing is handled transparently\n\n## Features\n\n- **Per-call billing** — charge callers per tool call (fiat or crypto)\n- **Subscriptions** — monthly/annual Stripe plans with call limits\n- **Tiered pricing** — free tier + paid tiers based on usage\n- **x402 micropayments** — accept USDC on Base from AI agents with no API keys\n- **Operator dashboard** — track revenue, usage, and callers in real time\n- **MCP transport** — full Streamable HTTP MCP transport at `/mcp/` endpoint\n\n## Quick Start\n\n### 1. Register as operator\n\n```bash\ncurl -X POST https://mcp-billing-gateway-production.up.railway.app/api/v1/operator/register \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"email\": \"you@example.com\", \"name\": \"Your Name\"}'\n```\n\nResponse:\n\n```json\n{\n  \"operator_id\": \"op_abc123\",\n  \"api_key\": \"bg_live_xxxxxxxxxxxx\",\n  \"message\": \"Operator registered successfully\"\n}\n```\n\n### 2. Register your MCP server\n\n```bash\ncurl -X POST https://mcp-billing-gateway-production.up.railway.app/api/v1/servers \\\n  -H \"Authorization: Bearer bg_live_xxxxxxxxxxxx\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"name\": \"My MCP Server\",\n    \"upstream_url\": \"https://your-mcp-server.com/mcp\",\n    \"proxy_slug\": \"my-server\"\n  }'\n```\n\n### 3. Create a pricing plan\n\n```bash\ncurl -X POST https://mcp-billing-gateway-production.up.railway.app/api/v1/servers/{server_id}/plans \\\n  -H \"Authorization: Bearer bg_live_xxxxxxxxxxxx\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"name\": \"Pay as you go\",\n    \"billing_model\": \"per_call\",\n    \"price_per_call_usd_micro\": 10000,\n    \"free_calls_per_month\": 100\n  }'\n```\n\n### 4. Connect callers to your proxied server\n\n```json\n{\n  \"mcpServers\": {\n    \"my-server\": {\n      \"url\": \"https://mcp-billing-gateway-production.up.railway.app/proxy/my-server/mcp\",\n      \"headers\": {\n        \"Authorization\": \"Bearer CALLER_API_KEY\"\n      }\n    }\n  }\n}\n```\n\n## Payment Methods\n\n| Method | Best for | How |\n|--------|----------|-----|\n| Stripe subscription | Human developers | Monthly or annual plan via Stripe Checkout |\n| Stripe per-call | Human developers | Credits consumed per tool call |\n| x402 micropayments | AI agents | USDC on Base, no API keys needed |\n\n## Examples\n\n### Check gateway capabilities\n\n```python\n# Using the MCP client\nresult = await session.call_tool(\"get_billing_info\")\nprint(result)\n# {\n#   \"service\": \"MCP Billing Gateway\",\n#   \"version\": \"0.1.0\",\n#   \"payment_methods\": [\"stripe_subscription\", \"stripe_metered\", \"x402_crypto\"],\n#   \"features\": [\"Per-call usage tracking\", \"Tiered pricing\", ...],\n#   \"live_service\": \"https://mcp-billing-gateway-production.up.railway.app\"\n# }\n```\n\n### Register and monetize an existing MCP server\n\n```bash\n# 1. Register\nAPI_KEY=$(curl -s -X POST .../api/v1/operator/register \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"email\": \"dev@example.com\", \"name\": \"Dev\"}' | jq -r .api_key)\n\n# 2. Add your server\nSERVER_ID=$(curl -s -X POST .../api/v1/servers \\\n  -H \"Authorization: Bearer $API_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\": \"my-tool\", \"upstream_url\": \"https://my-tool.com/mcp\", \"proxy_slug\": \"my-tool\"}' \\\n  | jq -r .server_id)\n\n# 3. Set pricing: $0.01 per call, 100 free calls/month\ncurl -X POST .../api/v1/servers/$SERVER_ID/plans \\\n  -H \"Authorization: Bearer $API_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\": \"Starter\", \"billing_model\": \"per_call\", \"price_per_call_usd_micro\": 10000, \"free_calls_per_month\": 100}'\n\n# Callers now connect via: .../proxy/my-tool/mcp\n```\n\n## Operator Dashboard\n\nAccess your dashboard at:\n\n```\nhttps://mcp-billing-gateway-production.up.railway.app/dashboard\n```\n\nTrack revenue, usage, active callers, and configure your servers in real time.\n\n## API Reference\n\n### Operator endpoints\n\n| Endpoint | Method | Description |\n|----------|--------|-------------|\n| `/api/v1/operator/register` | POST | Create operator account |\n| `/api/v1/operator/profile` | GET | View profile and API keys |\n| `/api/v1/operator/stats` | GET | Revenue and usage stats |\n\n### Server management\n\n| Endpoint | Method | Description |\n|----------|--------|-------------|\n| `/api/v1/servers` | POST | Register an MCP server |\n| `/api/v1/servers` | GET | List your servers |\n| `/api/v1/servers/{id}/plans` | POST | Create pricing plan |\n\n### Proxy\n\n| Endpoint | Method | Description |\n|----------|--------|-------------|\n| `/proxy/{slug}/*` | ANY | Proxied calls with billing enforcement |\n| `/mcp/` | ANY | Streamable HTTP MCP transport |\n\n## Architecture\n\n```\n┌─────────────┐     ┌──────────────────────┐     ┌──────────────────┐\n│  AI Agent /  │────▶│  MCP Billing Gateway │────▶│  Your MCP Server │\n│  MCP Client  │◀────│  (hosted on Railway)  │◀────│  (upstream)      │\n└─────────────┘     └──────────────────────┘     └──────────────────┘\n                         │\n                         ├── Payment verification (Stripe / x402)\n                         ├── Usage tracking & rate limiting\n                         ├── Tier enforcement\n                         └── Operator dashboard\n```\n\nThe gateway is a transparent proxy. Callers interact with your MCP server normally — the gateway intercepts requests, verifies payment, tracks usage, and forwards to your upstream server.\n\n## Self-hosted\n\nThe gateway is open for use at the hosted URL above. For self-hosted deployments, clone the server repository and deploy via Docker:\n\n```bash\ndocker build -t mcp-billing-gateway .\ndocker run -p 3000:3000 mcp-billing-gateway\n```\n\n## License\n\n[MIT](LICENSE)\n\n<!-- mcp-name: io.github.sapph1re/mcp-billing-gateway -->\n",
  "bytes": 8007,
  "sha": "59a3b1f7016a846fc7591e00a62e26ebef5786991a9d545af8d0523496f6ab59",
  "repo_slug": "sapph1re/mcp-billing-gateway-sdk",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_sapph1re_mcp_billing_gateway_3e89defe/readme"
}