Gate Pay x402 (gate-pay-x402)
General Rules
⚠️ STOP — Follow any shared runtime rules your host applies before this skill (if the host provides them). Do NOT select or call tools until those rules are satisfied.
- Only call MCP tools explicitly listed in this skill. Tools not documented here must NOT be called, even if they exist in the MCP server.
Allowlisted Gate Pay MCP tool names (exact names as exposed by the live server; skip tools the server does not list):
- Read / orchestration (no on-chain debit by themselves; may perform HTTP or session setup per schema):
x402_place_order. x402_request: only when the connected server lists it (some alternate single-tool builds); use for merchant HTTP, 402 handling, or MCP Wallet login per that tool’s inputSchema.
- Session / auth:
x402_quick_wallet_auth (MCP Wallet / quick_wallet). x402_gate_pay_auth (Gate Pay OAuth for centralized_payment when listed—see that tool’s description and inputSchema).
- Write / sign / pay (irreversible or security-sensitive—require explicit user confirmation after a clear price for payment steps):
x402_sign_payment, x402_create_signature, x402_submit_payment, x402_centralized_payment (if listed by the server).
- Merchant discovery (read-only): May live on a separate MCP server from
gatepay-local-mcp (e.g. remote HTTP MCP). When any connected server lists it, call the catalog tool by its exact live name (often discoveryResource; if the name differs, use the live name only). No payment from discovery. If no server lists it, use user URLs / context only—never invent tool names.
Do not use Gate Exchange MCP to substitute Gate Pay wallet binding or to finish a Gate Pay x402_place_order / same-server 402 flow on a third-party x402 MCP. When the user chose the gate_exchange rail, use only Gate Exchange MCP tools per Gate Exchange path.
No write without consent: Do not invoke any tool whose inputSchema performs signing, fund movement, or centralized settlement—including x402_sign_payment, x402_create_signature + x402_submit_payment, x402_centralized_payment, and (if listed) pay steps inside x402_request—until the user has seen a clear price (quote or 402 summary) and given explicit confirmation. One confirmation must cover all write steps in the current pay flow.
Gate Pay x402 layer — Merchant discovery (resource list only), wallet/env setup, and payment routing. Payment and wallet x402_* tools normally run on local gatepay-local-mcp (stdio). Discovery may run on the same server or on a second MCP (e.g. remote URL)—use the host’s tool list to see which server exposes which tool. Tool argument names, types, required fields, and enums come from each tool’s inputSchema. If anything in this skill disagrees with inputSchema, follow inputSchema for that invocation.
User-facing language: Write all user-visible replies in the same language the user is using in the current conversation (e.g. Chinese if they write Chinese, English if they write English).
Trigger Scenarios: Use when the user wants to pay via x402, discover or pick a paid service, configure or add Gate Pay wallets, or choose a payment rail:
- Wallet setup / add / switch: configure / set up / add / bind / change default payment method,
PAYMENT_METHOD_PRIORITY, and semantically equivalent phrasing in any language
- By rail (MCP Wallet /
quick_wallet): MCP Wallet, Quick Wallet, and the same product under localized or colloquial names in the user’s language, plugin wallet (including extension plus Open-API-token style setup), bind private key, local private key, private-key payment, EVM_PRIVATE_KEY, PLUGIN_WALLET_TOKEN
- Pay / buy: 402, payment required, help me pay / purchase, place order, sign payment,
x402_sign_payment — and equivalent phrasing in any language
- Paid service intent (examples, not literal only): book flights, order food, buy an API, “help me buy X”, which merchants exist, list of billable or paid services — and equivalent phrasing in any language the user writes
- Exchange: Gate Exchange payment, pay via exchange
Recognize intents from meaning, not only exact English strings; users often mix languages or use vendor-specific terms.
NOT this skill (common misroutes):
- Generic market/trade-only requests with no Gate Pay MCP, no x402, no merchant discovery for this product, no wallet/env setup for this product
- Pure consultation or trade decisions with no Gate Pay / x402 / this MCP path
- Payments that must be completed only on a non-Gate third-party x402 MCP for the same order as
x402_place_order from Gate Pay MCP (violates same-server rule below)
Domain Knowledge
- Product scope: Gate Pay x402: merchant HTTP and 402 handling via
gatepay-local-mcp (x402_* tools); optional merchant discovery on the same or another MCP when a catalog tool is listed (see GatePay merchant discovery); wallet rails (quick_wallet, plugin_wallet, local_private_key); optional Gate Exchange MCP when the user chose gate_exchange.
- Schema-first: Build every MCP
arguments object from the target tool’s inputSchema; on conflict with this file, inputSchema wins (see Gate Pay x402 Module (MCP Tools)).
- Consent: No signing, fund movement, or settlement tools until the user sees a clear price and gives explicit confirmation (GatePay merchant discovery & agent orchestration, Workflow).
- Rails and env:
PAYMENT_METHOD_PRIORITY and MCP env are covered in Wallet configuration procedure and Authentication State.
Routing Rules
Route by user intent (procedural sections live in this file — wallet, discovery, workflow, Exchange; no procedural split to other files. QA scenarios are in references/scenarios.md; that file is not a runtime routing submodule):
| User Intent |
Keywords / signals |
Target |
| Wallet / env configuration |
Wallet setup, add rail, MCP Wallet, Quick Wallet, 快捷钱包, gate/Gate钱包, localized names, plugin wallet / 插件钱包, private key, PAYMENT_METHOD_PRIORITY, MCP host env — match intent in any language |
This file — Wallet configuration procedure then Authentication State |
| Merchant discovery / selection / quote |
Which merchants, 有哪些商户, paid service list, 能付费的服务列表, pick a service, quote / dynamic price, discovery before pay — and non-English equivalents |
This file — GatePay merchant discovery & agent orchestration then Workflow |
| x402 payment (Gate Pay MCP) |
pay, 402, place order, x402_place_order, x402_sign_payment, and (if listed) x402_request — and non-English equivalents |
This file — Workflow |
| Gate Exchange payment |
exchange, Gate Exchange — and non-English equivalents |
This file — Gate Exchange path |
| MCP connectivity |
MCP missing, tools not found, need to add discovery or local pay server |
This file — MCP host setup (discovery + payment) then MCP Server Connection Detection |
GatePay merchant discovery & agent orchestration
One-line intent: When the user states what paid service they want in natural language, the agent discovers merchants → selects a resource by rules → quotes when the merchant supports it → fills required call parameters → invokes the service → after a clear price is visible, asks for explicit pay consent → only then runs signing / payment tools. Wallet rails (quick_wallet, plugin_wallet, local_private_key, gate_exchange) follow Wallet configuration procedure and Authentication State.
Scope and boundaries
- Merchant discovery layer returns an invokable resource list only. It does not take payment, does not place orders, and does not settle on-chain.
- Order / HTTP / 402 use
x402_place_order and/or x402_request (and related x402_*) on the payment MCP — typically gatepay-local-mcp. Every argument comes from that tool’s inputSchema.
- Two MCPs (common): (1) Discovery MCP — remote or separate process exposing the catalog tool only. (2) Payment MCP —
npx -y gatepay-local-mcp (stdio) exposing x402_*. The agent must invoke each tool on the server that lists it; do not assume discovery and pay share one connection.
- Registry / Discovery HTTP API (if present behind MCP) is implementation detail: use MCP tools and responses; do not duplicate discovery payload field tables here — treat list item shape as whatever the MCP returns, validated against
inputSchema.
Merchant discovery MCP tool (when listed)
- Which server: Scan all configured MCP servers. The catalog tool may appear only on the discovery server (not on
gatepay-local-mcp).
- Tool name (expected):
discoveryResource — must match the live tool list on the server that exposes discovery. If the shipped name differs, use the live name only.
- Behavior: Returns a paginated invokable resource list only (HTTP and/or MCP-type entries with
accepts, optional quote metadata). No payment, no order placement from this tool.
- Arguments (logical field names — assemble values per live
inputSchema; on any mismatch, inputSchema wins):
| Field |
Required |
Notes |
resourceDes |
Yes |
User intent / service description for fuzzy catalog match (natural language or keywords). |
resourceType |
Yes |
http or mcp (design default mcp). |
pageNum |
No |
Page index; design default 1. |
pageSize |
No |
Page size; design default 10. |
tenantId |
No |
Tenant id; design default GATE_PAY; omit if schema does not expose it. |
- Response mapping: Items typically include endpoint identity and
accepts (with outputSchema / input for HTTP method, headers, body, or MCP tool + inputSchema + transport). Optional metadata: quote_endpoint, quote_method, pricing_mode, quote_inputSchema / inputSchema for dynamic pricing — use for Quote vs main call order above. Field names may appear as resourceUrl or resource depending on layer; always follow the actual tool response and map into x402_place_order / x402_request per their inputSchema.
- If the tool is not listed: Skip discovery calls; rely on user-provided URLs and conversation context.
When discoveryResource is mandatory (before merchant HTTP)
When some connected MCP server lists the discovery catalog tool (often discoveryResource — use the exact name from that server’s tool list), and all of the following hold:
- The user expresses purchase or order intent for a good or service in natural language (e.g. “帮我买一双鞋”, “订一杯咖啡”, “买一个查天气的 API”) — including the same intent in other languages or colloquial phrasing.
- The user message plus conversation context do not supply enough information to satisfy the merchant HTTP tool’s
inputSchema on the payment MCP for x402_place_order or x402_request (typically missing or incomplete url / method / body or equivalent required fields) without inventing endpoints or parameters.
Then the agent MUST call the discovery tool first on the server that lists it — build arguments only from that tool’s inputSchema (commonly map the user’s wording into resourceDes, set resourceType per schema, e.g. design default mcp). Then apply Selection rules, then continue Workflow from Step 3–4 on the payment MCP with the chosen resource. Do not skip discovery by guessing merchant URLs or calling x402_place_order / x402_request with empty, placeholder, or hallucinated merchant targets.
Do not apply this mandatory catalog step when: no connected server lists a discovery tool (use user URLs/context only); the user already provides a concrete merchant endpoint and parameters adequate for the HTTP tool’s schema; the session is wallet / rail setup only with no purchase flow; or the user chose gate_exchange only (Gate Exchange path).
Selection rules (filter → rank → tie-break)
Apply in order; filter first, then sort what remains; if several options remain close, ask the user — do not silently choose.
- Intent match:
description, type, and capabilities align with the user goal (e.g. flights vs food vs API).
- Constraints: Network, currency,
maxPrice, user-stated budget — drop resources that violate them.
- Callability: Current environment can satisfy required MCP transport and/or HTTP; if not, drop or explain limitation.
- Parameter feasibility: Given what the user already said, can required inputs (per merchant
inputSchema) be filled? If a resource needs unknown critical fields and there is no safe default, do not select it or pick the easiest-to-complete option and ask for missing fields.
- Price path: If the user insists on knowing price before deciding, prefer resources that expose quote / dynamic metadata; otherwise, among equally good options, prefer fixed-price or simpler paths.
- Tie-break: If multiple resources remain similarly suitable, present differences (price band, latency, limits) and ask the user to pick (e.g. by number). Never auto-pick without user choice.
Quote vs main call order
- If the discovery item or schema/metadata indicates quote / dynamic pricing (e.g.
dynamic, quote_endpoint, or equivalent per MCP docs): quote first → show the user currency, amount, and conditions → ask whether to continue with that merchant → after yes, call the main service with parameters.
- If there is no quote path: do not invent a separate quote step; call the main service per contract. If cost appears only in 402, parse 402 then run mandatory pay confirmation below.
- No quote path does not mean skipping pay confirmation.
Parameters, price visibility, and mandatory pay confirmation
- Parameters: Before any merchant /
x402_place_order call (or x402_request if that is the tool the payment MCP lists for HTTP/402), list required fields from the relevant inputSchema. If the user has not provided them, complete via dialogue. Do not call with empty or guessed values to “probe” the API.
- Price visibility: On a quote path, show currency, amount, and applicability. Without quote, after 402 or an explicit price from the merchant, summarize the payment requirement in the user’s language.
- Pay confirmation (mandatory): The user must see a clear price (quote result or 402 summary) first. Then the agent must ask again; the message should cover how much, which asset/chain (if known), and which payment method (if known). Only after explicit consent (e.g. “confirm pay”, “go ahead and pay”) invoke
x402_sign_payment, split signature tools, or further steps in x402_request only if that tool is listed on the payment MCP. If the user refuses or is unsure, stop payment; offer another merchant or end.
- Step 1 (Workflow) “balance / intent” checks may be merged with this see-price-then-confirm step to avoid double-asking; prefer one clear confirmation after price is visible.
Mapping discovery to Step 4
url / method / body for x402_place_order (or x402_request when that is the HTTP tool on the server) come from the user message, conversation context, or upstream discovery (resource identity, outputSchema, or equivalent in the MCP response). Map field names to whatever the tool inputSchema requires.
Alignment with Workflow
- Step 4 remains merchant HTTP + 402 handling via
x402_place_order or, when listed, x402_request (per server).
- Steps 5–6 (MCP Wallet login if needed, sign / pay tools): run only after mandatory pay confirmation above (or immediately before first charge/sign, if merged with confirmation — not before the user has a clear price and agrees).
- Same-server rule (payment): For one merchant order / one 402 challenge, all
x402_* steps (place order, sign, submit, auth for pay) use the same payment MCP server id (typically gatepay-local-mcp). Discovery may be invoked on a different server id; that does not break this rule—only x402_* must stay on one pay server for the order.
Wallet and rails (product rules)
These override older wording elsewhere in this file where they conflict, except where a tool’s inputSchema requires a field (e.g. a URL argument): then inputSchema wins — supply values per schema and vendor docs.
plugin_wallet: User configures PLUGIN_WALLET_TOKEN in MCP env only (full token never in chat). Do not require PLUGIN_WALLET_SERVER_URL in user env as a default rule; implementation may use a built-in endpoint. If inputSchema still requires a URL (or similar) for a call, fill it per schema/docs — not by contradicting required fields.
quick_wallet (MCP Wallet): Do not require MCP_WALLET_API_KEY, MCP_WALLET_URL, or similar “quick wallet API URL” env vars. Session comes from tool-driven login (x402_quick_wallet_auth, or x402_request when that build uses it for login, per schema); after success, update PAYMENT_METHOD_PRIORITY as in Section 1 (MCP Wallet).
- Payment failure and rail switching: Use only rails that are actually configured and available (
PAYMENT_METHOD_PRIORITY + env + login state). If only plugin_wallet is configured and it fails: do not start quick_wallet login/auth unless quick_wallet is already configured and the user explicitly agrees to switch. If there is no next rail, explain the failure, suggest checking token/plugin setup, and do not invent other payment methods. With multiple rails, you may try the next configured rail on failure; prefer a brief user check before switching rails (unless product defines a pure technical retry exception).
Hard stops (non-exhaustive)
- Discovery returns nothing usable and constraints cannot be relaxed → stop or relax and retry; do not fake merchants.
- Required parameters missing → do not call the merchant or pay tools.
- User has not explicitly agreed to pay after seeing price → do not call signature or payment tools.
- Plugin-only config and plugin call failed → do not auto-launch unconfigured
quick_wallet.
MCP host setup (discovery + payment)
Many deployments use two MCP entries:
| Role |
Typical transport |
Purpose |
| Payment MCP |
stdio — npx -y gatepay-local-mcp |
x402_place_order, x402_request, x402_sign_payment, x402_quick_wallet_auth, other x402_*; wallet env (PAYMENT_METHOD_PRIORITY, EVM_PRIVATE_KEY, PLUGIN_WALLET_TOKEN, …) goes here. |
| Discovery MCP (optional) |
HTTP remote URL (host-specific) |
Payable-merchant catalog only (often tool name discoveryResource — confirm in the live tool list). No substitute for payment tools. |
Merge both into the host’s MCP server map without removing unrelated MCPs. Reload MCP or restart the app after edits.
Example: mcp.json fragment (Cursor-style hosts)
Project: <project>/.cursor/mcp.json. User-wide: ~/.cursor/mcp.json. Under mcpServers:
{
"gatepay-merchant-discovery": {
"url": "https://openplatform.gateapi.io/pay-mcp-server/mcp"
},
"gatepay-local-mcp": {
"command": "npx",
"args": ["-y", "gatepay-local-mcp"],
"env": {}
}
}
- Keys (
gatepay-merchant-discovery, gatepay-local-mcp) may be renamed; keep them stable for the session so the agent targets the correct server for each tool.
- If your host requires a different shape for remote MCP (headers,
transport, SSE), follow current host docs—the important part is registering both endpoints when your product uses split discovery + local pay.
- Secrets belong only in
gatepay-local-mcp’s env (never in chat).
MCP Server Connection Detection
Before the first Gate Pay x402_* tool call for payment or MCP Wallet auth, and before mandatory merchant discovery when the flow needs a catalog, run the probes below (skip when the user has only received Section 0.A and has not yet chosen a rail).
A. Payment MCP (required for x402 pay / wallet auth)
- Scan configured servers for at least one tool whose name starts with
x402_ (e.g. x402_place_order, x402_sign_payment, x402_quick_wallet_auth). Some builds expose x402_request as the main HTTP/login tool instead of or alongside x402_place_order.
- Record that host’s server key as the payment server id (e.g.
gatepay-local-mcp).
- Verify the tool list includes
x402_place_order or x402_request or another documented x402_* entry for merchant HTTP/402.
| Result |
Action |
| Success |
Use this payment server id for all x402_* calls this session for one order flow. |
| Failure |
Show Setup guide — payment MCP below; do not guess pay parameters. |
B. Discovery MCP (required only if mandatory discovery applies)
- Scan all configured servers (including not the payment server) for the catalog tool — often
discoveryResource; use the exact name from the live list.
- Record that server key as the discovery server id (e.g.
gatepay-merchant-discovery) when present.
- If the user’s buy flow needs a catalog (When
discoveryResource is mandatory) and no server lists a discovery tool → show Setup guide — discovery MCP below.
| Result |
Action |
| Catalog tool found |
Call discovery only on discovery server id; map results into x402_place_order / x402_request on payment server id. |
| Catalog missing but mandatory |
User must add discovery MCP or supply merchant URL/params manually. |
| Catalog not needed |
Skip; user gave sufficient merchant fields or session is wallet-only / Exchange-only. |
Setup guide — payment MCP (show at most once per session when A fails):
Payment MCP (gatepay-local-mcp)
- Add a stdio server: command "npx", args ["-y", "gatepay-local-mcp"], env { } (add PAYMENT_METHOD_PRIORITY / EVM_PRIVATE_KEY / PLUGIN_WALLET_TOKEN only when that rail is used — full secrets never in chat).
- Cursor-style: merge into .cursor/mcp.json under mcpServers; reload MCP or restart the IDE.
- Other hosts: register the same stdio command per product docs (VS Code MCP, Claude Code, OpenClaw, etc.).
Setup guide — discovery MCP (show at most once per session when B is required but missing):
Discovery MCP (example id: gatepay-merchant-discovery)
- Add a remote MCP entry with your vendor URL, e.g. "url": "https://openplatform.gateapi.io/pay-mcp-server/mcp" (confirm exact URL and transport with your deployment).
- Merge into the same mcpServers object as the payment MCP; reload MCP.
- After reload, confirm the catalog tool appears (name may be discoveryResource or differ — use the live tool list).
Wallet configuration procedure
When the user wants to configure, add, or change a payment wallet for Gate Pay MCP, follow this flow. Arguments for any MCP tool come from that tool’s inputSchema.
0. Entry
0.A Vague intent — first reply only (user-facing)
If the user only asks to configure or add a wallet (e.g. “help me set up my wallet”, “configure wallet”) without naming a specific rail, this turn must be short and plain-language. Use the same language as the user (see User-facing language above).
Give three options — for each, in plain language: what it is, who it suits, roughly what they will do — one or two sentences total per option. Contrast the three clearly (browser/device login vs extension/Open API style vs holding a key on the machine):
- MCP Wallet (localized: Quick Wallet, 快捷钱包, gate钱包 / Gate钱包): Sign in with Gate in a browser or device flow (like logging into an app); best for users who want no extension install and are fine with hosted login. After they pick, you’ll drive MCP tools to complete login and then payment order.
- Plugin wallet: Uses the Gate browser extension and an Open API–style token you keep in local app settings — good for users who already use the Gate extension and want payments authorized from the plugin. After they pick, you’ll point them to get a token from the plugin side and paste it only into local config, not into random sites.
- Private key (local signing): They put their own EVM private key in local config and the MCP signs on this machine — for advanced users who fully control a key and accept handling raw key material. After they pick, you’ll tell them to fill only local config, never type the key into chat.
In this first message, do not include: env key names (e.g. EVM_PRIVATE_KEY, PLUGIN_WALLET_*, PAYMENT_METHOD_PRIORITY), MCP tool names (e.g. x402_quick_wallet_auth, x402_place_order), enum tokens (quick_wallet, plugin_wallet), how to edit mcp.json (or other paths), or step-by-step technical procedures. Defer all of that until after they choose (Section 0.B → Sections 1–3).
Tone: No long checklist, no env audit, no long security lecture. At most one short line, e.g. “After you choose, I’ll walk you through the next steps step by step.”
Optionally one line for Gate Exchange pay if that MCP applies.
Close by asking them to pick one (name or number). Wait for their choice (unless they already named a rail in the same first message).
0.B After the user chooses (or already named a rail)
Continue with Sections 1–3 / Section 5 — here you may use env keys, tool names, PAYMENT_METHOD_PRIORITY, and file edits per those sections. For MCP Wallet, run MCP Server Connection Detection and record the server identifier.
1. MCP Wallet (quick_wallet)
MCP Wallet is one product channel; localized names (e.g. “Quick Wallet”) refer to the same rail. The MCP enum / env token remains quick_wallet — use that value in PAYMENT_METHOD_PRIORITY and in sign_mode (or equivalent fields) per inputSchema.
No user API key for this rail: MCP Wallet does not use MCP_WALLET_API_KEY, does not ask users to apply for or paste a “quick wallet API key”, and is not the same as the plugin wallet’s Open API token. Credentials come from the tool-driven login (device / OAuth flow); the implementation may persist session data locally (e.g. under ~/.gate-pay/) — follow the tool response, not chat guesses.
Order: tool auth first, then PAYMENT_METHOD_PRIORITY only on success. Do not write or merge PAYMENT_METHOD_PRIORITY until MCP Wallet login has succeeded per the tool you actually have (see below).
Wrong flows (MCP Wallet): Do not instruct users to set MCP_WALLET_API_KEY, MCP_WALLET_URL as a prerequisite, generic API keys, or EVM_PRIVATE_KEY for this rail. Do not conflate MCP Wallet with plugin_wallet token setup.
Which tool to call (read the live MCP tool list):
- If
x402_quick_wallet_auth exists → use it first; arguments from inputSchema (e.g. optional wallet_login_provider: gate | google).
- If
x402_quick_wallet_auth is absent but x402_request is listed and its inputSchema supports MCP Wallet login → trigger login via x402_request using fields for quick_wallet (e.g. sign_mode: quick_wallet, and any required wallet_login_provider / URL params). Still no user API key — same auth-first rule; then update PAYMENT_METHOD_PRIORITY only after success. (Common npm gatepay-local-mcp single-tool builds often list only x402_request for both HTTP and MCP Wallet login—still only if listed.)
- If the user chose centralized_payment and
x402_gate_pay_auth is listed → follow that tool’s description and inputSchema for Gate Pay OAuth (separate from MCP Wallet login).
Definition — configured: MCP Wallet is fully configured only after login / device flow completes successfully (tool response success / ready). Failed or abandoned login → do not update PAYMENT_METHOD_PRIORITY.
- First — MCP tool: Per Which tool to call above, invoke
x402_quick_wallet_auth, or x402_request when listed and used for quick_wallet login per schema, on the payment MCP (see MCP Server Connection Detection §A). Guide the user through MCP Wallet login until the tool indicates success / ready.
- If login succeeds (session established per tool response): then edit MCP
env:
- Add
quick_wallet to PAYMENT_METHOD_PRIORITY (merge with existing list if any).
- If no other rail was in
PAYMENT_METHOD_PRIORITY before, you may set quick_wallet as the only or first entry per user’s stated intent at Section 0.B.
- If one or more other rails were already in
PAYMENT_METHOD_PRIORITY, ask the user explicitly: whether to make quick_wallet the new default (move to front). Only if the user says yes move it to the first position; if no, append quick_wallet without changing the current first token (do not reorder without confirmation — see Section 4).
- If auth / login fails (error, timeout, user cancelled, non-ready): do not change
PAYMENT_METHOD_PRIORITY or add quick_wallet. Explain next steps; user may retry.
- After successful config writes, remind reload MCP / restart the host if needed.
- Disclose tool output after MCP Wallet login:
- Private key / seed / exported signing secret: Never paste the full value in chat. Print it to the integrated terminal (stdout) so it works on macOS, Windows, and Linux: prefer
node -e / node -p or python -c to print a JSON-safe or plain-text line; if neither runtime is on PATH, write a temporary file under the project (gitignored path) and run a command that prints its path or contents to the terminal, then tell the user in chat (in their language) to open the Terminal panel and copy from there — still do not put the secret in chat.
- Public deposit / wallet addresses (non-secret identifiers): may show in chat in full or summarized, in the user’s language, plus any short context the user needs.
- Other bulky or mixed responses: Strip or redact secrets for chat; put full private material only in terminal/temp file as above; addresses stay chat-eligible.
- Apply Safety Rules.
2. Plugin wallet (plugin_wallet)
PLUGIN_WALLET_TOKEN: Same plugin_wallet rules as Wallet and rails in GatePay merchant discovery & agent orchestration (token in env only, never full token in chat). PLUGIN_WALLET_SERVER_URL: optional per product defaults; if inputSchema requires a URL for a tool call, set it per schema/vendor docs.
PAYMENT_METHOD_PRIORITY: Add plugin_wallet. If this is the second or later rail, ask whether plugin_wallet should become the default (first in list). Only reorder to put it first if the user confirms yes; otherwise append without changing the current default.
- No
x402_quick_wallet_auth for this rail.
- Remind reload MCP after
env changes.
3. Private key / local signing (local_private_key)
- In
env, ensure EVM_PRIVATE_KEY exists for local signing. Use a placeholder in shared repos; the user fills the real value only in their local MCP config. Never collect or repeat a private key in chat.
- Add any
RPC_URL (or equivalent) variables required by the MCP package docs.
PAYMENT_METHOD_PRIORITY: Add local_private_key. If this is the second or later rail, ask whether local_private_key should become the default. Only move it first if the user confirms yes.
- No
x402_quick_wallet_auth for this rail unless the user also uses MCP Wallet (quick_wallet).
- Remind reload MCP after
env changes.
4. Adding a second rail or changing default
- When the user binds a second or additional payment rail, never change the first token of
PAYMENT_METHOD_PRIORITY (the current default) without an explicit user choice.
- Always ask a clear yes/no (or pick-one) question in the user’s language, e.g. “Should <rail> become the default payment method?” Only if the user answers yes, move that rail’s token to the front. If no, append the new rail or keep existing order as appropriate without promoting it to default.
- MCP Wallet (
quick_wallet): Auth (Section 1) still comes before any PAYMENT_METHOD_PRIORITY change that adds quick_wallet; after successful login, apply the same user-confirmed rule for whether quick_wallet becomes default when other rails already exist.
- Reordering among rails already listed (user wants to switch default only): still require explicit confirmation before editing which token is first.
5. Gate Exchange (gate_exchange)
If the user configures exchange-only pay: ensure Gate Exchange MCP is registered separately; set PAYMENT_METHOD_PRIORITY to include gate_exchange when that is the intended rail. Payment tools are only on the Exchange MCP — read each tool’s inputSchema there.
Authentication State
Payment and signing use whichever wallet rail the user has actually configured. Gate Pay MCP env is read from the host’s MCP config (path and format depend on Cursor, VS Code, Claude Code, etc. — not hardcoded here).
PAYMENT_METHOD_PRIORITY: If set in env, comma-separated; first token = default. Tokens: quick_wallet, plugin_wallet, local_private_key, gate_exchange. If unset, infer rails only from non-empty env keys / MCP session, or ask the user.
local_private_key: Only when the user chose this rail: EVM_PRIVATE_KEY (and any RPC vars your MCP documents) must be set in env — never collect private keys in chat. If empty, this rail is unavailable.
quick_wallet (MCP Wallet): Setup = login success via tool auth (Section 1: x402_quick_wallet_auth if present, else x402_request when listed and schema supports MCP Wallet login). No MCP_WALLET_API_KEY for users. Auth before writing PAYMENT_METHOD_PRIORITY; on failure, do not change that env. Pay: Workflow Step 5; on expiry, auth once then retry sign once.
plugin_wallet: PLUGIN_WALLET_TOKEN in env; PLUGIN_WALLET_SERVER_URL not user-mandatory by default (see Wallet and rails). If inputSchema requires a URL argument, comply with schema. If the token is missing, this rail is unavailable.
gate_exchange: Gate Exchange MCP configured separately; route there only when that MCP exists and user selects this rail.
When a second or additional payment rail is added, ask whether the default should switch to the newly bound rail. Do not reorder PAYMENT_METHOD_PRIORITY until the user explicitly agrees to change the default.
Gate Pay x402 Module (MCP Tools)
How to build arguments (mandatory)
Before every MCP tool call in this flow:
- Locate the tool by exact name on the correct server: discovery tools on the discovery server id (if any); all
x402_* on the payment server id (see MCP Server Connection Detection).
- Read that tool's
inputSchema: properties, required, enum, description.
- Assemble
arguments only from that schema and from allowed runtime values (user message, context, prior tool outputs).
Do not copy parameter tables from this Skill; the MCP inputSchema is the source of truth. Any conflict between this file and inputSchema → follow inputSchema. If the MCP is not connected and schema is unavailable, complete MCP setup first or use vendor docs.
Tools (names to look up in MCP)
Merchant discovery: When listed on any server, use discoveryResource (or the exact name on that server) and its inputSchema. Invoke on the discovery server, not on the payment server unless both tools are co-listed there. If absent everywhere, skip discovery calls.
| Tool |
Classification |
Side-effect level |
Purpose |
Parameters |
discoveryResource |
Read (list) |
None (no pay) |
GatePay catalog search — invokable resources + metadata only (no pay/order) |
resourceDes, resourceType (http|mcp), optional pageNum, pageSize, tenantId — see live inputSchema |
x402_place_order |
Read / HTTP |
Merchant I/O only; no sign until later tools |
Send merchant HTTP request; read status, headers, body |
See MCP inputSchema for x402_place_order |
x402_request |
Mixed |
Low when used for HTTP/login; High when schema drives combined sign/pay—still requires consent before any pay |
Only if listed — some builds use this for HTTP + 402 + optional sign, and/or MCP Wallet login via quick_wallet / sign_mode |
See MCP inputSchema for x402_request |
x402_quick_wallet_auth |
Write (session) |
Establishes wallet session |
MCP Wallet device/OAuth auth (quick_wallet rail) |
See MCP inputSchema for x402_quick_wallet_auth |
x402_gate_pay_auth |
Write (session) |
OAuth session for centralized pay |
Gate Pay OAuth when user uses centralized_payment (Bearer token for submit per tool docs) |
See MCP inputSchema for x402_gate_pay_auth |
x402_sign_payment |
Write (pay) |
High — signs and submits payment |
Parse 402, sign, submit payment (all-in-one) |
See MCP inputSchema for x402_sign_payment |
x402_create_signature |
Write (sign) |
High — produces signing material |
Create signed payload / encoded signature only |
See MCP inputSchema for x402_create_signature |
x402_submit_payment |
Write (pay) |
High — submits payment |
Submit payment with signature (split path) |
See MCP inputSchema for x402_submit_payment |
x402_centralized_payment |
Write (pay) |
High — centralized settlement when server exposes it |
Account-center / centralized pay path per MCP (if listed) |
See MCP inputSchema for x402_centralized_payment |
Merchant url / method / body come from the user message, conversation context, or upstream discovery (resource / outputSchema / MCP discovery response — map per **`inputSchema
…(truncated)
1---2name: gate-pay-x4023description: Helps with Gate Pay x402 payments (HTTP 402), finding payable merchants when discovery is available, and wallet setup: Quick Wallet, Gate plugin token, local EVM key, or Gate Exchange. Use when the user pays or wants to pay with x402 or 402, configures a Gate or MCP wallet or payment default, lists merchants or paid services, orders something without a merchant link, or says 快捷钱包, 插件钱包, 私钥, 支付方式, 有哪些商户, 能付费的服务列表, 配置钱包, gate钱包, MCP钱包, 交易所, 下单, 支付, or PAYMENT_METHOD_PRIORITY. Do NOT use for trading-only or market chat with no Gate Pay x402 or wallet intent, or for completing the same Gate Pay order on another vendor's x402 MCP.4---56# Gate Pay x402 (gate-pay-x402)78## General Rules910⚠️ STOP — Follow any **shared runtime rules** your host applies before this skill (if the host provides them). Do NOT select or call tools until those rules are satisfied.11- **Only call MCP tools explicitly listed in this skill.** Tools not documented here must NOT be called, even if they exist in the MCP server.1213**Allowlisted Gate Pay MCP tool names (exact names as exposed by the live server; skip tools the server does not list):**1415- **Read / orchestration (no on-chain debit by themselves; may perform HTTP or session setup per schema):** `x402_place_order`. **`x402_request`:** only when the **connected** server lists it (some alternate single-tool builds); use for merchant HTTP, 402 handling, or MCP Wallet login **per that tool’s `inputSchema`**.16- **Session / auth:** `x402_quick_wallet_auth` (MCP Wallet / `quick_wallet`). `x402_gate_pay_auth` (Gate Pay OAuth for **centralized_payment** when listed—see that tool’s description and `inputSchema`).17- **Write / sign / pay (irreversible or security-sensitive—require explicit user confirmation after a clear price for payment steps):** `x402_sign_payment`, `x402_create_signature`, `x402_submit_payment`, `x402_centralized_payment` (if listed by the server).18- **Merchant discovery (read-only):** May live on a **separate** MCP server from **`gatepay-local-mcp`** (e.g. remote HTTP MCP). When **any** connected server lists it, call the catalog tool by its **exact** live name (often **`discoveryResource`**; if the name differs, use the live name only). No payment from discovery. If **no** server lists it, use user URLs / context only—**never** invent tool names.1920**Do not** use Gate Exchange MCP to substitute Gate Pay wallet binding or to finish a Gate Pay `x402_place_order` / same-server 402 flow on a third-party x402 MCP. When the user chose the **`gate_exchange` rail**, use **only** Gate Exchange MCP tools per **Gate Exchange path**.2122**No write without consent:** Do not invoke any tool whose `inputSchema` performs signing, fund movement, or centralized settlement—including `x402_sign_payment`, `x402_create_signature` + `x402_submit_payment`, `x402_centralized_payment`, and (if listed) pay steps inside `x402_request`—until the user has seen a **clear price** (quote or 402 summary) and given **explicit** confirmation. One confirmation must cover **all** write steps in the current pay flow.2324---2526> **Gate Pay x402 layer** — Merchant discovery (resource list only), wallet/env setup, and payment routing. **Payment and wallet `x402_*` tools** normally run on **local** **`gatepay-local-mcp`** (stdio). **Discovery** may run on the **same** server or on a **second** MCP (e.g. remote URL)—use the **host’s tool list** to see which server exposes which tool. Tool **argument names, types, required fields, and enums** come from each tool’s **`inputSchema`**. **If anything in this skill disagrees with `inputSchema`, follow `inputSchema` for that invocation.**2728**User-facing language:** Write all **user-visible** replies in the **same language the user is using** in the current conversation (e.g. Chinese if they write Chinese, English if they write English).2930**Trigger Scenarios**: Use when the user wants to **pay via x402, discover or pick a paid service, configure or add Gate Pay wallets, or choose a payment rail**:3132- **Wallet setup / add / switch:** configure / set up / add / bind / change default payment method, `PAYMENT_METHOD_PRIORITY`, and semantically equivalent phrasing in any language33- **By rail (MCP Wallet / `quick_wallet`):** MCP Wallet, Quick Wallet, and **the same product under localized or colloquial names in the user’s language**, **plugin wallet** (including extension plus Open-API-token style setup), bind private key, local private key, private-key payment, `EVM_PRIVATE_KEY`, `PLUGIN_WALLET_TOKEN`34- **Pay / buy:** 402, payment required, help me pay / purchase, place order, sign payment, `x402_sign_payment` — and equivalent phrasing in any language35- **Paid service intent (examples, not literal only):** book flights, order food, buy an API, “help me buy X”, **which merchants exist**, **list of billable or paid services** — and equivalent phrasing in any language the user writes36- **Exchange:** Gate Exchange payment, pay via exchange3738Recognize intents from **meaning**, not only exact English strings; users often mix languages or use vendor-specific terms.3940**NOT this skill** (common misroutes):4142- Generic market/trade-only requests with **no** Gate Pay MCP, **no** x402, **no** merchant discovery for this product, **no** wallet/env setup for this product43- Pure consultation or trade decisions with **no** Gate Pay / x402 / this MCP path44- Payments that must be completed **only** on a **non-Gate** third-party x402 MCP for the **same** order as `x402_place_order` from Gate Pay MCP (violates same-server rule below)4546---4748## Domain Knowledge4950- **Product scope:** Gate Pay **x402**: merchant HTTP and **402** handling via **`gatepay-local-mcp`** (`x402_*` tools); optional **merchant discovery** on the **same or another** MCP when a catalog tool is listed (see **GatePay merchant discovery**); wallet rails (`quick_wallet`, `plugin_wallet`, `local_private_key`); optional **Gate Exchange** MCP when the user chose **`gate_exchange`**.51- **Schema-first:** Build every MCP `arguments` object from the target tool’s **`inputSchema`**; on conflict with this file, **`inputSchema` wins** (see **Gate Pay x402 Module (MCP Tools)**).52- **Consent:** No signing, fund movement, or settlement tools until the user sees a **clear price** and gives **explicit** confirmation (**GatePay merchant discovery & agent orchestration**, **Workflow**).53- **Rails and env:** **`PAYMENT_METHOD_PRIORITY`** and MCP **`env`** are covered in **Wallet configuration procedure** and **Authentication State**.5455---5657## Routing Rules5859Route by user intent (procedural sections live in **this file** — wallet, discovery, workflow, Exchange; **no** procedural split to other files. QA scenarios are in **`references/scenarios.md`**; that file is **not** a runtime routing submodule):6061| User Intent | Keywords / signals | Target |62|-------------|----------------------|--------|63| **Wallet / env configuration** | Wallet setup, add rail, MCP Wallet, Quick Wallet, 快捷钱包, gate/Gate钱包, localized names, plugin wallet / 插件钱包, private key, `PAYMENT_METHOD_PRIORITY`, MCP host env — match intent in any language | This file — **Wallet configuration procedure** then **Authentication State** |64| **Merchant discovery / selection / quote** | Which merchants, 有哪些商户, paid service list, 能付费的服务列表, pick a service, quote / dynamic price, discovery before pay — and non-English equivalents | This file — **GatePay merchant discovery & agent orchestration** then **Workflow** |65| **x402 payment (Gate Pay MCP)** | pay, 402, place order, `x402_place_order`, `x402_sign_payment`, and (if listed) `x402_request` — and non-English equivalents | This file — **Workflow** |66| **Gate Exchange payment** | exchange, Gate Exchange — and non-English equivalents | This file — **Gate Exchange path** |67| **MCP connectivity** | MCP missing, tools not found, need to add discovery or local pay server | This file — **MCP host setup (discovery + payment)** then **MCP Server Connection Detection** |6869---7071## GatePay merchant discovery & agent orchestration7273**One-line intent:** When the user states what paid service they want in natural language, the agent **discovers merchants** → **selects** a resource by rules → **quotes** when the merchant supports it → **fills required call parameters** → **invokes** the service → after a **clear price** is visible, **asks for explicit pay consent** → only then runs signing / payment tools. Wallet rails (`quick_wallet`, `plugin_wallet`, `local_private_key`, `gate_exchange`) follow **Wallet configuration procedure** and **Authentication State**.7475### Scope and boundaries7677- **Merchant discovery layer** returns an invokable **resource list** only. It **does not** take payment, **does not** place orders, and **does not** settle on-chain.78- **Order / HTTP / 402** use **`x402_place_order`** and/or **`x402_request`** (and related **`x402_*`**) on the **payment MCP** — typically **`gatepay-local-mcp`**. **Every** argument comes from that tool’s **`inputSchema`**.79- **Two MCPs (common):** **(1) Discovery MCP** — remote or separate process exposing the catalog tool only. **(2) Payment MCP** — `npx -y gatepay-local-mcp` (stdio) exposing **`x402_*`**. The agent **must** invoke each tool on the **server that lists it**; do not assume discovery and pay share one connection.80- **Registry / Discovery HTTP API** (if present behind MCP) is implementation detail: use **MCP tools and responses**; do **not** duplicate discovery payload field tables here — treat list item shape as **whatever the MCP returns**, validated against **`inputSchema`**.8182### Merchant discovery MCP tool (when listed)8384- **Which server:** Scan **all** configured MCP servers. The catalog tool may appear **only** on the discovery server (not on `gatepay-local-mcp`).85- **Tool name (expected):** **`discoveryResource`** — **must** match the **live** tool list **on the server that exposes discovery**. If the shipped name differs, use the **live** name only.86- **Behavior:** Returns a **paginated invokable resource list** only (HTTP and/or MCP-type entries with `accepts`, optional quote metadata). **No payment, no order placement** from this tool.87- **Arguments (logical field names — assemble values per live `inputSchema`; on any mismatch, `inputSchema` wins):**88 | Field | Required | Notes |89 |-------|----------|--------|90 | `resourceDes` | **Yes** | User intent / service description for fuzzy catalog match (natural language or keywords). |91 | `resourceType` | **Yes** | `http` or `mcp` (design default **`mcp`**). |92 | `pageNum` | No | Page index; design default **`1`**. |93 | `pageSize` | No | Page size; design default **`10`**. |94 | `tenantId` | No | Tenant id; design default **`GATE_PAY`**; omit if schema does not expose it. |95- **Response mapping:** Items typically include endpoint identity and **`accepts`** (with `outputSchema` / `input` for HTTP method, headers, body, or MCP `tool` + `inputSchema` + `transport`). Optional **`metadata`**: `quote_endpoint`, `quote_method`, `pricing_mode`, `quote_inputSchema` / `inputSchema` for dynamic pricing — use for **Quote vs main call order** above. Field names may appear as `resourceUrl` or `resource` depending on layer; **always** follow the **actual** tool response and map into `x402_place_order` / `x402_request` per their **`inputSchema`**.96- **If the tool is not listed:** Skip discovery calls; rely on user-provided URLs and conversation context.9798### When `discoveryResource` is mandatory (before merchant HTTP)99100When **some** connected MCP server **lists** the discovery catalog tool (often **`discoveryResource`** — use the **exact** name from that server’s tool list), and **all** of the following hold:1011021. The user expresses **purchase or order intent** for a **good or service** in natural language (e.g. “帮我买一双鞋”, “订一杯咖啡”, “买一个查天气的 API”) — including the same intent in other languages or colloquial phrasing.1032. The user message plus **conversation context** do **not** supply enough information to satisfy the merchant HTTP tool’s **`inputSchema`** on the **payment MCP** for **`x402_place_order`** or **`x402_request`** (typically missing or incomplete **`url` / `method` / `body`** or equivalent required fields) **without inventing** endpoints or parameters.104105Then the agent **MUST** call the discovery tool **first on the server that lists it** — build **`arguments` only from that tool’s `inputSchema`** (commonly map the user’s wording into **`resourceDes`**, set **`resourceType`** per schema, e.g. design default **`mcp`**). Then apply **Selection rules**, then continue **Workflow** from **Step 3–4** on the **payment MCP** with the chosen resource. **Do not** skip discovery by guessing merchant URLs or calling **`x402_place_order`** / **`x402_request`** with empty, placeholder, or hallucinated merchant targets.106107**Do not** apply this mandatory catalog step when: **no** connected server lists a discovery tool (use user URLs/context only); the user **already** provides a concrete merchant endpoint and parameters adequate for the HTTP tool’s schema; the session is **wallet / rail setup only** with **no** purchase flow; or the user chose **`gate_exchange`** only (**Gate Exchange path**).108109### Selection rules (filter → rank → tie-break)110111Apply in order; **filter** first, then **sort** what remains; if several options remain close, **ask the user** — do **not** silently choose.1121131. **Intent match:** `description`, type, and capabilities align with the user goal (e.g. flights vs food vs API).1142. **Constraints:** Network, currency, `maxPrice`, user-stated budget — drop resources that violate them.1153. **Callability:** Current environment can satisfy required **MCP transport** and/or **HTTP**; if not, drop or explain limitation.1164. **Parameter feasibility:** Given what the user already said, can required inputs (per merchant **`inputSchema`**) be filled? If a resource needs unknown critical fields and there is no safe default, **do not** select it **or** pick the easiest-to-complete option and **ask** for missing fields.1175. **Price path:** If the user insists on knowing price **before** deciding, prefer resources that expose **quote / dynamic** metadata; otherwise, among equally good options, prefer fixed-price or simpler paths.1186. **Tie-break:** If multiple resources remain similarly suitable, **present differences** (price band, latency, limits) and ask the user to pick (e.g. by number). **Never** auto-pick without user choice.119120### Quote vs main call order121122- **If** the discovery item or schema/metadata indicates **quote / dynamic pricing** (e.g. `dynamic`, `quote_endpoint`, or equivalent per MCP docs): **quote first** → show the user **currency, amount, and conditions** → ask whether to **continue with that merchant** → **after yes**, call the main service with parameters.123- **If** there is **no** quote path: **do not** invent a separate quote step; call the main service per contract. If cost appears **only** in **402**, parse **402** then run **mandatory pay confirmation** below.124- **No quote path does not mean skipping pay confirmation.**125126### Parameters, price visibility, and mandatory pay confirmation127128- **Parameters:** Before any merchant / `x402_place_order` call (or **`x402_request`** if that is the tool the **payment MCP** lists for HTTP/402), list **required** fields from the relevant **`inputSchema`**. If the user has not provided them, **complete via dialogue**. **Do not** call with empty or guessed values to “probe” the API.129- **Price visibility:** On a quote path, show **currency, amount, and applicability**. Without quote, after **402** or an explicit price from the merchant, summarize the **payment requirement** in the **user’s language**.130- **Pay confirmation (mandatory):** The user must see a **clear price** (quote result or **402** summary) first. Then the agent must ask again; the message should cover **how much**, **which asset/chain** (if known), and **which payment method** (if known). **Only after explicit consent** (e.g. “confirm pay”, “go ahead and pay”) invoke `x402_sign_payment`, split signature tools, or further steps in **`x402_request`** **only if that tool is listed** on the **payment MCP**. If the user **refuses** or is **unsure**, **stop** payment; offer another merchant or end.131- **Step 1 (Workflow)** “balance / intent” checks may be **merged** with this **see-price-then-confirm** step to **avoid double-asking**; prefer **one** clear confirmation after price is visible.132133### Mapping discovery to Step 4134135- **`url` / `method` / `body`** for `x402_place_order` (or **`x402_request`** when that is the HTTP tool on the server) come from the **user message**, **conversation context**, or **upstream discovery** (resource identity, `outputSchema`, or equivalent in the MCP response). **Map field names** to whatever the **tool `inputSchema`** requires.136137### Alignment with Workflow138139- **Step 4** remains merchant HTTP + **402** handling via `x402_place_order` or, when listed, `x402_request` (per server).140- **Steps 5–6** (MCP Wallet login if needed, sign / pay tools): run **only after** **mandatory pay confirmation** above (or immediately before first charge/sign, if merged with confirmation — **not** before the user has a clear price and agrees).141- **Same-server rule (payment):** For **one** merchant order / **one** **402** challenge, all **`x402_*`** steps (place order, sign, submit, auth for pay) use the **same payment MCP** server id (typically **`gatepay-local-mcp`**). **Discovery** may be invoked on a **different** server id; that does **not** break this rule—only **`x402_*`** must stay on one pay server for the order.142143### Wallet and rails (product rules)144145These **override** older wording elsewhere in this file where they conflict, **except** where a tool’s **`inputSchema`** requires a field (e.g. a URL argument): then **`inputSchema` wins** — supply values per schema and vendor docs.1461471. **`plugin_wallet`:** User configures **`PLUGIN_WALLET_TOKEN`** in MCP **`env`** only (full token **never** in chat). **Do not** require **`PLUGIN_WALLET_SERVER_URL`** in user env as a default rule; implementation may use a built-in endpoint. If **`inputSchema`** still requires a URL (or similar) for a call, fill it per schema/docs — not by contradicting required fields.1482. **`quick_wallet` (MCP Wallet):** **Do not** require `MCP_WALLET_API_KEY`, `MCP_WALLET_URL`, or similar “quick wallet API URL” env vars. Session comes from **tool-driven login** (`x402_quick_wallet_auth`, or **`x402_request`** when that build uses it for login, per schema); **after success**, update **`PAYMENT_METHOD_PRIORITY`** as in **Section 1** (MCP Wallet).1493. **Payment failure and rail switching:** Use only rails that are **actually configured** and available (`PAYMENT_METHOD_PRIORITY` + env + login state). If **only** `plugin_wallet` is configured and it **fails**: **do not** start **`quick_wallet`** login/auth **unless** `quick_wallet` is **already** configured **and** the user **explicitly** agrees to switch. If there is **no** next rail, explain the failure, suggest checking token/plugin setup, and **do not** invent other payment methods. With **multiple** rails, you may try the next configured rail on failure; **prefer** a brief user check before switching rails (unless product defines a pure technical retry exception).150151### Hard stops (non-exhaustive)152153- Discovery returns **nothing** usable and constraints cannot be relaxed → stop or relax and retry; do not fake merchants.154- **Required parameters missing** → **do not** call the merchant or pay tools.155- User **has not** explicitly agreed to pay after seeing price → **do not** call signature or payment tools.156- Plugin-only config and plugin call **failed** → **do not** auto-launch **unconfigured** `quick_wallet`.157158---159160## MCP host setup (discovery + payment)161162Many deployments use **two** MCP entries:163164| Role | Typical transport | Purpose |165|------|------------------|---------|166| **Payment MCP** | **stdio** — `npx -y gatepay-local-mcp` | **`x402_place_order`**, **`x402_request`**, **`x402_sign_payment`**, **`x402_quick_wallet_auth`**, other **`x402_*`**; wallet **`env`** (`PAYMENT_METHOD_PRIORITY`, `EVM_PRIVATE_KEY`, `PLUGIN_WALLET_TOKEN`, …) goes **here**. |167| **Discovery MCP** (optional) | **HTTP** remote URL (host-specific) | Payable-merchant **catalog** only (often tool name **`discoveryResource`** — confirm in the live tool list). **No** substitute for payment tools. |168169**Merge** both into the host’s MCP server map **without removing** unrelated MCPs. **Reload MCP** or restart the app after edits.170171### Example: `mcp.json` fragment (Cursor-style hosts)172173Project: `<project>/.cursor/mcp.json`. User-wide: `~/.cursor/mcp.json`. Under `mcpServers`:174175```json176{177 "gatepay-merchant-discovery": {178 "url": "https://openplatform.gateapi.io/pay-mcp-server/mcp"179 },180 "gatepay-local-mcp": {181 "command": "npx",182 "args": ["-y", "gatepay-local-mcp"],183 "env": {}184 }185}186```187188- **Keys** (`gatepay-merchant-discovery`, `gatepay-local-mcp`) may be renamed; keep them **stable** for the session so the agent targets the correct server for each tool.189- If your host requires a different shape for **remote** MCP (headers, `transport`, SSE), follow **current host docs**—the important part is registering **both** endpoints when your product uses split discovery + local pay.190- **Secrets** belong only in **`gatepay-local-mcp`**’s **`env`** (never in chat).191192---193194## MCP Server Connection Detection195196Before the first Gate Pay **`x402_*`** tool call **for payment or MCP Wallet auth**, and **before** mandatory merchant discovery when the flow needs a catalog, run the probes below (skip when the user has only received **Section 0.A** and has **not** yet chosen a rail).197198### A. Payment MCP (required for x402 pay / wallet auth)1992001. Scan configured servers for at least one tool whose name starts with **`x402_`** (e.g. `x402_place_order`, `x402_sign_payment`, `x402_quick_wallet_auth`). Some builds expose **`x402_request`** as the main HTTP/login tool instead of or alongside `x402_place_order`.2012. **Record** that host’s server key as the **payment server id** (e.g. `gatepay-local-mcp`).2023. **Verify** the tool list includes **`x402_place_order`** **or** **`x402_request`** **or** another documented **`x402_*`** entry for merchant HTTP/402.203204| Result | Action |205|--------|--------|206| Success | Use this **payment server id** for **all** **`x402_*`** calls this session for one order flow. |207| Failure | Show **Setup guide — payment MCP** below; do not guess pay parameters. |208209### B. Discovery MCP (required only if mandatory discovery applies)2102111. Scan **all** configured servers (including **not** the payment server) for the **catalog** tool — often **`discoveryResource`**; use the **exact** name from the live list.2122. **Record** that server key as the **discovery server id** (e.g. `gatepay-merchant-discovery`) when present.2133. If the user’s buy flow needs a catalog (**When `discoveryResource` is mandatory**) and **no** server lists a discovery tool → show **Setup guide — discovery MCP** below.214215| Result | Action |216|--------|--------|217| Catalog tool found | Call discovery **only** on **discovery server id**; map results into **`x402_place_order`** / **`x402_request`** on **payment server id**. |218| Catalog missing but mandatory | User must add discovery MCP or supply merchant URL/params manually. |219| Catalog not needed | Skip; user gave sufficient merchant fields or session is wallet-only / Exchange-only. |220221**Setup guide — payment MCP** (show at most once per session when **A** fails):222223```224Payment MCP (gatepay-local-mcp)225 - Add a stdio server: command "npx", args ["-y", "gatepay-local-mcp"], env { } (add PAYMENT_METHOD_PRIORITY / EVM_PRIVATE_KEY / PLUGIN_WALLET_TOKEN only when that rail is used — full secrets never in chat).226 - Cursor-style: merge into .cursor/mcp.json under mcpServers; reload MCP or restart the IDE.227 - Other hosts: register the same stdio command per product docs (VS Code MCP, Claude Code, OpenClaw, etc.).228```229230**Setup guide — discovery MCP** (show at most once per session when **B** is required but missing):231232```233Discovery MCP (example id: gatepay-merchant-discovery)234 - Add a remote MCP entry with your vendor URL, e.g. "url": "https://openplatform.gateapi.io/pay-mcp-server/mcp" (confirm exact URL and transport with your deployment).235 - Merge into the same mcpServers object as the payment MCP; reload MCP.236 - After reload, confirm the catalog tool appears (name may be discoveryResource or differ — use the live tool list).237```238239---240241## Wallet configuration procedure242243When the user wants to **configure, add, or change** a payment wallet for Gate Pay MCP, follow this flow. **Arguments for any MCP tool** come from that tool’s **`inputSchema`**.244245### 0. Entry246247#### 0.A Vague intent — **first reply only** (user-facing)248249If the user **only** asks to configure or add a wallet (e.g. “help me set up my wallet”, “configure wallet”) **without** naming a specific rail, **this turn** must be **short and plain-language**. Use the **same language as the user** (see **User-facing language** above).2502511. **Give three options** — for each, in plain language: **what it is**, **who it suits**, **roughly what they will do** — **one or two sentences** total per option. Contrast the three clearly (browser/device login vs extension/Open API style vs holding a key on the machine):252 - **MCP Wallet** (localized: Quick Wallet, **快捷钱包**, **gate钱包** / **Gate钱包**): **Sign in with Gate in a browser or device flow** (like logging into an app); best for users who want **no extension install** and are fine with **hosted login**. After they pick, you’ll drive **MCP tools** to complete login and then payment order.253 - **Plugin wallet:** Uses the Gate **browser extension** and an **Open API–style token** you keep in **local app settings** — good for users who **already use the Gate extension** and want payments **authorized from the plugin**. After they pick, you’ll point them to **get a token from the plugin side** and **paste it only into local config**, not into random sites.254 - **Private key (local signing):** They put **their own EVM private key** in **local config** and the MCP signs **on this machine** — for **advanced users** who **fully control a key** and accept **handling raw key material**. After they pick, you’ll tell them to fill **only local config**, **never** type the key into chat.2552562. **In this first message, do not include:** **`env` key names** (e.g. `EVM_PRIVATE_KEY`, `PLUGIN_WALLET_*`, `PAYMENT_METHOD_PRIORITY`), **MCP tool names** (e.g. `x402_quick_wallet_auth`, `x402_place_order`), **enum tokens** (`quick_wallet`, `plugin_wallet`), how to edit **`mcp.json`** (or other paths), or step-by-step technical procedures. **Defer all of that** until after they choose (**Section 0.B → Sections 1–3**).2572583. **Tone:** **No** long checklist, **no** env audit, **no** long security lecture. At most one short line, e.g. “After you choose, I’ll walk you through the next steps step by step.”2592604. Optionally **one line** for **Gate Exchange** pay if that MCP applies.2612625. **Close** by asking them to **pick one** (name or number). **Wait** for their choice (unless they already named a rail in the **same** first message).263264#### 0.B After the user **chooses** (or already named a rail)265266Continue with **Sections 1–3** / **Section 5** — here you **may** use env keys, tool names, `PAYMENT_METHOD_PRIORITY`, and file edits per those sections. For **MCP Wallet**, run **MCP Server Connection Detection** and record the server identifier.267268### 1. MCP Wallet (`quick_wallet`)269270**MCP Wallet** is one product channel; localized names (e.g. “Quick Wallet”) refer to the same rail. The MCP enum / env token remains **`quick_wallet`** — use that value in **`PAYMENT_METHOD_PRIORITY`** and in **`sign_mode`** (or equivalent fields) per **`inputSchema`**.271272**No user API key for this rail:** MCP Wallet **does not** use **`MCP_WALLET_API_KEY`**, does **not** ask users to apply for or paste a “quick wallet API key”, and is **not** the same as the plugin wallet’s Open API token. Credentials come from the **tool-driven login** (device / OAuth flow); the implementation may persist session data locally (e.g. under **`~/.gate-pay/`**) — follow the tool response, not chat guesses.273274**Order: tool auth first, then `PAYMENT_METHOD_PRIORITY` only on success.** Do **not** write or merge **`PAYMENT_METHOD_PRIORITY`** until MCP Wallet login has **succeeded** per the tool you actually have (see below).275276**Wrong flows (MCP Wallet):** Do **not** instruct users to set **`MCP_WALLET_API_KEY`**, **`MCP_WALLET_URL`** as a prerequisite, generic API keys, or **`EVM_PRIVATE_KEY`** for **this** rail. Do **not** conflate MCP Wallet with **plugin_wallet** token setup.277278**Which tool to call (read the live MCP tool list):**279280- If **`x402_quick_wallet_auth`** exists → use it first; **`arguments`** from **`inputSchema`** (e.g. optional `wallet_login_provider`: `gate` | `google`).281- If **`x402_quick_wallet_auth`** is **absent** but **`x402_request`** is **listed** and its **`inputSchema`** supports MCP Wallet login → trigger login via **`x402_request`** using fields for **`quick_wallet`** (e.g. `sign_mode`: **`quick_wallet`**, and any required `wallet_login_provider` / URL params). **Still** no user API key — same auth-first rule; then update **`PAYMENT_METHOD_PRIORITY`** only after success. *(Common **npm** `gatepay-local-mcp` single-tool builds often list **only** `x402_request` for both HTTP and MCP Wallet login—still **only if listed**.)*282- If the user chose **centralized_payment** and **`x402_gate_pay_auth`** is listed → follow that tool’s description and **`inputSchema`** for Gate Pay OAuth (separate from MCP Wallet login).283284**Definition — configured:** MCP Wallet is **fully configured** only after **login / device flow completes successfully** (tool response **success / ready**). Failed or abandoned login → **do not** update **`PAYMENT_METHOD_PRIORITY`**.2852861. **First — MCP tool:** Per **Which tool to call** above, invoke **`x402_quick_wallet_auth`**, or **`x402_request`** when listed and used for **`quick_wallet`** login per schema, on the **payment MCP** (see **MCP Server Connection Detection** §A). Guide the user through **MCP Wallet login** until the tool indicates **success / ready**.2872. **If login succeeds** (session established per tool response): **then** edit MCP **`env`**:288 - Add **`quick_wallet`** to **`PAYMENT_METHOD_PRIORITY`** (merge with existing list if any).289 - If **no other rail** was in **`PAYMENT_METHOD_PRIORITY`** before, you may set **`quick_wallet`** as the only or first entry per user’s stated intent at **Section 0.B**.290 - If **one or more other rails** were already in **`PAYMENT_METHOD_PRIORITY`**, **ask the user explicitly**: whether to make **`quick_wallet`** the **new default** (move to front). **Only if the user says yes** move it to the **first** position; **if no**, append **`quick_wallet`** without changing the current first token (**do not** reorder without confirmation — see **Section 4**).2913. **If auth / login fails** (error, timeout, user cancelled, non-ready): **do not** change **`PAYMENT_METHOD_PRIORITY`** or add **`quick_wallet`**. Explain next steps; user may retry.2924. After **successful** config writes, remind **reload MCP / restart the host** if needed.2935. **Disclose tool output after MCP Wallet login:**294 - **Private key / seed / exported signing secret:** **Never** paste the full value in **chat**. Print it to the **integrated terminal** (stdout) so it works on **macOS, Windows, and Linux**: prefer **`node -e`** / **`node -p`** or **`python -c`** to print a JSON-safe or plain-text line; if neither runtime is on `PATH`, write a **temporary file** under the project (**gitignored** path) and run a command that prints its path or contents to the terminal, then tell the user in **chat** (in their language) to **open the Terminal panel** and copy from there — still **do not** put the secret in chat.295 - **Public deposit / wallet addresses** (non-secret identifiers): **may** show in **chat** in full or summarized, in the **user’s language**, plus any short context the user needs.296 - **Other bulky or mixed responses:** Strip or redact secrets for chat; put **full private material** only in terminal/temp file as above; **addresses** stay chat-eligible.2976. Apply **Safety Rules**.298299### 2. Plugin wallet (`plugin_wallet`)3003011. **`PLUGIN_WALLET_TOKEN`:** Same **`plugin_wallet`** rules as **Wallet and rails** in **GatePay merchant discovery & agent orchestration** (token in **`env` only**, never full token in chat). **`PLUGIN_WALLET_SERVER_URL`:** optional per product defaults; if **`inputSchema`** requires a URL for a tool call, set it per schema/vendor docs.3022. **`PAYMENT_METHOD_PRIORITY`:** Add **`plugin_wallet`**. If this is the **second or later** rail, **ask** whether **`plugin_wallet`** should become the **default** (first in list). **Only** reorder to put it first if the user **confirms yes**; otherwise append without changing the current default.3033. **No** **`x402_quick_wallet_auth`** for this rail.3044. Remind **reload MCP** after `env` changes.305306### 3. Private key / local signing (`local_private_key`)3073081. In **`env`**, ensure **`EVM_PRIVATE_KEY`** exists for local signing. Use a **placeholder** in shared repos; the user fills the real value **only** in their local MCP config. **Never** collect or repeat a private key in chat.3092. Add any **`RPC_URL`** (or equivalent) variables **required** by the MCP package docs.3103. **`PAYMENT_METHOD_PRIORITY`:** Add **`local_private_key`**. If this is the **second or later** rail, **ask** whether **`local_private_key`** should become the **default**. **Only** move it first if the user **confirms yes**.3114. **No** **`x402_quick_wallet_auth`** for this rail unless the user also uses **MCP Wallet** (`quick_wallet`).3125. Remind **reload MCP** after `env` changes.313314### 4. Adding a second rail or changing default3153161. When the user **binds a second or additional** payment rail, **never** change the **first** token of **`PAYMENT_METHOD_PRIORITY`** (the current default) **without an explicit user choice**.3172. **Always ask** a clear yes/no (or pick-one) question in the **user’s language**, e.g. “Should **\<rail\>** become the default payment method?” Only if the user answers **yes**, move that rail’s token to the **front**. If **no**, append the new rail or keep existing order as appropriate **without** promoting it to default.3183. **MCP Wallet (`quick_wallet`):** Auth (**Section 1**) still comes **before** any **`PAYMENT_METHOD_PRIORITY`** change that **adds** **`quick_wallet`**; after successful login, apply the same **user-confirmed** rule for whether **`quick_wallet`** becomes default when other rails already exist.3194. Reordering among rails **already** listed (user wants to switch default only): **still** require **explicit confirmation** before editing which token is first.320321### 5. Gate Exchange (`gate_exchange`)322323If the user configures **exchange-only** pay: ensure **Gate Exchange MCP** is registered separately; set **`PAYMENT_METHOD_PRIORITY`** to include **`gate_exchange`** when that is the intended rail. Payment tools are **only** on the Exchange MCP — read each tool’s **`inputSchema`** there.324325---326327## Authentication State328329Payment and signing use whichever **wallet rail** the user has actually configured. Gate Pay MCP **`env`** is read from the **host’s MCP config** (path and format depend on Cursor, VS Code, Claude Code, etc. — not hardcoded here).330331- **`PAYMENT_METHOD_PRIORITY`**: If set in **`env`**, comma-separated; first token = default. Tokens: `quick_wallet`, `plugin_wallet`, `local_private_key`, `gate_exchange`. If **unset**, infer rails only from **non-empty** env keys / MCP session, or ask the user.332- **`local_private_key`**: Only when the user chose this rail: `EVM_PRIVATE_KEY` (and any RPC vars your MCP documents) must be set in **`env`** — never collect private keys in chat. If empty, this rail is unavailable.333- **`quick_wallet` (MCP Wallet):** **Setup** = **login success** via tool auth (**Section 1**: **`x402_quick_wallet_auth`** if present, else **`x402_request`** when listed and schema supports MCP Wallet login). **No** **`MCP_WALLET_API_KEY`** for users. Auth **before** writing **`PAYMENT_METHOD_PRIORITY`**; on failure, do **not** change that **`env`**. **Pay:** **Workflow** Step 5; on expiry, auth once then retry sign once.334- **`plugin_wallet`**: **`PLUGIN_WALLET_TOKEN`** in **`env`**; **`PLUGIN_WALLET_SERVER_URL`** not user-mandatory by default (see **Wallet and rails**). If **`inputSchema`** requires a URL argument, comply with schema. If the token is missing, this rail is unavailable.335- **`gate_exchange`**: Gate Exchange MCP configured separately; route there only when that MCP exists and user selects this rail.336337When a **second or additional** payment rail is added, **ask** whether the **default** should switch to the **newly bound** rail. **Do not** reorder **`PAYMENT_METHOD_PRIORITY`** until the user **explicitly agrees** to change the default.338339---340341## Gate Pay x402 Module (MCP Tools)342343### How to build `arguments` (mandatory)344345Before **every** MCP tool call in this flow:3463471. Locate the tool by **exact name** on the **correct server**: **discovery** tools on the **discovery server id** (if any); all **`x402_*`** on the **payment server id** (see **MCP Server Connection Detection**).3482. Read that tool's **`inputSchema`**: `properties`, `required`, `enum`, `description`.3493. Assemble `arguments` **only** from that schema and from **allowed** runtime values (user message, context, prior tool outputs).350351Do **not** copy parameter tables from this Skill; the **MCP `inputSchema` is the source of truth**. **Any conflict between this file and `inputSchema` → follow `inputSchema`.** If the MCP is not connected and schema is unavailable, complete MCP setup first or use vendor docs.352353### Tools (names to look up in MCP)354355**Merchant discovery:** When listed on **any** server, use **`discoveryResource`** (or the **exact** name on **that** server) and its **`inputSchema`**. Invoke on the **discovery** server, not on the payment server unless both tools are co-listed there. If absent everywhere, skip discovery calls.356357| Tool | Classification | Side-effect level | Purpose | Parameters |358|------|----------------|-------------------|---------|------------|359| `discoveryResource` | Read (list) | None (no pay) | GatePay catalog search — invokable resources + metadata only (**no pay/order**) | **`resourceDes`**, **`resourceType`** (`http`\|`mcp`), optional **`pageNum`**, **`pageSize`**, **`tenantId`** — **see live `inputSchema`** |360| `x402_place_order` | Read / HTTP | Merchant I/O only; no sign until later tools | Send merchant HTTP request; read status, headers, body | **See MCP `inputSchema` for `x402_place_order`** |361| `x402_request` | Mixed | **Low** when used for HTTP/login; **High** when schema drives combined sign/pay—still requires consent before any pay | **Only if listed** — some builds use this for HTTP + 402 + optional sign, and/or MCP Wallet login via `quick_wallet` / `sign_mode` | **See MCP `inputSchema` for `x402_request`** |362| `x402_quick_wallet_auth` | Write (session) | Establishes wallet session | **MCP Wallet** device/OAuth auth (`quick_wallet` rail) | **See MCP `inputSchema` for `x402_quick_wallet_auth`** |363| `x402_gate_pay_auth` | Write (session) | OAuth session for centralized pay | Gate Pay OAuth when user uses **centralized_payment** (Bearer token for submit per tool docs) | **See MCP `inputSchema` for `x402_gate_pay_auth`** |364| `x402_sign_payment` | Write (pay) | **High** — signs and submits payment | Parse 402, sign, submit payment (all-in-one) | **See MCP `inputSchema` for `x402_sign_payment`** |365| `x402_create_signature` | Write (sign) | **High** — produces signing material | Create signed payload / encoded signature only | **See MCP `inputSchema` for `x402_create_signature`** |366| `x402_submit_payment` | Write (pay) | **High** — submits payment | Submit payment with signature (split path) | **See MCP `inputSchema` for `x402_submit_payment`** |367| `x402_centralized_payment` | Write (pay) | **High** — centralized settlement when server exposes it | Account-center / centralized pay path per MCP (if listed) | **See MCP `inputSchema` for `x402_centralized_payment`** |368369Merchant **`url` / `method` / `body`** come from the **user message**, **conversation context**, or **upstream discovery** (resource / `outputSchema` / MCP discovery response — **map** per **`inputSchema370371…(truncated)