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 type | Use case | Source of call definitions |
|---|---|---|
| MCP endpoint | Supports the MCP protocol and enables discovery and invocation of one or more Tools | Tool definitions returned by tools/list |
| HTTP endpoint | A regular HTTP API | Endpoint, 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.
| Characteristic | Description | Examples |
|---|---|---|
| Structured data or capabilities | Returns explicit results through an interface rather than purely manual processing | Weather, exchange rates, maps, market data, company information |
| Can be exposed as tools | Each capability can be broken down into a function with parameters | Order queries, invoice generation, translation |
| Verifiable results and relatively low risk | Return values are relatively deterministic | Query and read-only services |
| Ongoing value | Users may make repeated calls | Data APIs, industry knowledge bases, vertical search |
Preparation before integration#
Choose the endpoint type you want to integrate, then complete the corresponding 4 preparation steps.
- 1Build 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 resource What it helps you understand Build an MCP server The basic workflow for Servers, Tool definitions, and client calls Official SDK index Choosing a programming language and its SDK Python SDK v1 documentation Tool definitions and Streamable HTTP examples TypeScript SDK v1 Server documentation Tool 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.
- 2Define tools and configure pricing
Define MCP Tools
Tool field Purpose name Identifier used to invoke the tool programmatically title Service name displayed on the platform description Describes the service purpose, capabilities, and returned results inputSchema Defines 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/callstage. 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 handles402responses 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-REQUIREDresponse 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.
- 3Deploy 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:textClient initialize → Server returns the initialization result → Client notifications/initialized → tools/list retrieves tool definitions → tools/call invokes the specified tool with valid argumentsConfirm 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.
- 4Register on OKX.AI
Submit the Endpoint following the ASP registration process.
