cd /news/ai-agents/zero-scraping-rag-preprocessing-html… · home › topics › ai-agents › article
[ARTICLE · art-182987] src=dev.to ↗ pub= topic=ai-agents verified=true sentiment=↑ positive

Zero-Scraping RAG Preprocessing: HTML-to-Markdown, Typed Tables, Chunking & Luhn PII Redaction via Edge MCP

A developer built doc-to-llm-markdown-mcp, a zero-dependency, stateless JavaScript MCP server that performs RAG pre-ingestion chores—HTML-to-Markdown conversion with boilerplate stripping, typed table-to-JSON parsing, heading-aware semantic chunking, and Luhn-based PII redaction—on caller-supplied text only. The engine runs on a free Cloudflare Worker with roughly 1ms cold starts and is also published as a Standby/Batch MCP Actor on the Apify Store, exposing REST routes and JSON-RPC 2.0 endpoints for use in Claude and Cursor.

key takeaway

doc-to-llm-markdown-mcp exposes HTML-to-Markdown, table-to-JSON, heading-aware chunking and Luhn PII redaction as stateless MCP/REST endpoints on a Cloudflare Worker with ~1ms cold starts and no stored caller data.

by read4 min views7 publishedDec 6, 2026

Most RAG pipelines waste time and tokens on the exact same pre-ingestion chores: stripping <nav> and <script> boilerplate out of HTML, turning messy CSV/Markdown/HTML tables into typed JSON, slicing documents into token-budgeted chunks without losing heading context, and scrubbing emails or payment card numbers before text ever hits an LLM prompt or vector database.

Too often, teams solve those four problems by spinning up a headless browser container, shipping 40 MB of transitive dependencies, or asking an LLM to clean its own input (burning both latency and tokens nondeterministically).

We built doc-to-llm-markdown-mcp as a zero-scraping, zero-dependency, stateless Web-Standards JS engine that runs identically on a free Cloudflare Worker (~1ms cold start, zero auth, zero caller data stored) and on Apify Store as a Standby/Batch MCP Actor (quantforge_data/doc-to-llm-markdown-mcp).

2025-03-26) https://doc-to-llm-markdown-mcp.ryu-7f5.workers.dev/mcp

claude mcp add --transport http doc-to-llm https://doc-to-llm-markdown-mcp.ryu-7f5.workers.dev/mcp

.cursor/mcp.json)

{
  "mcpServers": {
    "quantforge-doc-to-llm": {
      "url": "https://doc-to-llm-markdown-mcp.ryu-7f5.workers.dev/mcp"
    }
  }
}

Or test directly with curl via either the REST routes (/v1/*) or JSON-RPC 2.0 (/mcp).

Every single function in doc-to-llm-markdown-mcp operates exclusively on caller-supplied text:

fetch() callsTextEncoder, URL, crypto.subtle.digest('SHA-256', ...)). 10ms CPU budget on Cloudflare Workers Free Tier).pii_stored: false) html_to_llm_markdown (POST /v1/html-to-markdown) Removes <head>, <script>, <style>, <noscript>, <svg>, <iframe>, <template>—plus <nav>, <header>, <footer>, <aside> when strip_nav: true—while preserving <pre> code blocks using sentinel placeholders so whitespace normalization never corrupts code indentation. HTML <table> elements are extracted both inline as Markdown pipe tables and separately as structured JSON objects.

curl -sS -X POST "https://doc-to-llm-markdown-mcp.ryu-7f5.workers.dev/v1/html-to-markdown" \
  -H "Content-Type: application/json" \
  -d '{
    "html": "<nav>Skip Me</nav><article><h1>Q4 Engineering Update</h1><p>Deterministic <strong>RAG</strong> preprocessing.</p><table><tr><th>Metric</th><th>Value</th></tr><tr><td>Cold Start</td><td>1ms</td></tr></table></article>",
    "strip_nav": true,
    "include_links": true
  }'

Key fields returned under data:

title, markdown, headings ([{ level, text }]), tables, links (deduplicated)stats: input_bytes, output_bytes, compression_ratio, estimated_tokens, headings_count, tables_count, links_count, content_sha256 table_to_structured_json (POST /v1/table-to-json) Auto-detects csv, tsv, markdown, or html (format: "auto"), parses quoted RFC 4180 CSV fields cleanly, deduplicates duplicate column headers (price, price_2), infers scalar types ( integer, number, boolean, null, string), and emits per-column completeness statistics ( null_count, completeness_ratio).

curl -sS -X POST "https://doc-to-llm-markdown-mcp.ryu-7f5.workers.dev/v1/table-to-json" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "| service | price_per_1k | pii_excluded |\n| --- | --- | --- |\n| doc-to-llm | 2.00 | true |\n| rss-digest | 1.00 | true |",
    "format": "auto",
    "infer_types": true
  }'

rag_semantic_chunker (POST /v1/rag-chunk) Naive fixed-character splitting destroys Markdown section hierarchy and leaves vector chunks orphaned from the heading they belong to. rag_semantic_chunker maintains a live heading stack (#..######), splits at heading boundaries when preserve_headings: true, attaches heading_path breadcrumbs to every chunk, carries configurable overlap_tokens across paragraph boundaries, hard-splits oversized paragraphs on word boundaries, and computes a deterministic WebCrypto sha256 per chunk for vector-DB deduplication.

curl -sS -X POST "https://doc-to-llm-markdown-mcp.ryu-7f5.workers.dev/v1/rag-chunk" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "# Ingestion Guide\n\n## Deduplication\n\nStore each chunk SHA-256 hash so re-indexing skips unchanged sections.\n\n## Redaction\n\nRun PII redaction before generating embeddings.",
    "max_tokens": 64,
    "overlap_tokens": 8,
    "preserve_headings": true
  }'

pii_redactor_audit (POST /v1/redact-pii) Before text reaches a third-party embedding API or LLM context window, pii_redactor_audit deterministically redacts 5 categories (email, phone, ssn, credit_card, ipv4) using either [REDACTED_EMAIL] (placeholder_style: "bracket") or *** (placeholder_style: "mask").

One subtle detail that cuts false positives dramatically: credit card candidates (13–19 digits with optional spaces/hyphens) are verified with the Luhn checksum algorithm before redacting. That way a random 16-digit internal order ID or tracking number isn't mangled, while actual payment card numbers are caught.

Equally important: the audit output returns only redacted_text, pii_detected, total_redactions, counts_by_category, and redacted_sha256—it never echoes the raw matched PII values back into logs.

curl -sS -X POST "https://doc-to-llm-markdown-mcp.ryu-7f5.workers.dev/v1/redact-pii" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Contact ops@example.com or 415-555-0199 from 198.51.100.42 (test card 4111-1111-1111-1111, order 9999-8888-7777-6661).",
    "placeholder_style": "bracket"
  }'

Response shape:

{
  "ok": true,
  "data": {
    "redacted_text": "Contact [REDACTED_EMAIL] or [REDACTED_PHONE] from [REDACTED_IPV4] (test card [REDACTED_CREDIT_CARD], order 9999-8888-7777-6661).",
    "pii_detected": true,
    "total_redactions": 4,
    "counts_by_category": {
      "email": 1,
      "phone": 1,
      "ssn": 0,
      "credit_card": 1,
      "ipv4": 1
    },
    "redacted_sha256": "..."
  }
}

The exact same zero-dependency engine runs in two places:

quantforge_data/doc-to-llm-markdown-mcp) 256 MB, LIMITED_PERMISSIONS Standby MCP & Batch Actor ($0.002 / call, i.e., $2.00 / 1,000 calls with BRONZE/SILVER/GOLD volume discounts) when you need Apify Dataset persistence, scheduled jobs, n8n/Make connectors, or audit logs. If you test doc-to-llm-markdown-mcp against gnarly HTML tables or Markdown edge cases in your RAG pipeline, drop an example in the comments—we'd love to harden the parser against real-world inputs.

── more in #ai-agents 4 stories · sorted by recency
── more on @doc-to-llm-markdown-mcp 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/zero-scraping-rag-pr…] indexed:0 read:4min 2026-12-06 · —