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).

Try It in 10 Seconds (Zero API Keys)

Claude Code

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

Cursor / Windsurf (.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).

Architecture: Zero Outbound Network Calls, Zero Dependencies, 1 MB Guard

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

  • Zero outbound fetch() calls: zero scraping ToS risk, zero SSRF surface, zero upstream fragility.
  • Zero npm runtime dependencies: uses only built-in Web Standards (TextEncoder, URL, crypto.subtle.digest('SHA-256', ...)).
  • 1 MB stateless request guard: protects Worker memory/CPU (10ms CPU budget on Cloudflare Workers Free Tier).
  • Zero persistence (pii_stored: false): request payloads are processed in-memory and discarded immediately.

Walkthrough of the 4 Deterministic Tools

1. 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

2. 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 }' 

3. 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 }' 

4. 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": "..." } } 

Dual-Channel: Free Edge MCP vs. Apify Store Batch Actor

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

  1. Cloudflare Workers (https://doc-to-llm-markdown-mcp.ryu-7f5.workers.dev/mcp): Free, zero-auth Streamable HTTP MCP and REST for interactive Claude Code / Cursor sessions and lightweight API calls.
  2. Apify Store (quantforge_data/doc-to-llm-markdown-mcp): Packaged as a 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.