2026-12-06 ~5 min read MCP · x402 · Cloudflare · Apify RSS

Discovery Is the Hard Part: Shipping an x402 MCP Server Agents Can Actually Find

Moving cf-x402-mcp from v0.1.0 to v0.3.0 taught me that HTTP 402 plumbing is the easy part; discovery (/llms.txt, Official MCP Registry, Glama) and browserless verification actors are where the real friction lives.

Getting a Cloudflare Worker to return HTTP 402 with a Base-USDC PAYMENT-REQUIRED header is the easy part. I covered that plumbing in my earlier notes on cf-x402-mcp v0.1.0.

What tripped me up next was a much more mundane question: once a paid MCP server is deployed, how does an agent or another developer actually find it, inspect what it returns without paying first, and verify that its manifests are not broken?

Between v0.1.0 and v0.3.0 of xgbtxy/cf-x402-mcp (51/51 Vitest tests passing in CI), most of my work shifted away from payment plumbing and toward discovery and verification surfaces — plus two small, browserless Pay-Per-Event (PPE) Apify Actor repos built around the same HTTP-first pattern. Here is what actually worked, where the seams are, and what I am still unsure about.

1. Three discovery surfaces, three different contracts

In v0.3.0, cf-x402-mcp exposes five paid tools (ci_log_sieve, repo_sec_triage, market_edge_feed, web_md_distill, and the newly added llm_cost_router at $0.01 USDC) across six OpenAPI 3.1 REST routes plus a stateless streamable-http MCP endpoint at POST /mcp.

To make the server discoverable without asking someone to read a README first, it now publishes to three distinct surfaces:

  1. Self-hosted machine-readable endpoints:
    • GET /llms.txt (HTTP 200, text/plain; charset=utf-8) — concise plain-text index of the MCP URL, discovery manifest, OpenAPI spec, and free preview route.
    • GET /.well-known/x402 (HTTP 200) — x402 v2 manifest declaring network: eip155:8453, Base USDC asset, facilitator URL, mcpEndpoint: "/mcp", and per-tool atomic pricing.
    • GET /openapi.json — OpenAPI 3.1 schema covering all six REST routes (/api/ci-log-sieve, /api/llm-cost-router, /api/market-edge-feed, /api/poly-signals, /api/repo-sec-triage, /api/web-md-distill).
  2. Official MCP Registry (io.github.xgbtxy/cf-x402-mcp):
    • Published at v0.3.0 (status: active, isLatest: true) via GitHub OIDC, declaring a streamable-http remote pointing to https://cf-x402-mcp.yan8925298.workers.dev/mcp.
    • One small detail that bit me at v0.2.1: server.json enforces a tight description length (<= 100 chars), so registry metadata cannot just be a copy-paste of your repo tagline.
  3. Third-party directories:

The catch is obvious once you maintain all three: none of them is a single source of truth. Each surface has its own schema, staleness window, and versioning rules. Updating a route in the Worker updates /llms.txt and /openapi.json immediately, whereas the Official MCP Registry only moves when you push a v* tag and run the OIDC publish workflow, and external directories refresh on their own schedule.

2. "sample": true as the practical trust primitive

Nobody — human or agent — wants to sign a USDC payment just to discover that a tool's JSON output shape does not match what their parser expects.

Every paid tool in cf-x402-mcp accepts "sample": true (or ?sample=true on REST routes) at $0, returning a deterministic built-in response without triggering the paywall. There is also a free GET /api/poly-signals/preview endpoint for a single-signal preview.

In practice, "sample": true has been more useful than prose documentation. You can test the exact response shape with a single curl:

curl -X POST "https://cf-x402-mcp.yan8925298.workers.dev/api/ci-log-sieve?sample=true"

The trade-off: sample responses can quietly drift from live paid outputs if they are not generated through the same core formatter. Right now unit tests cover both paths (test/core.test.ts, test/http.test.ts, test/poly-signals.test.ts), which helps, but there is no runtime schema assertion guaranteeing zero drift in production.

3. Two browserless Pay-Per-Event Apify Actors (and the honest seams)

Alongside the Cloudflare Worker, I built two companion MIT-licensed Apify Actor repositories using Pay-Per-Event (PPE) billing:

  • xgbtxy/agent-docs-distiller-actor (8/8 Vitest tests passing in CI): pure HTTP fetch + cheerio + turndown in a 128–512 MB Node.js container (no Playwright/Chromium). It strips boilerplate, extracts HTML <table> elements into typed { headers, rows } JSON, probes origins for /llms.txt and /openapi.json, and writes a Dataset, OUTPUT summary, and LLMS_FULL.md RAG bundle. PPE events: $0.002 actor-start, $0.005 page-distilled, $0.010 spec-discovered (failed HTTP fetches are never billed page-distilled).
  • xgbtxy/x402-endpoint-auditor-actor (27/27 Vitest tests passing in CI): pure HTTP compliance auditor for x402 v2 and MCP origins. It checks discovery (/.well-known/x402, /openapi.json, /llms.txt, /favicon.ico), runs optional MCP JSON-RPC initialize + tools/list, probes paid routes for HTTP 402 + Base64 PAYMENT-REQUIRED headers (x402Version, CAIP-2 network, USDC asset, payTo), and outputs a 0–100 readinessScore, A–F grade, and AUDIT_REPORT.md. PPE events: $0.002 actor-start, $0.005 manifest-checked, $0.020 endpoint-audited (SSRF-blocked or unreachable origins are never billed).

I want to be careful not to oversell the relationship between the Cloudflare Worker and these two Apify Actors. They do not share a runtime, a billing system, a registry, or an auth layer. One settles Base USDC on Cloudflare Workers via x402; the other bills USD per-event on Apify's platform.

What they do share is a narrow engineering preference: pure HTTP over headless browsers, explicit per-call/per-event pricing instead of opaque subscriptions, fail-closed CI tests, and treating llms.txt / OpenAPI / /.well-known/x402 as machine-verifiable contracts.

Two deliberate scope limits in x402-endpoint-auditor-actor are worth calling out explicitly:

  1. Strict SSRF guard: it rejects localhost, loopback, RFC1918, link-local, IPv6 loopback/ULA, DNS rebinding, and redirects to internal hosts before billing or probing.
  2. Zero payment is ever sent: the auditor only inspects unpaid 402 challenges and discovery manifests. That means a 100 / A score on my own server is a shape check and a smoke test — not a proof that live facilitator settlement or on-chain finality will succeed under load.

Also, to be completely transparent about current status: both Apify Actor repositories are public and CI-green on GitHub, but Apify Store console publishing is still pending. They are runnable locally (npm test, npm run dry-run), not yet listed on the Apify Storefront.

4. Architectural trade-offs I actually felt

  • Pure HTTP (fetch + cheerio) vs. headless Chromium: startup is fast and memory stays in 128–512 MB, which makes $0.005/page economics plausible. The obvious downside is that client-side-only SPAs that render documentation purely via JavaScript come back thin or empty.
  • Two billing rails (x402 Base USDC vs. Apify PPE): x402 gives permissionless per-call crypto settlement on Cloudflare Workers, while Apify PPE plugs into an existing developer billing platform (mcp.apify.com). Supporting both means maintaining two completely separate operational surfaces instead of one clean stack.
  • Static shape audits vs. live paid end-to-end tests: refusing to hold private keys or send funds inside x402-endpoint-auditor-actor keeps the auditor safe to run on untrusted URLs, at the cost that settlement bugs still have to be caught separately.

5. What I am unsure about

  • Whether registry presence drives real agent traffic or mostly human curiosity. Being active on the Official MCP Registry (io.github.xgbtxy/cf-x402-mcp), Glama, and x402scan makes the server cleaner to inspect, but I have no evidence yet that autonomous agents are discovering and paying for third-party x402 tools in the wild at meaningful volume.
  • Whether micro-priced PPE events survive real-world unit economics. $0.002 for actor-start and $0.005 for page-distilled looks friendly on paper, and pending Apify Store publication means I have zero live billing data yet to see how platform fees and noisy crawls behave in practice.
  • How much value a self-written auditor has beyond catching my own regressions. Using x402-endpoint-auditor-actor against cf-x402-mcp is genuinely handy for catching missing headers or malformed manifests in CI, but an author auditing their own server is never an independent stamp of quality.

If you are publishing remote streamable-http MCP servers or experimenting with /llms.txt and /.well-known/x402 discovery, I would love to hear which discovery surfaces have actually sent you real traffic — and which ones turned out to be pure maintenance overhead.

Links

我觉得技术没有壁垒,在合适的时间做合适的事情就好,hhh