Skip to main content
Glama
README.md
# x402-cluster

## Quick Start (30 Seconds, No API Key)

Connect `x402-cluster` to your MCP client and test `preview_extract` for free—no signup, API key, or wallet required.

### 1. Add to your MCP client

**Cursor** (`.cursor/mcp.json` or `~/.cursor/mcp.json`):
```json
{
  "mcpServers": {
    "x402-cluster": {
      "url": "[https://x402-cluster.ian-944.workers.dev/v1/mcp.json](https://x402-cluster.ian-944.workers.dev/v1/mcp.json)"
    }
  }
}
```

**Windsurf** (`~/.codeium/windsurf/mcp_config.json`):
```json
{
  "mcpServers": {
    "x402-cluster": {
      "serverUrl": "[https://x402-cluster.ian-944.workers.dev/v1/mcp.json](https://x402-cluster.ian-944.workers.dev/v1/mcp.json)"
    }
  }
}
```

**Claude Desktop** (`claude_desktop_config.json`):
```json
{
  "mcpServers": {
    "x402-cluster": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-remote",
        "[https://x402-cluster.ian-944.workers.dev/v1/mcp.json](https://x402-cluster.ian-944.workers.dev/v1/mcp.json)"
      ]
    }
  }
}
```

### 2. Paste this test prompt

> Use `preview_extract` to scrape `https://news.ycombinator.com` and return the top 5 stories as JSON with `title`, `url`, and `points`.

### 3. Example output

```json
{
  "url": "[https://news.ycombinator.com](https://news.ycombinator.com)",
  "stories": [
    {
      "title": "Example Story Title",
      "url": "[https://example.com/article](https://example.com/article)",
      "points": 342
    }
  ]
}
```

When you're ready for full headless rendering, pagination, or bulk extraction, your agent can call the paid x402 tools automatically—pay per call with no monthly subscription.

**Serverless Headless-Browser Scraping, HTML-to-JSON Schema Extraction, and Compliance MCP Server for AI Agents.**

Zero local Docker bloat. Zero Chromium RAM leaks. Zero sign-up required to test.

- **Live MCP Endpoint (Streamable HTTP):** `https://x402-cluster.ian-944.workers.dev/v1/mcp.json`
- **Direct API Execution:** `https://x402-cluster.ian-944.workers.dev/v1/execute`
- **Self-Serve Prepaid Keys ($10 for 1,000 calls):** [x402-site-6gt.pages.dev](https://x402-site-6gt.pages.dev)
- **Official MCP Registry ID:** `io.github.ianshelp/x402-cluster`

---

## ⚡ Try It in 2 Seconds (Zero Auth, Zero Signup)

Run this right in your terminal. Test any public URL against any JSON schema for free:

```bash
curl -X POST https://x402-cluster.ian-944.workers.dev/v1/execute \
  -H "Content-Type: application/json" \
  -d '{
    "tool": "preview_extract",
    "url": "https://news.ycombinator.com",
    "target_schema": { "top_story": "string", "points": "number" }
  }'
```

**Response (~1.5s):**
```json
{
  "top_story": "<populated: string (48 chars)>",
  "points": "<populated: number>",
  "preview_token": "prev_7f8a9b2c..."
}
```

- Verifies that your target page was successfully rendered and extracted.
- Returns missing/blocked fields as `null` and populates types + character lengths.
- Returns a 300-second `preview_token`. When passed on your paid call, it returns the pinned snapshot immediately (~20ms latency) with **zero snapshot drift** and **zero re-rendering compute**.

---

## 🚀 Quick Setup for AI Agents

### 1. Claude Desktop / Cursor / Windsurf (`claude_desktop_config.json`)

```json
{
  "mcpServers": {
    "x402-cluster": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-fetch", "https://x402-cluster.ian-944.workers.dev/v1/mcp.json"],
      "env": {
        "AUTHORIZATION": "Bearer sk_live_YOUR_KEY_HERE"
      }
    }
  }
}
```

Or connect directly via any streamable HTTP MCP client to:
`https://x402-cluster.ian-944.workers.dev/v1/mcp.json`

---

## 🛠️ Tools Included

| Tool | Cost | Best For |
| :--- | :--- | :--- |
| **`preview_extract`** | **FREE** (3/hr per IP) | Test schema extraction on any page. Returns masked types + 300s `preview_token`. |
| **`extract_dynamic_url`** | $0.05 / call | Full headless Chromium rendering on Cloudflare edge (React, Next.js, SPAs, dynamic tables). |
| **`extract_from_url`** | $0.01 / call | Fast static HTML fetch + LLM entity normalization for docs, blogs, and articles. |
| **`parse_web_schema`** | $0.01 / call | Extract a flat list of named keys out of unstructured raw text or DOM snippets. |
| **`extract_structured_data`** | $0.01 / call | Strict schema validation & entity extraction for text snippets already in memory. |
| **`validate_compliance`** | $0.01 / call | Regulatory, PII, and policy checks before database writes or API mutations. |

---

## 📦 Zero Drift & Optional Metadata

### 1. Snapshot Drift Prevention (`preview_token`)
Pass `preview_token` from your free preview to the paid tool:
```bash
curl -X POST https://x402-cluster.ian-944.workers.dev/v1/execute \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "tool": "extract_dynamic_url",
    "preview_token": "prev_7f8a9b2c..."
  }'
```
- Reuses the rendered DOM snapshot pinned during preview.
- **Latency drops to <20ms**.
- Eliminates page drift between preview and extraction.

### 2. Optional Metadata Wrapper (`include_metadata: true`)
By default, extraction returns a strictly flat JSON object matching your schema keys. If you want final redirect URLs, HTTP codes, or anti-bot challenge statuses, pass `include_metadata: true`:

```json
{
  "data": {
    "top_story": "Show HN: x402-cluster",
    "points": 142
  },
  "meta": {
    "resolved_url": "https://news.ycombinator.com/news",
    "status": "success",
    "block_reason": null,
    "cached": true
  }
}
```

Detected `block_reason` values include: `cloudflare_turnstile`, `captcha_detected`, `login_wall`, `access_denied`, or `null`.

---

## 💳 Payment Options

1. **Prepaid API Keys ($10 for 1,000 credits):**
   - Instant self-serve checkout at [x402-site-6gt.pages.dev](https://x402-site-6gt.pages.dev).
   - Use via `Authorization: Bearer sk_live_...`.
   - Balances returned via `X-Credits-Remaining-Cents` header.
2. **On-Chain Crypto Micropayments (x402):**
   - Direct HTTP 402 with EIP-3009 `TransferWithAuthorization` on Base L2 (`0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913`).

---

## 📄 License
MIT