MCP server that pays x402-gated HTTP endpoints β fetch, and on a 402 authorize, sign, retry
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
π‘ Paste into ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows)
This is the BUYER side of x402 β the tool an agent uses to spend (pay for a resource). Merchants who want to charge for an API use the middleware SDK (
@cryptoapis-io/x402-merchant-sdk), not an MCP tool.
An MCP server that lets an AI agent find and pay x402-gated HTTP endpoints.
x402_pay β fetches a URL and, if the server returns 402 Payment Required, authorizes the payment
via the CryptoAPIs buyer service, signs locally, retries, and returns the paid response.x402_discover β browses the facilitator's catalogue of x402 resources and their prices, so an agent
can find a paid API instead of only calling one it was handed.Non-custodial: the private key is passed per request and never leaves the process (no HTTP server β stdio only).
Supported today: EVM (eip712, e.g. Base USDC) and Solana. Tron, Bitcoin/UTXO, XRP and Kaspa are
upcoming β wired but not yet enabled; paying on them returns a clear family_not_yet_supported
("coming soon") result.
walletIdx402_pay pays from a CryptoAPIs agent wallet (walletId). Create one ONCE per blockchain+network
before paying β a single POST to the buyer API returns the id (non-custodial: you register only your
PUBLIC address):
network MUST be the CAIP-2 id (eip155:8453, solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp, β¦), not a
bare name β and exactly one of address (any chain; required for Solana/Kaspa) or xpub
(xpub-capable chains). A malformed body returns a clear 400 malformed_request. Set the returned id as
X402_WALLET_ID (or pass walletId).
x402_pay| Input | Required | Description |
|---|---|---|
url | β | the (possibly paywalled) resource |
apiKey | β | your CryptoAPIs key (X402_BUYER feature) β only used to call the buyer /authorize |
walletId | β | the wallet record id from POST /wallets (a registry _id) β NOT the on-chain address (an address gets wallet_not_found) |
privateKey | β | the wallet's EVM key β signs locally, never sent anywhere |
method/body/headers | the request to make | |
allowedNetworks | restrict which CAIP-2 networks to pay on | |
maxAmount | safety cap β refuse if the required atomic-unit amount exceeds it | |
allowedHosts | restrict WHICH SITES may be paid, e.g. ["api.acme.com"] (leading dot = subdomains). A url outside the list is refused before any network call. Falls back to X402_ALLOWED_HOSTS (comma-separated) β pin it there to keep the allowlist outside the model's reach |
Returns { status, paid, body, settlement? }. On a 402 with no acceptable option (or over maxAmount),
paid:false with a reason β nothing is signed or paid.
x402_discoverBrowse the x402 "Bazaar" β the registered x402 resources and what each charges (spec Β§8).
| Input | Required | Description |
|---|---|---|
type | filter by resource type, e.g. "http" | |
limit | page size, 1β100 (default 20) | |
offset | rows to skip, for paging (default 0) | |
facilitatorBaseUrl | override the facilitator (QA/local) |
Returns { resources: [{ resource, type, x402Version, accepts, lastUpdated, metadata? }], pagination }.
Public β no API key, no wallet, spends nothing, so it is always safe to call. Note accepts[].amount
is in atomic units (USDC 6-decimals: "10000" = $0.01) β convert before quoting a price to a user.
Pass a chosen resource to x402_pay to actually buy it.
fetch(url). Not 402 β return it.accepts entry (allowlist-aware), authorize via buyer /authorize β the signing artifact.@cryptoapis-io/mcp-signer evm_sign typed-data) β build the x402 PaymentPayload
(wire scheme is always exact; the family is in network).X-PAYMENT header; return the paid response + the X-PAYMENT-RESPONSE settlement.The private key is a tool parameter and may be logged by MCP clients or stored in conversation
history β use only in trusted local environments. This mirrors @cryptoapis-io/mcp-signer.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/mcp-x402-pay)<a href="https://allmcps.com/mcp/mcp-x402-pay"><img src="https://allmcps.com/api/badge/mcp-x402-pay?style=directory" alt="Mcp X402 Pay on AllMCPs" /></a>