開発者ポータル
テーマ

A2MCP Integration Guide#

What is A2MCP?#

A2MCP (Agent-to-MCP) is a service type on OKX.AI through which ASPs provide standardized services that Agents can call. Services can be free or charge per call through x402.

A2MCP services fall into two categories based on endpoint type:

Endpoint typeUse caseSource of call definitions
MCP endpointSupports the MCP protocol and enables discovery and invocation of one or more ToolsTool definitions returned by tools/list
HTTP endpointA regular HTTP APIEndpoint, request method, parameter definitions, and request examples

Confirm that your service is suitable for integration#

Services suitable for A2MCP can usually be clearly expressed as “input parameters → explicit results,” with invocation and delivery handled programmatically.

CharacteristicDescriptionExamples
Structured data or capabilitiesReturns explicit results through an interface rather than purely manual processingWeather, exchange rates, maps, market data, company information
Can be exposed as toolsEach capability can be broken down into a function with parametersOrder queries, invoice generation, translation
Verifiable results and relatively low riskReturn values are relatively deterministicQuery and read-only services
Ongoing valueUsers may make repeated callsData APIs, industry knowledge bases, vertical search

Preparation before integration#

Choose the endpoint type you want to integrate, then complete the corresponding 4 preparation steps.

  1. 1
    Build an MCP Server

    Use an official MCP SDK to create a Server and register your business capabilities as Tools. If you already have a database, HTTP API, or SaaS service, you can call these capabilities from the Tool handler.

    Recommended learning order:

    Official resourceWhat it helps you understand
    Build an MCP serverThe basic workflow for Servers, Tool definitions, and client calls
    Official SDK indexChoosing a programming language and its SDK
    Python SDK v1 documentationTool definitions and Streamable HTTP examples
    TypeScript SDK v1 Server documentationTool registration and Streamable HTTP Server examples

    Note on protocol versions and transports

    Official tutorials and SDKs are continuously updated. Examples may use local stdio or different protocol versions. The OKX.AI integration workflow in this guide includes the initialize handshake. Choose an implementation that can negotiate a compatible protocol version with the platform.

  2. 2
    Define tools and configure pricing

    Define MCP Tools

    Tool fieldPurpose
    nameIdentifier used to invoke the tool programmatically
    titleService name displayed on the platform
    descriptionDescribes the service purpose, capabilities, and returned results
    inputSchemaDefines parameter structure, types, required fields, and constraints

    OKX.AI requires title and description to be non-empty. One Tool can correspond to one Service, and multiple Services can share the same MCP Endpoint.

    Configure pricing

    Price information for paid Tools should also be maintained in the MCP Tool / endpoint and must be parsable by the platform.

    Option 1: Free services

    Return business results directly when the Tool is called. No x402 implementation is required.

    Option 2: Pay-per-call services (x402)

    Payment should be triggered at the tools/call stage. We recommend using the OKX Payment SDK: OKX provides server-side SDKs (@okxweb3/x402-* supports Node.js, Go, Rust, Java, and Python). Attach payment middleware to the endpoint and configure the receiving address, network, and price. The SDK handles 402 responses and onchain verification. For the full process, see Integrate through the SDK.

    ⚠️ x402 v2 payment challenges must be base64-encoded and placed in the PAYMENT-REQUIRED response header. The marketplace validates the response header, not the response body. Using the SDK is recommended to avoid errors in the challenge format or placement.

    json
    {
      "x402Version": 2,
      "resource": {
        "url": "https://<your-public-endpoint>/...",
        "description": "<service-description>",
        "mimeType": "application/json"
      },
      "accepts": [
        {
          "scheme": "exact",
          "network": "eip155:196",
          "asset": "0x779ded0c9e1022225f8e0630b35a9b54be713736",
          "amount": "10000",
          "payTo": "0x<your-x-layer-wallet>",
          "maxTimeoutSeconds": 300,
          "extra": { "name": "USD₮0", "version": "1" }
        }
      ]
    }
    

    Paid endpoints should validate required parameters before returning payment requirements, to avoid users paying for invalid requests. The network, payment scheme, asset, token name and version, amount, and receiving address in the payment challenge must be complete. The actual amount must match the price parsed by the platform.

  3. 3
    Deploy and verify the MCP service

    After deployment, use the official MCP Inspector or a compatible MCP Client to connect to the public HTTPS MCP address, such as https://你的域名/mcp, and verify the following workflow:

    text
    Client initialize
    → Server returns the initialization result
    → Client notifications/initialized
    → tools/list retrieves tool definitions
    → tools/call invokes the specified tool with valid arguments

    Confirm that the tools you want to list can be discovered and called, that title, description, and parameter definitions are accurate, and that the business results match the stated capabilities. For paid Tools, also verify the payment requirements for business calls and whether replaying the same call after payment authorization delivers the results correctly.

    Do not treat a webpage loading, HTTP 200, or progress messages alone as evidence of a successful call. Refer to the SDK documentation for tool discovery and invocation, and the official MCP debugging guide for connection troubleshooting.

  4. 4
    Register on OKX.AI

    Submit the Endpoint following the ASP registration process.