gatepay-local-mcp
Provides tools for handling X402 payments on Ethereum and other EVM networks, enabling AI agents to place orders, create signatures, and submit payments for protected endpoints.
Enables authentication via Google accounts using device-flow OAuth for the Quick Wallet signing mode in X402 payment workflows.
Provides tools for handling X402 payments on Polygon and other EVM networks, enabling AI agents to place orders, create signatures, and submit payments for protected endpoints.
Provides tools for handling X402 payments on Solana networks, enabling AI agents to place orders, create signatures, and submit payments for protected endpoints.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@gatepay-local-mcp Pay and fetch data from https://api.example.com/data"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
gatepay-local-mcp
gatepay-local-mcp is a local stdio MCP server for calling X402 payment-protected HTTP endpoints. It provides a suite of MCP tools to handle the complete X402 payment workflow, from placing orders to signing payments and submitting them to merchants.
Features
7 MCP Tools covering order placement, signature flows, quick wallet / Gate Pay auth, and centralized payment retries
Built-in X402 payment flow under
src/x402/Multiple signing modes:
local_private_key,quick_wallet,plugin_walletMulti-chain support: EVM (Ethereum, Base, Polygon, etc.) and Solana
Works with Cursor, Claude Desktop, and other MCP clients
Auto-selects the first ready signing mode if not specified
Gate Pay centralized payment (
sign_mode: centralized_payment) andx402_centralized_paymenthelper for merchant-side settlement
Related MCP server: x402-mcp
Available Tools
1. x402_place_order
Send an HTTP request and return complete response information including headers, body, and the original request details.
Use case: Initial request to a payment-protected endpoint that returns 402 Payment Required.
Parameters:
{
url: string; // Target URL (required)
method?: string; // HTTP method: GET, POST, PUT, PATCH (default: POST)
body?: string; // JSON string request body (optional)
sign_mode?: string; // Signing mode: local_private_key, quick_wallet, plugin_wallet (auto-select if omitted)
wallet_login_provider?: string; // OAuth provider: google, gate (default: gate)
}Returns: Complete response with status code, headers (including PAYMENT-REQUIRED), body, and original request details.
2. x402_sign_payment
Parse X402 payment requirements, create a signed payment authorization, and submit the payment to complete a 402-protected request (all-in-one workflow).
Use case: Single-step payment flow - parse, sign, and submit in one call.
Parameters:
{
url: string; // Target URL (required)
method?: string; // HTTP method (default: POST)
body?: string; // JSON request body (optional)
payment_required_header?: string; // Base64-encoded PAYMENT-REQUIRED header
response_body?: string; // Response body from 402 response (alternative to header)
sign_mode?: string; // Signing mode (auto-select if omitted)
wallet_login_provider?: string; // OAuth provider (default: gate)
}Returns: Final response from the merchant after successful payment.
3. x402_create_signature
Parse X402 payment requirements and create a signed payment authorization.
Use case: Two-step workflow - create signature first, then submit separately.
Parameters:
{
payment_required_header?: string; // Base64-encoded PAYMENT-REQUIRED header
response_body?: string; // Response body from 402 response (alternative to header)
sign_mode?: string; // Signing mode (auto-select if omitted)
wallet_login_provider?: string; // OAuth provider (default: gate)
}Returns: Payment payload and base64-encoded PAYMENT-SIGNATURE header value.
4. x402_submit_payment
Submit a signed payment to complete a 402-protected request.
Use case: Second step of two-step workflow - submit the signature created by x402_create_signature.
Parameters:
{
url: string; // Target URL (required)
method?: string; // HTTP method (default: POST)
body?: string; // JSON request body (optional)
payment_signature: string; // Base64-encoded PAYMENT-SIGNATURE from x402_create_signature (required)
}Returns: Final response from the merchant.
5. x402_quick_wallet_auth
Pre-authorize with Quick Wallet using device-flow OAuth (Google or Gate account).
Use case: When using sign_mode: quick_wallet, run this first to complete the device-flow login before making payment requests.
Parameters:
{
wallet_login_provider?: string; // OAuth provider: google, gate (default: gate)
}Returns: Authorization status and wallet addresses (EVM and Solana).
6. x402_gate_pay_auth
Complete the Gate Pay OAuth device flow (browser authorize URL + localhost callback + remote token exchange) and cache the resulting access token/UID for centralized payments.
Use case: Required before calling x402_submit_payment with sign_mode: centralized_payment or when preparing to use x402_centralized_payment.
Parameters: None
Returns: Current authorization status with masked Gate Pay UID and access token indicators.
7. x402_centralized_payment
Parse the Base64-encoded PAYMENT-REQUIRED header and complete the Gate Pay centralized payment flow without submitting a PAYMENT-SIGNATURE.
Use case: When a merchant expects Gate Pay centralized settlement (e.g., OTA or off-chain marketplace) and you prefer an all-in-one helper instead of crafting PAYMENT-SIGNATURE.
Parameters:
{
payment_required_header: string; // Base64-encoded PAYMENT-REQUIRED header (required)
}Returns: Payment confirmation including prepayId, merchantTradeNo, currency, amount, and the raw API response.
Workflow Examples
Single-Step Workflow (Recommended)
1. x402_place_order → Get payment requirements
2. x402_sign_payment → Sign and submit payment (all-in-one)Two-Step Workflow (Advanced)
1. x402_place_order → Get payment requirements
2. x402_create_signature → Create signed payment
3. x402_submit_payment → Submit signed paymentQuick Wallet Pre-Auth
1. x402_quick_wallet_auth → Authorize with Google/Gate
2. x402_place_order → Get payment requirements
3. x402_sign_payment → Sign and submit (using quick_wallet)Centralized Payment (Gate Pay)
1. x402_gate_pay_auth → Browser OAuth + token exchange (repeat when token expires)
2. x402_place_order → Receive PAYMENT-REQUIRED header that encodes Gate Pay order info
3. x402_submit_payment → Use payment_signature + sign_mode: "centralized_payment" to call the merchant with Authorization: Bearer
或
3. x402_centralized_payment → Pass payment_required_header directly for all-in-one centralized settlementSigning Modes
The server supports three automatic signing modes plus a dedicated Gate Pay centralized mode:
| Status | Networks / Scope | Description |
| Ready when | EVM, Solana | Signs locally with your private keys (no external dependencies) |
| Ready after OAuth login | EVM, Solana | Custodial MCP wallet with device-flow login (Google/Gate account) |
| Ready when | EVM, Solana | Browser extension wallet (e.g., Gate Wallet) via MCP bridge |
| Ready after | Gate Pay | Adds |
Priority Order (auto-selection applies to the first three rows when sign_mode is omitted):
plugin_wallet(priority: 30) - if token configuredquick_wallet(priority: 20) - if MCP endpoint configuredlocal_private_key(priority: 10) - if private keys configured
The server automatically selects the highest-priority ready mode.
Network Support
EVM Networks: Ethereum, Base, Polygon, Arbitrum One, GateChain, GateLayer
Solana Networks: Solana Mainnet, Solana Devnet
Quick Start
1. Local Private Key Mode (EVM + Solana)
This is the simplest setup for local signing with your own private keys:
{
"mcpServers": {
"gatepay-mcp": {
"command": "npx",
"args": ["-y", "gatepay-local-mcp"],
"env": {
"EVM_PRIVATE_KEY": "your-evm-private-key-hex-with-or-without-0x-prefix",
"SVM_PRIVATE_KEY": "your-solana-private-key-base58-optional"
}
}
}
}Set
EVM_PRIVATE_KEYfor EVM network payments (Ethereum, Base, Polygon, etc.)Set
SVM_PRIVATE_KEYfor Solana network payments (optional)Put this into your MCP config such as
~/.cursor/mcp.json, then restart or reload MCP
2. Quick Wallet Mode (Custodial)
Remote wallet signing with device-flow OAuth (Google or Gate account):
{
"mcpServers": {
"gatepay-mcp": {
"command": "npx",
"args": ["-y", "gatepay-local-mcp"],
"env": {
"QUICK_WALLET_MCP_URL": "https://walletmcp.gate.com/mcp",
"QUICK_WALLET_API_KEY": "your-api-key-optional"
}
}
}
}First payment will trigger device-flow login (opens browser)
Token is persisted at
~/.gate-pay/auth.jsonUse
x402_quick_wallet_authtool to pre-authorize
3. Plugin Wallet Mode (Browser Extension)
Sign with browser extension wallet (e.g., Gate Wallet):
{
"mcpServers": {
"gatepay-mcp": {
"command": "npx",
"args": ["-y", "gatepay-local-mcp"],
"env": {
"PLUGIN_WALLET_TOKEN": "your-plugin-wallet-mcp-token"
}
}
}
}Get the token from your browser extension wallet
Requires the wallet extension to be installed and running
User confirms transactions in the browser extension
4. Gate Pay Centralized Payment (Browser OAuth)
Use this when merchants expect Gate Pay centralized settlement instead of user-owned signatures.
{
"mcpServers": {
"gatepay-mcp": {
"command": "npx",
"args": ["-y", "gatepay-local-mcp"],
"env": {
"GATE_PAY_OAUTH_CLIENT_ID": "your-gate-pay-client-id",
"GATE_PAY_OAUTH_CLIENT_SECRET": "your-gate-pay-client-secret",
"GATE_PAY_OAUTH_BACKEND_ORIGIN": "https://www.gate.com/apiw/v2/mcp/oauth",
"GATE_PAY_ACCOUNT_AUTHORIZE_ORIGIN": "https://gate.com",
"GATE_PAY_OAUTH_CALLBACK_PORT": "18473",
"GATE_PAY_CENTRALIZED_PAYMENT_URL": "https://api.gateio.ws/api/v4/pay/ai/order/pay",
"GATE_PAY_CLIENT_ID": "your-gate-pay-client-id"
}
}
}
}Run
x402_gate_pay_authonce per token lifecycle; it opens the Gate consent page and exchanges the code automatically.Use
x402_submit_paymentwithsign_mode: "centralized_payment"after you create aPAYMENT-SIGNATURE, orCall
x402_centralized_paymentdirectly with the Base64PAYMENT-REQUIREDheader when you prefer a single-step helper.
Cursor / Claude Desktop with plugin wallet
If you want to use a browser extension wallet (like Gate Wallet) for signing, configure the plugin wallet mode:
{
"mcpServers": {
"gatepay-mcp": {
"command": "npx",
"args": ["-y", "gatepay-local-mcp"],
"env": {
"PLUGIN_WALLET_SERVER_URL": "https://your-plugin-wallet-server.com",
"PLUGIN_WALLET_TOKEN": "your-token-from-browser-wallet"
}
}
}
}Before using plugin wallet mode:
Install a compatible browser extension wallet (e.g., Gate Wallet)
Open the wallet extension in your browser and obtain the connection token
Configure
PLUGIN_WALLET_SERVER_URLandPLUGIN_WALLET_TOKENin your MCP configThe wallet extension must be active in your browser when making x402 requests
Environment Variables
The server loads .env from the repository or package root at startup.
Signing Mode Configuration
Variable | Mode | Description |
|
| Local EVM private key; hex with or without |
|
| Local Solana private key; base58 encoded (optional) |
|
| MCP wallet endpoint URL (default: |
|
| API key for MCP wallet service (optional) |
|
| MCP token from browser extension wallet |
Gate Pay Centralized Payment
Variable | Description |
| Gate Pay OAuth client id used for device authorization and token exchange |
| Client secret required when exchanging the authorization code for an access token |
| Base URL for the OAuth backend that hosts the token/refresh endpoints |
| Domain that serves the Gate Pay authorization page (opens in the browser) |
| Local port used to receive the OAuth redirect (set to |
| OAuth scope requested during device/login flow |
| Custom User-Agent for the authorization preflight (defaults to |
| HTTPS endpoint for submitting centralized payments via Gate Pay |
| Merchant client id embedded in centralized payment payloads |
| Optional: origin used to derive default token and refresh endpoints |
| Optional: explicit token endpoint path override |
| Optional: explicit refresh endpoint path override |
Test and Script Variables
Variable | Used By | Default | Description |
|
|
| Base URL for the local private-key flow test |
|
|
| Endpoint path appended to |
|
|
| Timeout for the MCP tool integration test |
Usage Examples
Example 1: Single-Step Payment (Recommended)
// Step 1: Place order to get payment requirements
{
"tool": "x402_place_order",
"arguments": {
"url": "https://api.example.com/order",
"method": "POST",
"body": "{\"flightId\":\"FL001\",\"uid\":\"100\"}"
}
}
// Step 2: If 402 response, sign and submit payment
{
"tool": "x402_sign_payment",
"arguments": {
"url": "https://api.example.com/order",
"method": "POST",
"body": "{\"flightId\":\"FL001\",\"uid\":\"100\"}",
"payment_required_header": "<base64-from-place_order>",
"sign_mode": "quick_wallet"
}
}Example 2: Two-Step Payment (Advanced)
// Create signature first
{
"tool": "x402_create_signature",
"arguments": {
"payment_required_header": "<base64>",
"sign_mode": "local_private_key"
}
}
// Then submit separately
{
"tool": "x402_submit_payment",
"arguments": {
"url": "https://api.example.com/order",
"payment_signature": "<base64-from-create_signature>"
}
}Example 3: Quick Wallet with Pre-Auth
// Pre-authorize (opens browser for OAuth)
{
"tool": "x402_quick_wallet_auth",
"arguments": {
"wallet_login_provider": "gate"
}
}Example 4: Gate Pay Centralized Payment
// Step 1: Run OAuth (opens Gate authorize page)
{ "tool": "x402_gate_pay_auth", "arguments": {} }
// Step 2a: Use centralized helper
{
"tool": "x402_centralized_payment",
"arguments": {
"payment_required_header": "<base64-from-place_order>"
}
}
// Step 2b: Or submit with sign_mode: centralized_payment
{
"tool": "x402_submit_payment",
"arguments": {
"url": "https://api.example.com/order",
"method": "POST",
"payment_signature": "<base64-from-create_signature>",
"sign_mode": "centralized_payment"
}
}Agent Skill
skills/SKILL.mdcontains thegatepay-x402skill manifest and prompts so MCP-aware IDEs (Cursor, Claude Desktop, Codex CLI, etc.) know how to call every tool exposed by this server.skills/gatepay-x402.md(mirrored atdocs/gatepay-x402.md) is a natural-language installation guide. Share that link with your AI host for a “one-click” experience: the host can follow the steps to downloadgatepay-local-mcp, register it inmcpServers, and copy thegatepay-x402skill into its skills directory automatically.
Tool names and arguments always match each tool’s MCP inputSchema on the server you connect to; check your client’s tool list if you ship a trimmed build.
Development
# install dependencies
npm install
# build TypeScript output into dist/
npm run build
# start the MCP server from source
npm run dev
# run the built entrypoint through the package start script
npm start
# run unit tests
npm run test:unit
# run the local private key flow test
npm run test:privateKey
# run the MCP tool integration test
npm run test:mcp-toolIntegration test notes
npm run test:mcp-tool starts dist/src/index.js and calls x402_request against the configured remote wallet flow. The test requires proper wallet credentials to be configured.
npm run build
npm run test:mcp-toolIf you already logged in before, the saved token in ~/.gate-pay/auth.json will be reused. Otherwise the quick wallet flow may require interactive device login. You can increase the timeout with GATEPAY_MCP_TEST_TIMEOUT_MS.
License
MIT
Available Tools
7 toolsx402_centralized_paymentA
Execute centralized payment (中心化支付) by parsing PAYMENT-REQUIRED header, extracting payment information, and calling the Gate Pay centralized payment API. Automatically handles Gate Pay OAuth authentication if needed (same as x402_gate_pay_auth). Parses amount (converts from smallest unit by dividing by 10^6), currency, prepayId, and orderId from the header. Returns payment result including transaction details.
Inputs: payment_required_header (required).
x402_create_signatureA
Parse X402 payment requirements and create a signed payment authorization. Returns the complete payment payload including signature and the base64-encoded PAYMENT-SIGNATURE header value. Supports signing modes: local_private_key, quick_wallet, and plugin_wallet. The output can be used with x402_submit_payment to complete the payment request.
Inputs: sign_mode, response_body, wallet_login_provider, payment_required_header.
x402_gate_pay_authA
When the user chooses centralized_payment (中心化支付), run this tool to complete Gate Pay OAuth: browser opens Gate authorize URL, redirect hits localhost callback, then the client exchanges the code for access_token via the remote OAuth backend (GATE_PAY_OAUTH_TOKEN_BASE_URL, etc.). Stores access_token in-process for Authorization: Bearer on x402_submit_payment when sign_mode is centralized_payment. Success JSON includes gate_pay_access_token_masked and gate_pay_uid_masked (脱敏). Wallet MCP login (x402_quick_wallet_auth) is separate and not used for Gate Pay.
Inputs: no named parameters.
x402_place_orderB
Send an HTTP request and return complete response information including headers, body, and the original request details. Returns status code, all response headers (including PAYMENT-REQUIRED if present), response body, and the original request parameters. Use this for any HTTP request where you need full response details.
Inputs: url (required), body, method.
x402_quick_wallet_authA
When the user selects sign_mode quick_wallet, run this tool first to perform the same device-flow login/authorization as the quick_wallet signing path. If the in-process MCP token is already valid, returns ready status and wallet addresses; otherwise opens the browser flow (Gate by default, or Google if wallet_login_provider is google). After a fresh login succeeds, the user may need to confirm before continuing to payment. To switch authorization provider (e.g. Gate vs Google), restart the MCP server; the in-process wallet client keeps the current session until restart.
Inputs: wallet_login_provider.
x402_sign_paymentA
Parse X402 payment requirements from PAYMENT-REQUIRED header or response body, create a signed payment authorization, and submit the payment to complete a 402-protected request. Supports signing modes: local_private_key (local EVM wallet), quick_wallet (custodial MCP wallet), and plugin_wallet (browser extension wallet). For centralized payment (中心化支付), obtain Gate Pay access_token via x402_gate_pay_auth and use x402_submit_payment with sign_mode centralized_payment — no MCP calls for Gate Pay auth. Provide either payment_required_header or response_body containing X402 payment requirements.
Inputs: url (required), body, method, sign_mode, +3 more.
x402_submit_paymentA
Submit a signed payment to complete a 402-protected request. Takes the payment_signature from x402_create_signature and sends it to the merchant along with the original request. When sign_mode is centralized_payment, runs Gate Pay OAuth (local callback + remote token exchange) if needed, same as x402_gate_pay_auth, no MCP, and attaches Authorization: Bearer . Returns the final response from the merchant.
Inputs: url (required), payment_signature (required), body, method, +1 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
Multiple tools have overlapping purposes and unclear boundaries. x402_sign_payment, x402_create_signature, x402_submit_payment, and x402_centralized_payment all handle payment signing/submission in overlapping ways, and the auth tools overlap with the centralized payment tool's OAuth handling. An agent would struggle to select the correct tool for a given situation.
The x402_ prefix provides a consistent namespace, but the verb/noun pattern is mixed. Tools like place_order, sign_payment, create_signature, and submit_payment are verb-first, while gate_pay_auth, quick_wallet_auth, and centralized_payment are noun-first. 'centralized_payment' also reads as a noun phrase rather than a clear action, reducing predictability.
Seven tools is within the typical reasonable range for a payment-focused server. However, several tools are redundant (e.g., sign_payment duplicates create_signature + submit_payment, and centralized_payment duplicates gate_pay_auth + submit_payment for central payments), so the set feels slightly bloated rather than tightly scoped.
The core X402 flow—sending a request, parsing PAYMENT-REQUIRED, signing, and submitting—is well covered, including authentication for quick wallet and centralized payment modes. Minor gaps exist, such as no explicit tool for local private key configuration or plugin wallet authentication, and no payment status/refund operations, but these are not critical for the primary use case.
Maintenance
Related MCP Connectors
x402 MCP with exact and batched payments for recurring wallet, trading, market and web workflows.
Agent-commerce MCP server for x402/USDC payments and affiliate splits on Base.
Billing proxy for MCP servers. Adds Stripe and x402 crypto payments without writing billing code.
MCP server for Modern Treasury — payment orders, transactions, counterparties and ledgers.
Related MCP Servers
- AlicenseAqualityBmaintenanceMCP server for local transaction signing across EVM, UTXO, Tron, and XRP blockchains, with no network calls or API keys required.7199 npmMIT
- AlicenseNot gradedqualityDmaintenanceA hybrid MCP server that integrates x402 payment protocol, providing tools to manage cryptocurrency payments and dynamically create HTTP endpoints protected by payments.223 npmMIT
- AlicenseNot gradedqualityCmaintenanceA local MCP proxy that connects to remote MCP servers and automatically handles x402 payments, signing USDC on-chain when a tool returns HTTP 402.26 npm1MIT
- AlicenseNot gradedqualityDmaintenanceMCP server for agent-native and human-accessible payments using MPP and x402 protocols, enabling payment flows from CLI or agent hosts.3 npmMIT