MCP Server for AI Agents
Give your AI agent full control over payment gates, content, analytics, and a built-in Solana wallet with spending safety rails. One package, 23 tools.
Quick Start
Claude Code
claude mcp add gates-x402 -s user -- npx @gates-x402/mcp-server --stdioThen add a .mcp.json to your project root with your API key:
{
"mcpServers": {
"gates-x402": {
"command": "npx",
"args": ["@gates-x402/mcp-server", "--stdio"],
"env": {
"GATES_API_KEY": "pg_test_xxx",
"SOLANA_NETWORK": "mainnet-beta"
}
}
}
}Cursor
{
"mcpServers": {
"gates-x402": {
"command": "npx",
"args": ["@gates-x402/mcp-server", "--stdio"],
"env": {
"GATES_API_KEY": "pg_test_xxx",
"SOLANA_NETWORK": "mainnet-beta"
}
}
}
}OpenAI Agents SDK
from agents import Agent
from agents.mcp import MCPServerStdio
mcp = MCPServerStdio(
name="gates-x402",
command="npx",
args=["@gates-x402/mcp-server", "--stdio"],
env={
"GATES_API_KEY": "pg_test_xxx",
"SOLANA_NETWORK": "mainnet-beta",
},
)
agent = Agent(
name="Payments Agent",
instructions="You manage payment gates on Gates x402.",
mcp_servers=[mcp],
)Programmatic (Node.js)
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
const transport = new StdioClientTransport({
command: "npx",
args: ["@gates-x402/mcp-server", "--stdio"],
env: {
GATES_API_KEY: "pg_test_xxx",
SOLANA_NETWORK: "devnet",
},
});
const client = new Client({ name: "my-app", version: "1.0.0" });
await client.connect(transport);
const { tools } = await client.listTools();
const result = await client.callTool({ name: "list_paygates", arguments: {} });Environment Variables
Required
| Variable | Description |
|---|---|
| GATES_API_KEY | Your API key (pg_test_* for devnet, pg_live_* for mainnet) |
Optional
| Variable | Default | Description |
|---|---|---|
| GATES_API_URL | localhost:4021 | Gates x402 API server URL |
| WALLET_KEYPAIR_PATH | ~/.gates-x402/wallet.json | Path to Solana keypair JSON file |
| WALLET_PRIVATE_KEY | — | Base58-encoded private key (alternative to file) |
| SOLANA_RPC_URL | Solana public RPC | Solana RPC endpoint (Helius, QuickNode, etc.) |
| SOLANA_NETWORK | mainnet-beta | mainnet-beta or devnet |
Safety Rails
| Variable | Default | Description |
|---|---|---|
| WALLET_MAX_SOL_PER_TX | 1.0 | Maximum SOL per single transaction |
| WALLET_MAX_USDC_PER_TX | 10.0 | Maximum USDC per single transaction |
| WALLET_DAILY_USDC_LIMIT | 50.0 | Maximum USDC the agent can spend per day |
| WALLET_ALLOWLIST | — | Comma-separated allowed recipient addresses |
Built-in Wallet
The MCP server includes a built-in Solana wallet so your AI agent can hold and transfer SOL and USDC.
Auto-generated on first run
A new Solana keypair is automatically generated and saved to ~/.gates-x402/wallet.json on first start. The same wallet is loaded on every subsequent run.
Persistent across sessions
The wallet is stored on disk — it persists across conversations, server restarts, and reboots. Multiple agent sessions share the same wallet.
Safety rails
- Per-transaction cap — Blocks transfers above the configured maximum (default: 1 SOL / $10 USDC)
- Daily spending limit — Tracks cumulative USDC spent per day (default: $50/day)
- Address allowlist — Restrict transfers to specific addresses only
- Mainnet warnings — Large transfers on mainnet produce warnings
- Devnet airdrop only — Airdrop tool is disabled on mainnet
Tools (23)
Paygate Management
| Tool | Description |
|---|---|
| list_paygates | List all payment gates with status, pricing, and transaction counts |
| create_paygate | Create a new paygate with name, price, resource URL, optional description and webhook |
| update_paygate | Update an existing paygate (pass only the fields to change) |
| delete_paygate | Permanently delete a paygate |
Content
| Tool | Description |
|---|---|
| list_content | List hosted files for a paygate with sizes and preview URLs |
| get_storage_usage | Storage quota, used space, and file count |
| upload_content_file | Upload a file from the local filesystem to a paygate |
| upload_content_text | Create and upload text-based content inline (markdown, code, JSON, etc.) |
Analytics & Billing
| Tool | Description |
|---|---|
| get_analytics | Revenue data with optional date range and paygate filters |
| get_billing_summary | Revenue, platform fees, net earnings, and monthly breakdown |
| list_transactions | Paginated transaction history |
| get_subscription | Current tier, usage limits, and expiration date |
| get_webhook_stats | Webhook delivery statistics (success/failure counts) |
API Keys & Profile
| Tool | Description |
|---|---|
| list_api_keys | List keys (prefix and last-used only — full keys are never exposed) |
| create_api_key | Create a test or live API key (shown once on creation) |
| get_profile | Creator profile: username, bio, wallet address, social links |
Wallet
| Tool | Description |
|---|---|
| wallet_create | Generate a new keypair, replacing the current wallet (requires confirm: true) |
| wallet_get_address | Get the wallet public key and keypair file location |
| wallet_get_balance | SOL and USDC balances |
| wallet_transfer_sol | Send SOL (subject to per-tx limit) |
| wallet_transfer_usdc | Send USDC (subject to per-tx and daily limits) |
| wallet_airdrop | Request devnet SOL airdrop (max 2 SOL, devnet only) |
| wallet_spending_status | View spending limits, daily usage, and safety rail config |
Resources
MCP resources provide live data that agents can read without calling a tool:
| Resource | URI | Description |
|---|---|---|
| Paygates | gates-x402://paygates | Live list of all payment gates |
| Subscription | gates-x402://subscription | Current subscription status and usage |
Example Prompts
Once connected, you can ask your AI agent things like:
Get Started
Install with a single command:
npx @gates-x402/mcp-server --stdioNeed an API key? Create an account, subscribe to a plan and generate one in Settings.