Skip to main content
Glama
Fourier18

SchemaFetch MCP Server

by Fourier18
README.md
# SchemaFetch

Schema-constrained web extract for AI agents. Pass a URL + preset (or JSON schema), get structured JSON back with confidence and source snippets. Pay per call in USDC on Base via **x402** — no API keys for buyers.

Separate product from [ReceiptStamp](https://github.com/Fourier18/ReceiptStamp). Reuses the same Cloudflare account, CDP facilitator keys, and Base payTo wallet; **does not merge codebases**.

Live (after deploy): `https://schemafetch.panmediatech.workers.dev`

## API

| Route | Auth | Purpose |
|---|---|---|
| `GET /health` | free | Liveness + preset list |
| `GET /v1/sample?preset=contact` | free | Fixed demo HTML extract |
| `GET /v1/presets` | free | Preset schemas |
| `GET /openapi.json` | free | OpenAPI doc |
| `POST /x402/extract` | **$0.02 USDC** | `{ "url", "preset" }` or `{ "url", "schema" }` |
| `GET /x402/extract?url=&preset=` | **$0.02 USDC** | Agentic.Market GET compatibility |
| `POST /x402/extract/custom` | **$0.04 USDC** | `{ "url", "schema" }` only |

### Presets

`saas_pricing` · `contact` · `team` · `product` · `faq`

### Example (after payment)

```json
POST /x402/extract
{
  "url": "https://example.com/pricing",
  "preset": "saas_pricing"
}
```

```json
{
  "data": {
    "plans": [{ "name": "Pro", "price": "$29 / mo", "period": "month", "features": [] }],
    "currency_hints": ["USD"]
  },
  "confidence": 0.7,
  "sources": [{ "field": "plans", "quote": "..." }],
  "fetched_at": "2026-07-11T00:00:00.000Z",
  "cache": "miss",
  "preset": "saas_pricing"
}
```

## Structure

- `src/extract.js` — pure extract logic (heuristics + presets)
- `src/worker.mjs` — Hono Worker + x402 paywall (CDP facilitator)
- `mcp/server.mjs` — MCP bridge (free tools + paid extract via x402-fetch)
- `skills/schemafetch/SKILL.md` — agent skill (when/how to call; free install)
- `test/` — extract + worker tests (402 without real CDP settlement)
- `scripts/bootstrap-x402-payment.mjs` — one-time Bazaar first-settlement pay

## MCP + skill (distribution, same monetization)

Packaging only — agents still pay the Worker per call. No second price.

**You (the seller) do not need to keep `npm run mcp` open.** The product is the live Worker + marketplace listing. MCP is how *other people* plug SchemaFetch into Claude Desktop / Cursor.

### For buyers (your audience)

Step-by-step: **[mcp/FOR_USERS.md](mcp/FOR_USERS.md)**

One-liner config (Claude Desktop / similar hosts):

```json
"schemafetch": {
  "command": "npx",
  "args": ["-y", "github:Fourier18/SchemaFetch", "mcp"],
  "env": {
    "SCHEMAFETCH_BASE_URL": "https://schemafetch.panmediatech.workers.dev",
    "X402_CLIENT_PRIVATE_KEY": "0xYOUR_BASE_PRIVATE_KEY_WITH_USDC"
  }
}
```

### Skill

`skills/schemafetch/SKILL.md` — instructions agents can load (when to call, presets, budget).

### Marketplace (agent HTTP discovery — already live)

https://agentic.market/services/schemafetch-panmediatech-workers-dev

## Local

```bash
npm install
npm test
```

## Deploy

Same Cloudflare account as ReceiptStamp (`panmediatech` workers.dev).

```bash
# Secrets — file redirect only on this machine (interactive paste can corrupt)
npx wrangler secret put CDP_API_KEY_ID < secrets/cdp_id.txt
npx wrangler secret put CDP_API_KEY_SECRET < secrets/cdp_secret.txt

npx wrangler deploy
```

Then once, with a funded Base USDC wallet, bootstrap Bazaar indexing:

```bash
X402_CLIENT_PRIVATE_KEY=0x... node scripts/bootstrap-x402-payment.mjs
```

## Kill criterion

**Zero non-test paid calls by 2026-07-25 = stop funding this product.** Listing and self-payments do not count.

## Relationship to ReceiptStamp

| | ReceiptStamp | SchemaFetch |
|---|---|---|
| Job | Notarize payload | Extract structured page data |
| Rails | ACP + x402 | **x402 only** (v1) |
| Worker | `receiptstamp` | `schemafetch` |
| payTo | `0x7e05…dc20` | same (by design) |
| CDP keys | Worker secrets | same account, new Worker secrets |

See `PLAN.md` for status and deploy notes.

## Built with

| | |
|---|---|
| **Language** | JavaScript (Node.js ≥20, ESM Worker) |
| **Runtime** | [Cloudflare Workers](https://workers.cloudflare.com) |
| **HTTP** | [Hono](https://hono.dev) |
| **Payments** | [x402](https://x402.org) + [Coinbase CDP facilitator](https://docs.cdp.coinbase.com/x402) (USDC on Base) |
| **Agent tools** | [MCP](https://modelcontextprotocol.io) (`@modelcontextprotocol/sdk`), x402-fetch |
| **AI (authoring)** | **[Grok 4.5](https://x.ai)** via **Grok Build** CLI **v0.2.93** (xAI SuperGrok / Grok Build agent stack) |

Human owns product decisions, wallets, and accounts. Stack details also in [`TOOLS.md`](TOOLS.md).