x402_pay_tool
Call a tool on another MCP server, handle x402 payment requirements with local signing, and return the paid result.
Instructions
Call a TOOL on another MCP server and, if that tool requires payment, pay it automatically with x402 and return the paid result. This is the MCP-transport twin of x402_pay: use x402_pay for an HTTP url, and THIS for a paid tool on another MCP server. On a challenge it reads the PaymentRequired (from structuredContent, falling back to content[0].text), authorizes via the CryptoAPIs buyer /authorize, signs LOCALLY (non-custodial — the key never leaves this process), and retries the tool call once with the payment in _meta["x402/payment"] (a raw object, no base64 — MCP carries structured JSON natively). Returns { paid, result, settlement? }; the settlement receipt comes back in _meta["x402/payment-response"]. The upstream server is launched over stdio for the call and shut down afterwards. Same credentials and keys as x402_pay: CRYPTOAPIS_API_KEY + X402_WALLET_ID, plus X402_PRIVATE_KEY (EVM) / X402_SVM_SECRET (Solana). Supported today: EVM (eip712) and Solana; Tron, UTXO, Kaspa and XRP return a clear coming-soon result. Use allowedNetworks and maxAmount as guardrails. SECURITY: this tool holds spending keys and launches the process you name — use only in trusted local environments.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| apiKey | No | Your CryptoAPIs API key with the X402_BUYER feature (used only to call the buyer /authorize). Falls back to the CRYPTOAPIS_API_KEY env var. | |
| server | Yes | The upstream MCP server to call, launched over stdio. It is started for this call and shut down afterwards. | |
| tronKey | No | Tron private key (hex). Falls back to X402_TRON_KEY, then to privateKey/X402_PRIVATE_KEY. | |
| utxoWif | No | UTXO private key in WIF format. Falls back to X402_UTXO_WIF. | |
| xrpSeed | No | XRP secret/seed. Falls back to X402_XRP_SEED. | |
| kaspaKey | No | Kaspa private key (hex). Falls back to X402_KASPA_KEY. | |
| toolName | Yes | The name of the tool to call on that server | |
| walletId | No | The CryptoAPIs buyer-service wallet RECORD ID (from POST /wallets) — NOT the on-chain address. Falls back to the X402_WALLET_ID env var. | |
| arguments | No | Arguments to pass to that tool | |
| maxAmount | No | Safety cap: refuse to pay if the required atomic-unit amount exceeds this | |
| svmSecret | No | Solana secret key, base58-encoded — signs svm-transaction payments. Falls back to X402_SVM_SECRET. | |
| privateKey | No | EVM private key (hex, 0x optional) — signs the eip712 payment, and Tron by default. Falls back to X402_PRIVATE_KEY. SECURITY: trusted local environments only. | |
| buyerBaseUrl | No | Override the buyer service base URL (default https://ai.cryptoapis.io/x402/buyer) | |
| allowedNetworks | No | Restrict which CAIP-2 networks to pay on (e.g. ["eip155:8453"]) |