跳到正文
DEV Community· member_0fbab672·· 48 分鐘前AI 評分55

PayAI Bazaar 與 MCP Registry 上架經驗:讓 AI 智能體找到付費 x402 API 的 5 項心得

Getting a paid x402 API discovered by AI agents: 5 things I learned listing on the PayAI Bazaar and the MCP Registry

AI 導讀

作者分享如何讓 AI 智能體發現日本資料的按次付費 x402 API,並總結在 PayAI Bazaar 與 MCP Registry 上架的 5 項實測心得。

正文

I run a small pay-per-call API with Japan data for AI agents (official ticket-sale openings, JMA weather warnings, prefecture minimum wages, foreign-worker rights). It costs 0.01 USDC per call over x402 (HTTP 402 + USDC on Base) and is also exposed as a remote MCP server. Building the endpoints was the easy part. Getting agents to find them took most of the work. Here is what actually moved the needle, so you don't have to rediscover it.

1. The bare URL must return 402, not 400

Discovery crawlers probe your resource URL without parameters. My /api/v1/warnings returned 400 missing office when called bare, so crawlers never saw a price and the route was never indexed.

Fix: with no parameters → 402 with the payment requirements. After payment, return a sensible default (I return Tokyo with defaulted_office: true and a note). Invalid parameters (office=zzz) still get a 400 before the 402, so nobody pays for a query that can't succeed.

GET /api/v1/warnings            -> 402 (price visible to crawlers)
GET /api/v1/warnings?office=zzz -> 400 (validated before payment)
GET /api/v1/warnings?office=130000 + X-PAYMENT -> 200

2. A bazaar extension alone wasn't enough. One real settle was.

I put the bazaar discovery metadata in my 402 responses, and only some routes appeared in the PayAI Bazaar. The missing routes showed up about a minute after their first settled payment through the facilitator. I made one 0.01 USDC self-payment per route (to my own payTo address). After that, discovery/resources?payTo=<my address> listed all of them.

Also note that facilitators don't share an index. Settling through PayAI got me listed on PayAI only. The Coinbase CDP Bazaar is a separate index, fed by settles through the CDP facilitator.

3. Validate before you settle, and watch Workers CPU

On Cloudflare Workers, settlement happens before your handler fetches data. If the handler then dies from the free plan's 10 ms CPU limit, the buyer has paid and gets nothing. Parsing the full 1.26 MB JMA map JSON took ~18 ms of CPU locally, so I dropped the "nationwide summary" idea. Keep the paid path cheap, and do the heavy parsing at build time.

4. The official MCP Registry doesn't need a GitHub account

mcp-publisher supports HTTP domain auth. You serve one text line at /.well-known/mcp-registry-auth:

v=MCPv1; k=ed25519; p=<base64 public key>

Then mcp-publisher login http --domain <your-domain> --private-key <hex> and mcp-publisher publish. Your namespace is the reverse-DNS form of the domain (mine is dev.pages.hodoyoku/japan-data). Keep the private key out of anything you deploy.

5. Registry search is a name substring match, so pick a niche name

The registry's ?search= matches names only. "japan" already returns 100+ servers, so a generic "Japan data" name gets buried. Terms like foreign-worker rights or minimum wage had zero competing servers when I checked, so specific names win.

Try it

  • MCP endpoint (streamable HTTP): https://hodoyoku.pages.dev/mcp (tools/list is free)
  • x402 index: https://hodoyoku.pages.dev/.well-known/x402
  • Registry entry: https://registry.modelcontextprotocol.io/v0/servers?search=hodoyoku

Honest status: listing works, but outside paid traffic is still close to zero. Discovery was a prerequisite, not demand. If you build agents that touch Japan (travel, HR, payroll, relocation), I'd love to hear which data you'd actually pay a cent per call for.

Setup guide, tool list and curl examples: https://hodoyoku.pages.dev/agents

來源:DEV Community · dev.to