Skip to content

feat(lore-0042): run the example seller behind a tunnel, in an image - #254

Open
Bartek-str wants to merge 6 commits into
developfrom
lore-0042-mcp-claude-desktop-e2e
Open

Bartek-str wants to merge 6 commits into
developfrom
lore-0042-mcp-claude-desktop-e2e

Conversation

@Bartek-str

@Bartek-str Bartek-str commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

First of two PRs for 0042, a seller that always answers in the testnet catalog for the Claude
Desktop run (D2). This one makes examples/http-api ready to run behind the server's tunnel; the
second brings its deploy files and its probe. The task stays active.

  • Public origin (examples/http-api/src/config.ts, app.ts): optional PUBLIC_ORIGIN, https
    and an origin only. Set, the 402 names <origin>/weather. Behind the tunnel the seller sees plain
    http, so it named an http:// resource; the catalog's check after a settle asks the seller at
    that URL through the seller-fetch guard, which refuses it (not_https), and no listing was
    written. Unset, nothing changes.
  • SIGTERM (examples/http-api/src/index.ts): the seller stops taking requests, lets open ones
    finish and exits 0. In a container Node is PID 1 and ignores a SIGTERM it doesn't handle.
  • Image (examples/http-api/Dockerfile): the facilitator's pinned base and layout; it holds no
    secret.
  • README (apps/mcp-local/README.md): the Claude Desktop config names our catalog,
    https://x402-facilitator.sorobanscan.com, instead of a placeholder.
  • Task (lore/1-tasks/active/0042_…): what was checked and the e2e run's hashes; the README
    criterion ticked.

Reviewers, please confirm:

  • @karolko9 (0063, 0037): the listing path as the task file records it (PUBLIC_ORIGIN passes
    the cataloger's validate, seller check and sameListing), and that testnet-results.json stays
    as it was, since this run's commit field would name a commit without these changes.
  • @karczuRF (0026): the seller is to run on the production server beside the facilitator from
    this image; the deploy files come in the next PR for your review.
  • @adamkoot (0102): examples/http-api changes here before 0102's PR 3 makes it use the SDK's
    seller helpers; createApp takes publicOrigin and index.ts passes the whole config.

Please confirm

  1. PUBLIC_ORIGIN is https, an origin only, and a host a catalog lists (discovery, dev-tools):
    an http value would bring back the listing the catalog can't check, and a path would make the
    route name a URL other than its own. A user or password, an IP address, a trailing dot, a single
    label or a private suffix stop the start (10650853, after review), by the rules
    packages/bazaar applies, copied so the example needs none of our packages. Without it the seller names the request's URL, as before, so local runs and the e2e
    are unchanged.
  2. The SIGTERM handler is beyond the criteria (platform): without it every docker stop and
    deploy would wait out the grace period and kill the seller; the facilitator and the portal
    handle it the same way.

Testing

  • pnpm format:check && pnpm lint && pnpm typecheck && pnpm test && pnpm build → all pass but
    @stellar-x402/deploy tests on macOS: openbao-snapshot.test.ts and portal.test.ts fail with
    flock: command not found, the same two files on develop without these commits; CI's Linux has
    flock.
  • @stellar-x402/example-http-api → 33 tests, new: the 402 behind a proxy names the public https
    resource and a paid request still settles; PUBLIC_ORIGIN refused when http, a path, a query, or a host the catalog refuses (each checked against packages/bazaar's own canonicalizeUrl and isPublicResourceUrl);
    SIGTERM exits 0.
  • Testnet: pnpm mcp:e2e on the code of 8dee9c1e → 26 of 26 scenarios passed, three payments of
    0.001 USDC settled and successful on Horizon:
    263d5b00c6f7440b28d5c3228ea9441ac205ae3729f84c2f7248752f9e74d2ba (E-21),
    60a8ef6d533b1ae10599c1bbac63549c82dc9ce0734a712f09279a524e8e4d67 (E-22),
    bdebcc1fe02fadf0226d821512ebb88904a6d4dda0a7fc8e15ae3128e7f280c0 (E-25, search then pay). It
    starts the seller without PUBLIC_ORIGIN, so it shows the payment path still works.
  • The catalog's own steps (packages/bazaar, as cataloger.ts runs them) fed the seller's real
    402 with PUBLIC_ORIGIN=https://x402-seller.sorobanscan.com → validated, check request
    GET https://x402-seller.sorobanscan.com/weather?city=Warsaw, listing with our payTo and
    10000, sameListing true.
  • The image with --read-only --cap-drop ALL --security-opt no-new-privileges:true against our
    facilitator → 402 naming https://x402-seller.sorobanscan.com/weather on stellar:testnet; a
    probe from inside the container gets 402; docker stop returns at once, exit 0.
  • Not covered until the deploy: the seller behind the tunnel at its own hostname, its listing in the
    deployed catalog, the Claude Desktop run.

Behind the server's Cloudflare tunnel the request reaches the seller as
plain http, so the 402 named an http:// resource. The catalog's check
after a settle asks the seller at that URL through the seller-fetch
guard, which refuses http (not_https), so no listing was written.

PUBLIC_ORIGIN, optional, https and an origin only, makes the route name
<origin>/weather. Unset, the seller behaves as before.
In a container Node is PID 1, which ignores a SIGTERM it does not
handle, so every docker stop and deploy would wait out the grace period
and kill it. The seller now stops taking requests, lets open ones
finish and exits 0, as the facilitator and the portal do.
The seller is to run on the production server beside the facilitator,
where everything runs in Docker. Same base and layout as the
facilitator's and the portal's images; it holds no secret.
The Claude Desktop config named a placeholder catalog. Our facilitator
serves the testnet catalog in public since 0032.
The four commits before this one, what was checked on them, and the
e2e run on their code: 26 of 26 scenarios, three payments settled on
testnet with their hashes. Ticks the README criterion.

@karolko9 karolko9 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few findings for consideration, read at ae513e66. Four reviews ran on it, the 23 tests pass, and nothing was tried behind the real tunnel. Your call on each.

  1. Could app.set("trust proxy", true) replace PUBLIC_ORIGIN? @x402/express builds the URL from req.protocol and Host (index.mjs:55), and cloudflared keeps both. That's about −45 lines and no setting to keep in step with the hostname.
  2. If PUBLIC_ORIGIN stays: config.ts:31-38 accepts https://user:pw@host, https://host. and https://127.0.0.1, which the catalog refuses later, so the seller is silently never listed.
  3. FACILITATOR_URL defaults to x402.org (config.ts:15). If PR 2 forgets it, payments settle but never reach our catalog.
  4. For PR 2: after the 16.12 reset the probe stays green while payments fail, because the 402 comes from config. Could it check that payTo exists and has its trustline?
  5. For PR 2: junk payments copied from the public 402 cost nothing and share the server's single IP limit on /verify, so ~600 of them make the seller look dead.

Correctness held: with PUBLIC_ORIGIN the listing passes validate, the seller check and sameListing, and unset nothing changes.

PUBLIC_ORIGIN accepted a user and password, a trailing dot, an IP
address, a single label and private suffixes such as .local. The
catalog refuses those hosts after a settle, so the seller ran but was
silently never listed. It now stops at start instead, by the same
rules packages/bazaar applies, copied so the example needs none of
our packages.
Bartek-str added a commit that referenced this pull request Nov 26, 2026
The task stays active. Its seller code is in PR #254, under review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants