Skip to main content
Glama

x402-agent-mcp

Universal x402 agent MCP — discover and pay for any x402 endpoint on Base, Polygon, Arbitrum, Solana or Casper

What it does

An agent searches the directory, describes a service, then fetches its URL: the server pays the seller's 402 price with the operator's wallet and hands back the data. The agent never sees wallets, private keys or x402 protocol details — no API keys, no subscriptions, just a wallet.

Related MCP server: obolpay-x402-mcp

Quick start

git clone https://github.com/dchu3/x402-agent-mcp.git
cd x402-agent-mcp
npm install
npm run build

Point your MCP client config at the built server, passing the server's keys through env (only keys that exist in .env.example):

{
  "mcpServers": {
    "x402": {
      "command": "node",
      "args": ["/path/to/x402-agent-mcp/dist/index.js"],
      "env": {
        "X402_NETWORK_MODE": "mainnet",
        "SOLANA_PRIVATE_KEY": "<YOUR_SOLANA_PRIVATE_KEY>",
        "EVM_PRIVATE_KEY": "<YOUR_EVM_PRIVATE_KEY>",
        "CASPER_PRIVATE_KEY": "<YOUR_CASPER_PRIVATE_KEY>",
        "MAX_PAYMENT_PER_CALL": "0.50",
        "MAX_DAILY_SPEND": "10.00"
      }
    }
  }
}

Replace every <PLACEHOLDER> with your own value — never commit real key material. Only the chains you want to pay on need a key. The full annotated key set (RPC URLs with their public fallbacks, devnet mode, the optional cross-chain ceiling, the policy config) is .env.example; copy it to a .env your client loads, or inline the keys in the config block.

Before your first paid call: there is no default network — with a payment key loaded and X402_NETWORK_MODE unset, every paid call is refused with NETWORK_NOT_CONFIGURED before anything is fetched or signed. Set MAX_PAYMENT_PER_CALL and MAX_DAILY_SPEND to what you can afford, and make your first paid calls with a throwaway key.

Paid routes and prices rotate — confirm the route and price on the seller's GET /.well-known/x402 manifest before fetching.

Tools

Tool

Free/paid

Purpose

x402_search

Free

Search the endpoint directory by keyword, category or chain — ranked live-first, zero network calls.

x402_list_categories

Free

List all endpoint categories with counts.

x402_describe

Free

Get one service's paths, prices and schema.

x402_discover_url

Free

Discover an x402 service by URL (well-known files) and add it to the directory.

x402_health

Free

Check a service is live and answering 402.

x402_discover_urls

Free

Batch-discover several services in parallel.

x402_crawl_directory

Free

Crawl x402scan.com for new services and add them to the directory.

x402_check_payment

Free

Evaluate a prospective payment: decision, reason codes, limits, network mode, budget headroom. Never pays.

x402_probe_allowlist

Free

Refresh the recorded 402 liveness probes for the pinned endpoint set. Never pays.

x402_status

Free

Show every budget rail — unit, caps, spent/remaining today, outstanding holds, ledger path, configured USD rate. Read-only.

x402_inspect

Free

Inspect a 402 challenge or single offer — exact amounts, asset verdict, policy and budget verdicts — without paying or fetching.

x402_fetch

Endpoint price

Fetch an x402 endpoint and pay the 402 price — the only paying tool.

Safety and network defaults

  • The default payment policy is permissive — any x402 endpoint is payable up to the global caps — and every cap fails closed on a malformed value (it disables payments rather than widening them). Tighten via a config file pointed at by POLICY_CONFIG_PATH, or opt into a shipped profile with X402_POLICY_PROFILE=strict|standard — unset stays permissive (the behavior-compat default; see the policy engine reference for the three profiles).

  • Polygon and Arbitrum are opt-in (add them to the policy's networks.allowed); the Ethereum mainnet (eip155:1) is always refused.

  • Payment receipts come from the seller and are not verified on-chain (receipt_verified: false).

  • There is no default network: X402_NETWORK_MODE must be set explicitly before any paid call.

Documentation

  • Policy engine — decisions, reason codes, rule order, trust levels, the recipients and anomaly gates

  • Payments and budgets — spend accounting, the ledger and reservations, the payment-intent boundary, trust in receipts

  • Networks and network mode — the chain matrix, the no-default network mode, devnet, Casper, assets and USD pricing

  • Operations — usage examples, directory refresh recipes, CI, the security scan, tech stack

Disclaimer and licence

This software is experimental and provided "as is", without warranty of any kind. Use at your own risk. It initiates real cryptocurrency transactions that are irreversible. License: MIT.

Available Tools

8 tools
x402_crawl_directoryA

Crawl x402scan.com resources page to discover new x402 endpoints. Extracts service URLs, probes each for x402 support, and auto-adds confirmed services to the local directory. Returns summary of newly discovered services.

Inputs: max_results.

x402_describeB

Get detailed information about a specific x402 endpoint, including all available paths, methods, prices, and well-known discovery files.

Inputs: name (required).

x402_discover_urlA

Discover any x402 service by URL. Fetches /.well-known/x402 (payment details), /.well-known/ai-catalog.json (capabilities), and /llms.txt (agent summary). Returns a unified discovery object with chains, wallet, endpoints, and prices.

Inputs: url (required).

x402_discover_urlsA

Batch discover multiple x402 services in parallel. Provide a list of URLs, each is probed for /.well-known/x402 and ai-catalog.json. Returns a summary array.

Inputs: urls (required).

x402_fetchA

Fetch any x402-paid endpoint — handles 402 payment challenge automatically on Base, Solana or Casper. The agent never sees wallets or payment details. Just provide a URL and optional body.

Inputs: url (required), body, chain, method.

x402_healthA

Check if an x402 service is live and responding with 402 Payment Required. Verifies the service is operational before an agent pays for it.

Inputs: url, name.

x402_list_categoriesA

List all available x402 endpoint categories with counts.

Inputs: no named parameters.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 8 tools

    Disambiguation4/5

    Each tool has a clearly defined role covering category listing, searching, describing, discovering, health-checking, and fetching. The main overlap is between discover_url and discover_urls, which are the same operation in single and batch form, but this is a reasonable convenience rather than a true ambiguity.

    Naming Consistency4/5

    All tools share the x402_ prefix and most use a verb or verb_noun pattern (list_categories, search, describe, discover_url, crawl_directory, fetch). The exceptions are health, which is a noun, and two discover verbs with slightly different forms, but the overall convention remains predictable.

    Tool Count5/5

    Eight tools is well within the ideal range for this domain. Each tool addresses a distinct stage of discovering, evaluating, and consuming x402 services without excessive redundancy or missing core functions.

    Completeness5/5

    The toolset covers the full lifecycle from discovery (search, crawl, list categories), to verification (health, describe, discover_url), to interaction (fetch with automatic payment handling). No obvious dead ends or missing capabilities are apparent for an agent needing to work with x402 endpoints.

    Maintenance

    ActivityActive
    ResponsivenessLimited data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      An MCP server that enables AI agents to search, pay for, and call paid APIs using the x402 protocol, with automatic USDC settlement.
      2
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      MCP server that allows AI agents to discover and pay for thousands of APIs (x402 on Solana/Base) using a single key, with automatic payment handling and a federated catalog of machine-payable endpoints.
      221
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      MCP server that provides AI agents with pay-per-call access to a suite of tools (honeypot check, token market, DeFi yields, etc.) via USDC on Base using the x402 protocol.
      11 npm
      MIT