Utvecklingsportal
Tema

A2MCP Guide#

What Is A2MCP?#

A2MCP (Agent-to-MCP) is one of the service types ASPs offer on OKX.AI, mainly for standardized tasks. It can be free or charged per call. To become an A2MCP ASP, you shape your service's endpoint into one of two compliant forms:

① Free endpoint — returns the result directly on call; no billing, no x402.

② x402 pay-per-call endpoint — uses the x402 protocol: on each call it first returns a standard 402 Payment Required payment challenge, and after the user pays, the request is replayed to fetch the result.

Is Your Service a Good Fit for A2MCP?#

The test: can your capability be expressed as "take some parameters, return a clear result"?

TraitWhat it meansExamples
Has structured data or capabilityReturns a clear result via an interface, not manual laborWeather, FX rates, maps, stock quotes, business registry data
The action can be tool-ifiedEach capability fits a function with parametersLook up an order, generate an invoice, translate
Verifiable, low-risk resultsDeterministic return valuesRead-only lookups are the easiest to start with
Recurring value, billableUsers call it repeatedly; you can charge per call or monthlyData APIs, knowledge bases, vertical search

Core Preparation for A2MCP#

  1. 1
    Make sure your service has an API

    At its core, MCP is "the AI calling your API," so your service needs a programmatically callable interface first (skip this step if you already have an API).

    How to do it (hand to a developer, or pick one of these paths):

    • Standard build: stand up a simple interface with the mainstream framework FastAPI, Official tutorial.
    • Have a database, don't want to write code: turn a database into a REST API with PostgREST.
    • Have an internal API / SaaS: expose it through a cloud API gateway (most major cloud providers offer one).
  2. 2
    Make your endpoint compliant (free or x402)

    Decide first whether your service is free or paid, then take one of two paths:

    Option 1: Free service

    Just have your endpoint return the result directly on call (HTTP 200) — no x402 needed.

    Option 2: Pay-per-call (x402)

    Billing is driven by x402. There are two ways to do it — we recommend the OKX Payment SDK:

    • Option A (recommended): use the OKX Payment SDK

    OKX provides a server-side SDK (@okxweb3/x402-*, for Node.js / Go / Rust / Java / Python). Attach the payment middleware to your endpoint, configure the receiving address, network, and price, and the SDK handles the 402 response and on-chain verification — you only write the business logic. Full steps: Integrate via SDK.

    • Option B: implement it yourself

    If you'd rather build it yourself, you must do the full x402 server-side work: return a compliant 402, verify the payment header (EIP-3009 signature, amount / nonce / validity), and handle replay protection and settlement. See the field spec in the example below.

    • Standard 402 challenge example (v2)

    ⚠️ The JSON below is the challenge structure example: for v2, base64-encode it and put it in the PAYMENT-REQUIRED response header — that header is what the marketplace validates, not the body. It is recommended to use OKX Payment SDK, which will be automatically placed in the correct position..

    json
    {
      "x402Version": 2,
      "resource": {
        "url": "https://<your real public endpoint>/...",
        "description": "<your service description>",
        "mimeType": "application/json"
      },
      "accepts": [
        {
          "scheme": "exact",
          "network": "eip155:196",                                     // CAIP-2, 196 = X Layer
          "asset": "0x779ded0c9e1022225f8e0630b35a9b54be713736",       // official settlement stablecoin on X Layer, USDT0
          "amount": "10000",                                            // min units, decimals=6, 10000 = 0.01
          "payTo": "0x<your real X Layer wallet>",                     // your receiving address
          "maxTimeoutSeconds": 300,
          "extra": { "name": "USD₮0", "version": "1" }                 // USD₮0 config
        }
      ]
    }
    
  3. 3
    Get a public server and a domain

    Whether free or paid, to let others call your endpoint remotely you need a public server that is reachable worldwide and serves over HTTPS — the endpoint must be an HTTPS address tied to a domain. You're not tied to any particular vendor; any major cloud provider works. Choose a node by these requirements:

    Your audienceWhat to chooseICP filing
    Both inside and outside China (top pick)A lightweight / cloud server in a Hong Kong nodeNot required
    Mainly overseasA node in Singapore / Tokyo or similarNot required
    No ops, want global accelerationA serverless edge platformN/A
    • Every major cloud provider offers these nodes — pick one by price and your familiarity. For the serverless route, see this general deployment guide.

    • If your service needs to call third-party AI APIs such as OpenAI/Gemini/Claude, please do not use Hong Kong servers, as these AI vendors will refuse connections from Hong Kong nodes. It is recommended to use servers in supported regions such as Singapore/Tokyo/US instead.

  4. 4
    Deploy and set up HTTPS

    Deploy the API from Step 2 onto the server from Step 3, point your domain at the server, and set up an HTTPS certificate. You'll end up with a public address (the endpoint), the entry point others use to call your service.

    • Buying the server, logging in, opening ports, and DNS records: all done in your chosen cloud provider's own console, the layout is similar across vendors.
  5. 5
    Self-check your endpoint

    Always self-check before registering as an ASP — a non-compliant endpoint won't pass review. Send a request to your endpoint with curl -i:

    • Free type: should return HTTP 200 with the result directly.
    • x402 paid type: with no payment header, should return HTTP 402 (response header carries PAYMENT-REQUIRED, or the body carries x402Version).
    bash
    curl -i -X POST https://your-domain/your-path
    # Free type  ✅ expected: HTTP 200 + result
    # Paid type  ✅ expected: HTTP 402 + PAYMENT-REQUIRED
    
  6. 6
    Register on OKX.AI