Skip to main content
Glama
CryptoAPIs-io

CryptoAPIs x402 Pay MCP

Official

@cryptoapis-io/mcp-x402-pay

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.

Run

node dist/cli.js            # stdio MCP server (no --api-key at startup; keys are per-tool-call)

Related MCP server: @arispay/payagent-mcp

Prerequisite — an agent walletId

x402_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):

curl -X POST https://ai.cryptoapis.io/x402/buyer/wallets \
  -H "x-api-key: $CRYPTOAPIS_API_KEY" -H "content-type: application/json" \
  -d '{"blockchain":"base","network":"eip155:8453","address":"0xYourAddress"}'
# → { "walletId": "…" }

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).

Tool: 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.

Tool: x402_discover

Browse 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.

Flow

  1. fetch(url). Not 402 → return it.

  2. 402 → pick an accepts entry (allowlist-aware), authorize via buyer /authorize → the signing artifact.

  3. Sign locally (@cryptoapis-io/mcp-signer evm_sign typed-data) → build the x402 PaymentPayload (wire scheme is always exact; the family is in network).

  4. Retry with the base64 X-PAYMENT header; return the paid response + the X-PAYMENT-RESPONSE settlement.

Security

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.

Available Tools

3 tools
x402_discoverA

Discover x402-gated APIs you can pay for — browse the facilitator's Bazaar catalogue of registered x402 resources, each with the price and payment terms it accepts. Use this BEFORE x402_pay whenever you need to FIND a paid endpoint rather than call one you were already given: the pay tool only fetches a URL you hand it, so this is the only way to locate a monetized API on your own. Returns { resources: [{ resource, type, x402Version, accepts: [{ scheme, network, amount, asset, payTo }], lastUpdated, metadata? }], pagination: { limit, offset, total } } — amount is in ATOMIC units (USDC 6-decimals: "10000" = $0.01), so convert before quoting a price to the user. PUBLIC: needs no API key, no wallet and spends nothing, so it is always safe to call. Filter with type (e.g. "http") and page with limit/offset. Then pass a chosen resource URL to x402_pay to actually buy it.

ParametersJSON Schema
NameRequiredDescriptionDefault
typeNoFilter by resource type, e.g. "http". Omit to list every type.
limitNoMax results to return, 1-100 (default 20). The facilitator clamps out-of-range values rather than erroring.
offsetNoHow many results to skip, for paging (default 0). Use with `pagination.total` from a previous call.
facilitatorBaseUrlNoOverride the facilitator base URL (default https://ai.cryptoapis.io/x402/merchant). Useful against QA/local.

TDQS

A4.7/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and succeeds. It discloses that the call is 'PUBLIC: needs no API key, no wallet and spends nothing, so it is always safe to call,' and warns that `amount` is in ATOMIC units (with a conversion example). These are behavioral traits beyond what the schema/annotations convey, essential for an agent to safely invoke the tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is moderately long but each sentence earns its place: purpose, sibling differentiation, return structure, atomic-unit caveat, safety, and filtering/pagination guidance. It is front-loaded with the main purpose and flows logically. No redundancy or filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the absence of an output schema, the description fully compensates by detailing the return shape ({ resources: [...], pagination: {...} }), explaining atomic unit conversion, and noting safety. It also covers filtering and pagination usage. For a moderately complex tool with no annotations or output schema, this description is comprehensive enough for correct selection and invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3. The description mentions 'Filter with `type` (e.g. "http") and page with `limit`/`offset`,' but this largely restates the schema descriptions and adds minimal new meaning. It does contextualize parameters in the workflow, but doesn't go beyond what the schema already provides, so it remains at baseline.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Discover x402-gated APIs you can pay for — browse the facilitator's Bazaar catalogue of registered x402 resources.' It uses a specific verb ('Discover') and resource, and explicitly distinguishes from its sibling x402_pay by noting that the pay tool only fetches a URL you already have, making this the only way to locate a paid endpoint independently.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It gives explicit guidance: 'Use this BEFORE x402_pay whenever you need to FIND a paid endpoint rather than call one you were already given.' It also provides follow-up direction ('Then pass a chosen `resource` URL to x402_pay') and clarifies exclusions (when you already have a URL, use pay instead). This fully covers when-to-use and alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

x402_payA

Fetch an HTTP resource and, if it returns 402 Payment Required, pay it automatically with x402 and return the paid response. On a 402 it: parses the merchant's price, authorizes via the CryptoAPIs buyer /authorize, signs the payment LOCALLY (non-custodial — the key never leaves this process), and retries with the X-PAYMENT header. Returns { status, paid, body, settlement? }. This is for HTTP URLs — to pay a paid MCP TOOL on another server, use x402_pay_tool instead. Supported today: EVM (eip712, e.g. Base USDC) and Solana. Tron, UTXO (bitcoin/ltc/doge/dash/bch/zcash), Kaspa and XRP are UPCOMING — wired but not yet enabled, and paying on them returns a clear coming-soon (family_not_yet_supported) result. Set CRYPTOAPIS_API_KEY + X402_WALLET_ID once, plus the signing key(s) for the chain(s) you pay on: X402_PRIVATE_KEY (EVM hex), X402_SVM_SECRET (base58). A scheme with no configured key errors cleanly (never mis-signs). Env vars keep keys OUT of tool-call logs. Use allowedNetworks to restrict chains, maxAmount as a per-call spend cap, and allowedHosts to restrict WHICH SITES may be paid (a url outside the list is refused before any network call; set X402_ALLOWED_HOSTS in the MCP config to pin it outside the model's reach). SECURITY: this tool holds spending keys — use only in trusted local environments, and prefer pinning allowedHosts + maxAmount via env for unattended runs.

ParametersJSON Schema
NameRequiredDescriptionDefault
urlYesThe (possibly paywalled) resource URL to fetch
bodyNoRequest body (string; set content-type via headers if needed)
apiKeyNoYour CryptoAPIs API key with the X402_BUYER feature (used only to call the buyer /authorize). Falls back to the CRYPTOAPIS_API_KEY env var — set it once and omit this.
methodNoHTTP method (default GET)
headersNoExtra request headers
tronKeyNoTron private key (hex). Falls back to X402_TRON_KEY, then to privateKey/X402_PRIVATE_KEY (same secp256k1 curve).
utxoWifNoUTXO private key in WIF format — signs utxo-transaction payments (bitcoin/ltc/doge/dash/bch/zcash). Falls back to X402_UTXO_WIF.
xrpSeedNoXRP secret/seed (base58, e.g. s...) — signs xrp-transaction payments. Falls back to X402_XRP_SEED.
kaspaKeyNoKaspa private key (hex, 32 bytes) — signs kaspa-transaction payments. Falls back to X402_KASPA_KEY.
walletIdNoThe CryptoAPIs buyer-service wallet RECORD ID (the id returned by POST /wallets) — NOT the on-chain address; passing an address returns wallet_not_found. Falls back to the X402_WALLET_ID env var. Create one first (once per blockchain+network): POST https://ai.cryptoapis.io/x402/buyer/wallets with {blockchain, network (CAIP-2 id like eip155:8453 or solana:<genesisHash> — NOT a bare name), address (your public address; required for Solana/Kaspa)} → returns walletId.
maxAmountNoOptional safety cap: refuse to pay if the required atomic-unit amount exceeds this
svmSecretNoSolana secret key, base58-encoded (64-byte keypair secret) — signs svm-transaction payments. Falls back to X402_SVM_SECRET.
privateKeyNoEVM private key (hex, 0x optional) — signs the eip712 (EVM) payment, and Tron by default. Falls back to X402_PRIVATE_KEY. SECURITY: trusted local environments only.
allowedHostsNoRestrict WHICH HOSTS may be paid, e.g. ["api.acme.com"] (a leading dot matches subdomains: ".acme.com"). A url outside the list is refused BEFORE any network call. Falls back to the X402_ALLOWED_HOSTS env var (comma-separated) — set it there to pin the allowlist OUTSIDE the model's reach, so a prompt-injected url cannot widen it.
buyerBaseUrlNoOverride the buyer service base URL (default https://ai.cryptoapis.io/x402/buyer)
allowedNetworksNoRestrict which CAIP-2 networks to pay on (e.g. ["eip155:8453"])

TDQS

A4.8/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden and does so well: it details the 402 sequence (parse price, authorize, sign locally non-custodially, retry with X-PAYMENT), the return shape {status, paid, body, settlement?}, supported vs upcoming chains, the exact behavior on unsupported families (family_not_yet_supported), clean error handling for unconfigured keys, and a security warning about holding spending keys.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Purpose and 402 behavior are strongly front-loaded, followed by alternatives, chain support, config, and security in a logical order. It is long for a description, and the SECURITY warnings and env-var reiterations appear twice, so a small amount of trimming is possible.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Despite 16 parameters, no output schema, and no annotations, the description covers what an agent needs: the return shape, the payment flow, supported/upcoming networks, error semantics, required configuration, and safety controls. Nothing material for correct invocation is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3. The description goes beyond the schema by framing allowedNetworks, maxAmount, and allowedHosts as a coherent safety posture, explaining that env-pinning keeps the allowlist outside the model's reach, and describing the CRYPTOAPIS_API_KEY/X402_WALLET_ID setup once. This adds genuine framing value, though much of the per-parameter detail is already in the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb (fetch) and resource (HTTP resource), then specifies the conditional behavior (pay on 402 and return the paid response). It explicitly distinguishes itself from the sibling x402_pay_tool (HTTP URLs vs paid MCP tools), so an agent can route without opening either schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly names the alternative (x402_pay_tool for paid MCP tools on another server) and the condition that selects it. It also gives when-to-use guidance for the safety controls (allowedNetworks, maxAmount, allowedHosts) and the trusted-local-environment precondition for holding spending keys.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

x402_pay_toolA

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
apiKeyNoYour CryptoAPIs API key with the X402_BUYER feature (used only to call the buyer /authorize). Falls back to the CRYPTOAPIS_API_KEY env var.
serverYesThe upstream MCP server to call, launched over stdio. It is started for this call and shut down afterwards.
tronKeyNoTron private key (hex). Falls back to X402_TRON_KEY, then to privateKey/X402_PRIVATE_KEY.
utxoWifNoUTXO private key in WIF format. Falls back to X402_UTXO_WIF.
xrpSeedNoXRP secret/seed. Falls back to X402_XRP_SEED.
kaspaKeyNoKaspa private key (hex). Falls back to X402_KASPA_KEY.
toolNameYesThe name of the tool to call on that server
walletIdNoThe CryptoAPIs buyer-service wallet RECORD ID (from POST /wallets) — NOT the on-chain address. Falls back to the X402_WALLET_ID env var.
argumentsNoArguments to pass to that tool
maxAmountNoSafety cap: refuse to pay if the required atomic-unit amount exceeds this
svmSecretNoSolana secret key, base58-encoded — signs svm-transaction payments. Falls back to X402_SVM_SECRET.
privateKeyNoEVM private key (hex, 0x optional) — signs the eip712 payment, and Tron by default. Falls back to X402_PRIVATE_KEY. SECURITY: trusted local environments only.
buyerBaseUrlNoOverride the buyer service base URL (default https://ai.cryptoapis.io/x402/buyer)
allowedNetworksNoRestrict which CAIP-2 networks to pay on (e.g. ["eip155:8453"])

TDQS

A4.8/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden — and it does: it discloses the challenge/retry flow, non-custodial local signing ('the key never leaves this process'), where PaymentRequired is read from (structuredContent with content[0].text fallback), that the upstream server is launched over stdio and shut down per call, supported vs coming-soon chains, and an explicit SECURITY warning about holding spending keys.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Dense but every sentence earns its place — flow, return shape, credentials, supported chains, and security are all load-bearing for a 14-parameter tool. Slightly over-packed with parentheticals, but front-loaded and non-redundant.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema present, the description supplies the return contract ('{ paid, result, settlement? }') and where the settlement receipt arrives (_meta['x402/payment-response']), plus credential and network coverage. Given the tool's complexity and nested server object, an agent has everything needed to call it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3 and the schema already documents fallbacks and formats. The description adds meaning on top by naming the credential set (CRYPTOAPIS_API_KEY, X402_WALLET_ID, X402_PRIVATE_KEY/X402_SVM_SECRET) and framing allowedNetworks/maxAmount as guardrails, which tells the agent how to use them defensively.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb+resource ('call a tool on another MCP server and pay it automatically with x402') and explicitly positions itself against the sibling x402_pay ('MCP-transport twin... use x402_pay for an HTTP url, and THIS for a paid tool on another MCP server'). An agent can unambiguously separate it from x402_pay and x402_discover.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives an explicit selection rule against the closest alternative and a clear exclusion ('use x402_pay for an HTTP url'), plus a security scoping condition ('use only in trusted local environments'). Nothing about when-to-use is left to inference.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 1 tool updatev0.5.3
    • Addedx402_pay_tool
  2. 2 tool updatesv0.3.0
    • First observedx402_discover
    • First observedx402_pay

TDQS

A4.6/5.0

Scored across 3 tools

Disambiguation5/5

Each tool has a clearly distinct purpose: x402_pay for HTTP URLs, x402_pay_tool for paid MCP tools on other servers, and x402_discover for finding paid endpoints. The descriptions explicitly cross-reference each other ('use x402_pay for an HTTP url, and THIS for a paid tool') to eliminate misselection.

Naming Consistency4/5

All three share a consistent x402_ prefix and snake_case style, which is highly predictable. The only minor deviation is that pay_tool adds a qualifier rather than following a strict verb_noun pattern like the other two, but overall naming is coherent.

Tool Count4/5

Three tools is on the lean side but each earns its place in a narrowly scoped payment domain. The surface is well-scoped with no redundancy, though a small set of supporting tools (e.g. balance/status) could round it out.

Completeness4/5

Core payment lifecycle is covered: discovery, HTTP payment, and MCP-tool payment, with settlement receipts returned. Minor gaps exist around checking wallet balance, payment history, or supported-network queries, which agents can work around but would strengthen the surface.

Maintenance

ActivityMaintained
ResponsivenessUnresponsive

Related MCP Connectors

Related MCP Servers