Skip to main content
Glama

Got HTTP 402? Fund your x402 wallet from any chain

fund_x402

Hit a '402 Payment Required' (x402) paywall but your funds are on another chain or token? Paste the 402 response (body JSON or base64 PAYMENT-REQUIRED header, x402 v1 or v2). Swap Ripper reads the invoice, picks the right network and token (e.g. USDC on Base), and tops up YOUR wallet there with an exact amount, paid from any token on any chain (SOL, ETH, BTC, USDC on Solana...). Default top-up ~$5 so dozens of future 402 calls need no swap. Call with only payment_required to decode the invoice and see options; add pay_with_token, wallet and refund_address to get a deposit address.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "payment_required": "<payment_required>"
    },
    "name": "fund_x402"
  }
}

Input Schema

NameRequiredDescriptionDefault
testNoTest mode: true = no real money. You get a fake deposit address that completes by itself in ~15s, so you can test status, invoices, receipts and webhooks for free.
speedNoOptional. Default 'best_price': Swap Ripper quotes two networks at once and uses whichever is cheaper for you (and the other if one fails); the reply's route_choice shows both. 'fast' forces the ~seconds Relay route.
walletNoYOUR address on the invoice's network (the wallet your x402 client signs with).
referrerNoOptional: your NEAR account (e.g. 'myagent.near'). You earn 1/3 of the service fee on every swap routed with it. The user pays the same.
request_idNoRecommended: your own unique ID for this payment (e.g. a UUID). Retrying with the same request_id returns the SAME payment instructions, so you never pay twice.
top_up_usdNoMinimum top-up in USD (1-500, default 5). The invoice amount is used if larger.
slippage_bpsNoMax slippage in basis points (default 100 = 1%, range 10-500).
pay_with_chainNoChain you pay from, e.g. 'solana'.
pay_with_tokenNoToken you hold and will pay with, e.g. 'SOL' or 'USDC'.
prefer_networkNoOptional: which of the invoice's networks to fund, e.g. 'base' or 'solana'.
refund_addressNoYour address on the paying chain, for automatic refunds.
payment_requiredYesThe 402 response body (object or JSON string) or the base64 PAYMENT-REQUIRED header value.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changed
    • addedInput schema / properties / request_id
      Added value: +{
      +  "description": "Recommended: your own unique ID for this payment (e.g. a UUID). Retrying with the same request_id returns the SAME payment instructions, so you never pay twice.",
      +  "type": "string"
      +}
    • addedInput schema / properties / speed
      Added value: +{
      +  "description": "Optional. Default 'best_price': Swap Ripper quotes two networks at once and uses whichever is cheaper for you (and the other if one fails); the reply's route_choice shows both. 'fast' forces the ~seconds Relay route.",
      +  "enum": [
      +    "best_price",
      +    "fast"
      +  ],
      +  "type": "string"
      +}
    • addedInput schema / properties / test
      Added value: +{
      +  "description": "Test mode: true = no real money. You get a fake deposit address that completes by itself in ~15s, so you can test status, invoices, receipts and webhooks for free.",
      +  "type": "boolean"
      +}
  2. First observed

TDQS

A4/5.0
Behavior4/5

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

With annotations already marking it non-read-only, open-world, non-destructive, and not idempotent, the description adds useful context: test mode uses fake money, default top-up is about $5, and repeating the same request_id returns the same payment instructions. It does not cover permissions, failure handling, or refund timing.

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?

The description is front-loaded and dense with relevant information for an agent, but the single paragraph includes some sales-oriented wording and could be organized more cleanly into invocation steps.

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

Completeness4/5

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

For a 12-parameter payment tool with no output schema, it explains the key invocation paths, test mode, retry safety, and deposit-address behavior. It stops short of fully describing the response shape and the post-deposit step needed to confirm funding.

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 schema already documents the parameters. The description adds meaningful usage semantics for the main flow, request_id retry behavior, test mode, speed routing, and the default top-up amount, though it does not explain every parameter.

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

Purpose4/5

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

The description states a specific verb and resource: it tops up the user's x402 wallet by reading a 402 invoice and swapping from another chain/token. This is clearly distinct from generic swap or payment tools, but it does not explicitly name a sibling alternative or contrast itself with pay/pay_exact.

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

Usage Guidelines4/5

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

It gives clear usage modes: call with only payment_required to decode the invoice, then add pay_with_token, wallet, and refund_address to get a deposit address. It does not state when not to use the tool or compare it against alternatives such as pay_exact.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.