api2mcp-asp
Integrates with OKX for pay-per-call billing via x402, allowing the MCP server to monetize its tools with OKX payments on X Layer.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@api2mcp-aspGenerate MCP server from petstore API spec"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
API2MCP — turn any OpenAPI spec into a paid MCP server
OKX.AI Genesis Hackathon · Software Utility track
API2MCP is an Agentic Service Provider (ASP): give it any OpenAPI 3.x spec (JSON or YAML) and it generates a complete, ready-to-deploy TypeScript MCP server scaffold — one MCP tool per API operation, proxying the upstream API — with x402 pay-per-call billing already wired in.
It is deliberately meta: API2MCP is itself an MCP service that other agents pay (via x402) to call, and each call mints another monetizable ASP for the OKX.AI marketplace. One paid service that manufactures more paid services. See the ASP tutorial: https://www.okx.ai/tutorial/asp.
Generation is fully deterministic — plain template strings, no LLM calls.
How it works
OpenAPI 3.x spec (JSON/YAML)
|
v
API2MCP generator ──────────────► generated project (file map / zip)
- parse + light validation package.json, tsconfig.json
- 1 operation -> 1 MCP tool src/server.ts (Express + MCP Streamable HTTP,
- params/body -> Zod schemas fetch-proxy to the upstream API)
- servers[0] -> upstream base URL src/x402.ts (env-driven pay-per-call gate)
README.md, .env.example, .gitignoreRun it
npm install
npm run dev # starts http://localhost:4402 (tsx watch)
# or: npm run build && npm start
npm test # acceptance test: generated project must npm install + tsc cleanlyInterfaces
MCP (Streamable HTTP, stateless) — POST /mcp
Tool | Pricing | Description |
| paid |
|
| free |
|
curl -s http://localhost:4402/mcp \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'REST
Endpoint | Pricing | Returns |
| paid | JSON |
| paid | zip archive of the generated project |
| free | tool listing teaser |
# Generate an MCP server from the bundled petstore fixture:
node -e 'console.log(JSON.stringify({openapi_spec: require("fs").readFileSync("examples/petstore.json","utf8"), price_usd: 0.01}))' \
| curl -s http://localhost:4402/api/generate -H 'Content-Type: application/json' -d @- \
| node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{const r=JSON.parse(s);console.log(r.service_name, r.tool_count, Object.keys(r.files));})'
# Or download it as a zip:
node -e 'console.log(JSON.stringify({openapi_spec: require("fs").readFileSync("examples/petstore.json","utf8")}))' \
| curl -s http://localhost:4402/api/generate.zip -H 'Content-Type: application/json' -d @- -o petstore-mcp.zipCLI (local use, no server)
npx tsx src/cli.ts examples/petstore.json -o out/
cd out/petstore-mcp && npm install && npm run devOKX payment
Paid calls are settled via OKX's official x402 seller middleware
(@okxweb3/x402-express + @okxweb3/x402-core + @okxweb3/x402-evm) against
the OKX facilitator on X Layer (eip155:196).
Route | Price |
| $0.50 |
| $0.50 |
| $0.01 |
Env vars (all four OKX values plus PAYMENT_ENABLED=true are required to
activate payments; create keys at https://web3.okx.com/onchainos/dev-portal):
PAYMENT_ENABLED=true
OKX_API_KEY=...
OKX_SECRET_KEY=...
OKX_PASSPHRASE=...
PAY_TO_ADDRESS=0xYourWalletAddressWith payment active, unpaid requests to the paid routes get HTTP 402 with an
x402Version: 2 payment-required body listing the accepted exact-scheme
X Layer payment option. If any variable is missing, or OKX initialization
fails, the server logs one line and serves everything free — deploys stay safe
until real keys exist. /healthz, / and /mcp are never payment-gated.
Generated projects ship the same env-driven stub (PAYMENT_ENABLED, PAY_TO_ADDRESS,
PRICE_USD, X402_NETWORK) so every scaffold is monetizable out of the box.
Acceptance test
npm test is the quality bar: it generates a project from examples/petstore.json
(5 operations: path params, query params, header param, enum, $ref/allOf schemas, POST/PUT
bodies), writes it to a temp dir, runs npm install and npm run build (tsc) inside it, and
fails unless the generated code compiles. Set KEEP_GENERATED=1 to keep the temp project around.
Layout
src/generator/ deterministic OpenAPI -> MCP project generator
parse.ts JSON/YAML parsing + light structural validation
operations.ts operation -> tool extraction (names, params, bodies)
zod-codegen.ts JSON Schema -> Zod source translation ($ref, enum, allOf/oneOf/anyOf)
templates.ts file templates for the generated project
src/server.ts API2MCP service (MCP endpoint + REST + zip)
src/x402.ts OKX x402 payment middleware (@okxweb3/x402-express, env-gated no-op by default)
src/cli.ts local generation CLI
examples/ petstore fixture
test/validate.ts acceptance test (generated project must compile)This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Ni8crawler18/api2mcp-asp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server