# Doc-to-LLM Markdown, Table JSON, RAG Chunker & PII Redactor MCP (`quantforge_data/doc-to-llm-markdown-mcp`) Actor

Zero-scraping deterministic document utility & MCP server: convert HTML to clean LLM Markdown, parse CSV/TSV/HTML/Markdown tables to typed JSON, split heading-aware RAG chunks, and redact PII (Luhn-validated). Pay-Per-Event & Standby MCP.

- **URL**: https://apify.com/quantforge_data/doc-to-llm-markdown-mcp.md
- **Developed by:** [QuantForge Data](https://apify.com/quantforge_data) (community)
- **Categories:** AI, MCP servers, Developer tools
- **Features:** Limited permissions, Single-tenant, Server interface
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.60 / 1,000 document transformation calls

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

Published by **QuantForge Data** (`quantforge_data`).

A **zero-scraping, deterministic, stateless document preprocessing utility & MCP server** built for **RAG pipelines, LLM agents, n8n/Make/LangGraph workflows, and B2B document automation**. Send your own HTML, CSV/TSV/Markdown/HTML tables, or raw text and get clean LLM-ready Markdown, typed JSON table records, heading-aware semantic RAG chunks with SHA-256 hashes, or Luhn-validated PII-redacted text in milliseconds — with **zero external scraping, zero upstream API fragility, and zero PII retention**.

### What can Doc-to-LLM Markdown, Table JSON, RAG Chunker & PII Redactor MCP do?

- **HTML to LLM-Ready Markdown (`html_to_llm_markdown`)**: Strips `<script>`, `<style>`, `<nav>`, `<header>`, `<footer>`, and `<aside>` boilerplate, converts HTML tables to Markdown tables, extracts heading outlines and deduplicated links, and computes compression ratio, estimated tokens, and SHA-256 hashes.
- **Universal Table to Typed JSON (`table_to_structured_json`)**: Auto-detects and parses **CSV, TSV, Markdown pipe tables, and HTML `<table>`** into normalized JSON rows with automatic type inference (`integer`, `float`, `boolean`, `null`) and column completeness statistics.
- **Heading-Aware Semantic RAG Chunker (`rag_semantic_chunker`)**: Splits Markdown or plain text along heading boundaries respecting `max_tokens` and `overlap_tokens`, attaching hierarchical `heading_path` breadcrumbs and deterministic chunk hashes for vector databases.
- **Deterministic PII Redactor & Audit (`pii_redactor_audit`)**: Detects and masks emails, US phone numbers, SSNs, **Luhn-validated payment cards**, and IPv4 addresses before LLM ingestion. Returns sanitized text and aggregate counts only — never echoes or stores raw PII.
- **Dual Interface (Apify Batch + Standby REST/MCP)**: Run as a standard Apify Actor, query low-latency Standby REST endpoints (`/v1/html-to-markdown`, `/v1/table-to-json`, `/v1/rag-chunk`, `/v1/redact-pii`), or connect AI agents directly via **JSON-RPC 2.0 MCP (`/mcp`)**.

### Input parameters & examples

#### Example 1: HTML to LLM Markdown (Batch input)

```json
{
  "operation": "html_to_llm_markdown",
  "html": "<nav>Menu</nav><article><h1>Q4 Engineering Update</h1><p>Cut RAG token usage by <strong>48%</strong>.</p><table><tr><th>Metric</th><th>Before</th><th>After</th></tr><tr><td>Tokens</td><td>1200</td><td>620</td></tr></table></article>",
  "strip_nav": true,
  "include_links": true
}
```

#### Example 2: Table to Typed JSON

```json
{
  "operation": "table_to_structured_json",
  "content": "company,arr_usd,profitable\nAcme AI,2400000,true\nNova Labs,850000,false",
  "format": "auto",
  "infer_types": true
}
```

#### Example 3: PII Redactor Audit

```json
{
  "operation": "pii_redactor_audit",
  "text": "Reach support@acme.example or call 415-555-0199 from 192.0.2.10.",
  "placeholder_style": "bracket"
}
```

### Standby REST API & MCP server

When running in Apify Standby mode, all 4 tools are exposed via REST and native MCP:

- `GET /` — Service metadata and Apify readiness probe
- `GET /health` — Health status JSON
- `POST /v1/html-to-markdown` — Convert HTML to clean Markdown + outline + tables
- `POST /v1/table-to-json` — Parse CSV/TSV/Markdown/HTML table into typed JSON
- `POST /v1/rag-chunk` — Split text/Markdown into heading-aware RAG chunks
- `POST /v1/redact-pii` — Redact PII and return aggregate audit counts
- `POST /mcp` — JSON-RPC 2.0 MCP endpoint (`initialize`, `ping`, `tools/list`, `tools/call`)

#### MCP `tools/call` example

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "rag_semantic_chunker",
    "arguments": {
      "text": "# Architecture\n## Storage\nAll processing is completely stateless.",
      "max_tokens": 128,
      "overlap_tokens": 16,
      "preserve_headings": true
    }
  }
}
```

### How much does it cost? (Pay-Per-Event pricing)

| Event Name | Price (USD) | Description |
|---|---|---|
| `apify-actor-start` | `$0.00005` | Standard Apify startup event per run (covers first 5 seconds of compute) |
| `doc-transform-call` | `$0.002` | Per deterministic transformation call (`$2.00 / 1,000 calls`) |

### More feeds & MCP servers by QuantForge Data

- [**U.S. SEC Form D Startup & Private Funding Leads Feed**](https://apify.com/quantforge_data/sec-form-d-funding-leads) — Daily PII-free Regulation D private placement & startup fundraising leads from SEC EDGAR.
- [**U.S. SEC Form 4 Open-Market Insider & Cluster Buy Signal Feed**](https://apify.com/quantforge_data/sec-form4-cluster-insider) — Strictly PII-free open-market insider buys/sales, Rule 10b5-1 flags, and multi-insider clusters.
- [**Crypto Perpetual Funding Rate APR & Cross-Venue Spread Feed**](https://apify.com/quantforge_data/crypto-perp-funding-arb) — Hourly multi-venue funding APR, basis, OI, and delta-neutral carry spreads.
- [**Polymarket Probability Inefficiency & Liquidity Scanner Feed**](https://apify.com/quantforge_data/polymarket-inefficiency-scanner) — Multi-outcome NegRisk overround/underround and bid-ask spread scanner.

### FAQ & privacy guarantee

#### Does this Actor scrape external websites or call third-party APIs?

No. It operates strictly on caller-supplied input strings with zero outbound HTTP calls, eliminating scraping ToS risk, rate limits, and third-party downtime.

#### Is any input document or PII stored?

No. Processing is 100% stateless in memory. The `pii_redactor_audit` tool returns only sanitized text and category counts — raw PII matches are never echoed or persisted.

# Actor input Schema

## `operation` (type: `string`):

Select the deterministic transformation tool to execute.

## `html` (type: `string`):

Raw HTML document or fragment supplied by caller.

## `strip_nav` (type: `boolean`):

Remove <nav>, <header>, <footer>, and <aside> tags before Markdown conversion.

## `include_links` (type: `boolean`):

Keep links as Markdown [text](url).

## `base_url` (type: `string`):

Optional http(s) base URL used to resolve relative href links.

## `content` (type: `string`):

Raw CSV, TSV, Markdown pipe table, or HTML <table> string.

## `format` (type: `string`):

Input table format (auto-detected by default).

## `infer_types` (type: `boolean`):

Automatically infer integers, floats, booleans, and nulls.

## `text` (type: `string`):

Markdown or plain text to chunk for RAG or sanitize for PII.

## `max_tokens` (type: `integer`):

Target maximum estimated tokens per chunk (32..8192).

## `overlap_tokens` (type: `integer`):

Estimated overlap tokens carried from previous chunk (0..2048).

## `preserve_headings` (type: `boolean`):

Split on Markdown heading boundaries and attach breadcrumb paths.

## `placeholder_style` (type: `string`):

Replacement format for redacted PII tokens.

## Actor input object example

```json
{
  "operation": "html_to_llm_markdown",
  "html": "<article><h1>Q4 Product Release</h1><p>Fast <strong>deterministic</strong> RAG preprocessing.</p><table><tr><th>Metric</th><th>Value</th></tr><tr><td>Latency</td><td>2ms</td></tr></table></article>",
  "strip_nav": true,
  "include_links": true,
  "format": "auto",
  "infer_types": true,
  "max_tokens": 256,
  "overlap_tokens": 32,
  "preserve_headings": true,
  "placeholder_style": "bracket"
}
```

# Actor output Schema

## `resultsDataset` (type: `string`):

Structured JSON output produced by the selected document transformation operation.

## `summaryOutput` (type: `string`):

Operation executed, processing status, and full structured result.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "html": "<article><h1>Q4 Product Release</h1><p>Fast <strong>deterministic</strong> RAG preprocessing.</p><table><tr><th>Metric</th><th>Value</th></tr><tr><td>Latency</td><td>2ms</td></tr></table></article>"
};

// Run the Actor and wait for it to finish
const run = await client.actor("quantforge_data/doc-to-llm-markdown-mcp").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "html": "<article><h1>Q4 Product Release</h1><p>Fast <strong>deterministic</strong> RAG preprocessing.</p><table><tr><th>Metric</th><th>Value</th></tr><tr><td>Latency</td><td>2ms</td></tr></table></article>" }

# Run the Actor and wait for it to finish
run = client.actor("quantforge_data/doc-to-llm-markdown-mcp").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "html": "<article><h1>Q4 Product Release</h1><p>Fast <strong>deterministic</strong> RAG preprocessing.</p><table><tr><th>Metric</th><th>Value</th></tr><tr><td>Latency</td><td>2ms</td></tr></table></article>"
}' |
apify call quantforge_data/doc-to-llm-markdown-mcp --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,quantforge_data/doc-to-llm-markdown-mcp"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/7rCllESQHvwZAIm5l/builds/HpPQUHaHoqudnGTdV/openapi.json
