# Clean Markdown & RAG Extractor for LLMs (`slavako/clean-markdown-rag-fetcher`) Actor

Scrapes web pages into clean, boilerplate-free Markdown with rich metadata & vector-ready chunks for RAG, LangChain, LlamaIndex, and MCP AI agents. No login required.

- **URL**: https://apify.com/slavako/clean-markdown-rag-fetcher.md
- **Developed by:** [Sviatoslav](https://apify.com/slavako) (community)
- **Categories:** AI, Developer tools, Automation
- **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.00 / 1,000 clean markdown documents

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/actors/running/actors-in-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

## Clean Markdown & RAG Extractor for LLMs

[![No Login Required](https://img.shields.io/badge/Auth-No_Login_Required-brightgreen?style=flat-square)](https://apify.com/slavako/clean-markdown-rag-fetcher)
[![RAG Ready](https://img.shields.io/badge/RAG-Semantic_Chunks_Ready-blue?style=flat-square)](https://apify.com/slavako/clean-markdown-rag-fetcher)
[![MCP Ready](https://img.shields.io/badge/AI_Agents-MCP_Ready-blue?style=flat-square)](https://apify.com/slavako/clean-markdown-rag-fetcher)
[![Pay-Per-Event](https://img.shields.io/badge/Pricing-from_$1.00_/_1k-orange?style=flat-square)](https://apify.com/slavako/clean-markdown-rag-fetcher)
[![Zero Proxies](https://img.shields.io/badge/Proxies-Zero_Cost-informational?style=flat-square)](https://apify.com/slavako/clean-markdown-rag-fetcher)

High-speed, zero-noise web-to-Markdown scraper and RAG content extractor. Cleans boilerplates (navbars, ads, cookie banners, footers), extracts metadata, formats clean GitHub-flavored Markdown, and generates vector-ready semantic chunks for LLMs and AI agents.

***

### ⚡ Key Features

- **🔒 100% No Login / No Cookies Required**: Works directly via HTTP fetch with instant response times.
- **🧹 Boilerplate Removal**: Uses Mozilla Readability algorithm to strip navigation, ads, footers, headers, and social widgets, preserving only the core article content.
- **📝 Clean Markdown Formatting**: Converts clean HTML into standard GitHub Flavored Markdown (headings, lists, tables, fenced code blocks).
- **🧩 Vector-Ready Semantic Chunking**: Automatically splits markdown documents into configurable chunks (`chunkSize`, `chunkOverlap`) with preserved heading hierarchies for instant ingestion into Chroma, Pinecone, Qdrant, Weaviate, or Supabase pgvector.
- **📊 Rich Metadata Extraction**: Extracts title, author, published date, description, site name, canonical URL, and estimated reading time.
- **🔗 Link Graph Discovery**: Automatically discovers and categorizes internal vs external links on the page, with optional domain crawling (`crawlDepth: 1`).
- **🤖 Standby MCP Mode**: Native Model Context Protocol (MCP) server running at `/mcp` or `/read` for instant tool execution by AI agents (Cursor, Claude, LangChain, n8n) with zero cold starts.

***

### 💰 Pay-Per-Event (PPE) Transparent Pricing

Never pay flat monthly plans or expensive proxy fees. You are billed strictly per event:

| Event | Cost | Description |
|---|---|---|
| **Actor Start (`apify-actor-start`)** | **$0.003** / run | Initialization & environment setup |
| **Clean Document (`apify-default-dataset-item`)** | **$0.001** / page ($1.00 per 1k pages) | Clean Markdown, metadata, reading time, link graph |
| **RAG Chunking (`rag-chunking-enriched`)** | **$0.001** / document ($1.00 per 1k docs) | Overlapping semantic vector chunks with heading paths |

*Free tier accounts can extract up to 15 pages per run for free testing.*

***

### 🔗 Step-by-Step Integrations

#### 1. LangChain / LlamaIndex Vector Ingestion (Python)

Ingest documentation or blog content directly into your vector database:

```python
from apify_client import ApifyClient
import chromadb

client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("slavako/clean-markdown-rag-fetcher").call(run_input={
    "urls": ["https://platform.openai.com/docs/models"],
    "enableChunking": True,
    "chunkSize": 1000,
    "chunkOverlap": 150
})

dataset_items = client.dataset(run["defaultDatasetId"]).list_items().items
chroma_client = chromadb.Client()
collection = chroma_client.create_collection("docs_rag")

for doc in dataset_items:
    for chunk in doc.get("chunks", []):
        collection.add(
            documents=[chunk["text"]],
            metadatas=[{"url": doc["url"], "title": doc["title"], "headings": " > ".join(chunk["headings"])}],
            ids=[f"{doc['url']}-chunk-{chunk['chunkIndex']}"]
        )
```

***

#### 2. n8n / Make Workflow (Web Page to Notion / Knowledge Base)

1. Add an **HTTP Request** node calling `https://api.apify.com/v2/acts/slavako~clean-markdown-rag-fetcher/run-sync-get-dataset-items`.
2. Body:

```json
{
  "urls": ["https://news.ycombinator.com/item?id=..."],
  "enableChunking": false
}
```

3. Connect a **Notion** node: create a new page with content `{{$json.markdown}}` and title `{{$json.title}}`.

***

#### 3. Cursor & Claude Desktop (MCP Agent Integration)

Add this to your `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "web-markdown": {
      "command": "npx",
      "args": ["-y", "@apify/mcp-server", "--actor", "slavako/clean-markdown-rag-fetcher"]
    }
  }
}
```

Ask Claude: *"Read the documentation at https://docs.anthropic.com/en/docs/welcome and summarize the core prompt engineering principles"*.

***

### 📥 Input Parameters

| Parameter | Type | Default | Description |
|---|---|---|---|
| `urls` | Array of strings | `["https://..."]` | Target web URLs to scrape (blogs, articles, docs) |
| `crawlDepth` | Integer | `0` | `0` = only given URLs, `1` = follow same-domain links |
| `maxPages` | Integer | `50` | Maximum pages to scrape |
| `enableChunking` | Boolean | `true` | Split markdown into vector-ready overlapping chunks |
| `chunkSize` | Integer | `1000` | Target character length per chunk |
| `chunkOverlap` | Integer | `150` | Overlap character count between adjacent chunks |
| `extractMetadata` | Boolean | `true` | Extract author, date, description, reading time |
| `includeRawHtml` | Boolean | `false` | Include sanitized HTML snippet in output |

***

### 📤 Output Dataset Format

```json
{
  "url": "https://docs.example.com/guide/rag",
  "canonicalUrl": "https://docs.example.com/guide/rag",
  "title": "Complete Guide to RAG Architectures",
  "description": "Step-by-step tutorial on retrieval-augmented generation with vector databases.",
  "author": "Jane Doe",
  "siteName": "AI Engineering Blog",
  "publishedTime": "2026-05-10T12:00:00Z",
  "readingTimeMinutes": 4,
  "wordCount": 820,
  "characterCount": 5410,
  "markdown": "# Complete Guide to RAG Architectures\n\nRetrieval-Augmented Generation (RAG) optimizes...",
  "chunks": [
    {
      "chunkIndex": 0,
      "totalChunks": 6,
      "text": "# Complete Guide to RAG Architectures\n\nRetrieval-Augmented Generation (RAG)...",
      "characterCount": 980,
      "wordCount": 142,
      "headings": ["Complete Guide to RAG Architectures", "Core Concepts"]
    }
  ],
  "internalLinks": ["https://docs.example.com/guide/embeddings"],
  "externalLinks": ["https://github.com/example/rag-demo"],
  "scrapedAt": "2026-11-13T00:00:00.000Z"
}
```

***

### 📄 License

Apache-2.0

# Actor input Schema

## `urls` (type: `array`):

List of web URLs to scrape and convert into clean Markdown (e.g. documentation, blogs, articles).

## `crawlDepth` (type: `integer`):

How deeply to follow internal links from the same domain (0 = only given URLs, 1 = also follow direct internal links).

## `maxPages` (type: `integer`):

Maximum number of total pages to extract.

## `enableChunking` (type: `boolean`):

Splits clean Markdown into semantic overlapping chunks ready for vector databases (Chroma, Pinecone, Qdrant, Weaviate).

## `chunkSize` (type: `integer`):

Target character size for each semantic chunk.

## `chunkOverlap` (type: `integer`):

Character overlap between adjacent chunks to maintain context continuity.

## `extractMetadata` (type: `boolean`):

Extracts title, author, publish date, site name, description, reading time, and open graph image.

## `includeRawHtml` (type: `boolean`):

Include the cleaned HTML snippet alongside the Markdown output.

## Actor input object example

```json
{
  "urls": [
    "https://docs.anthropic.com/en/docs/welcome",
    "https://platform.openai.com/docs/models"
  ],
  "crawlDepth": 0,
  "maxPages": 50,
  "enableChunking": true,
  "chunkSize": 1000,
  "chunkOverlap": 150,
  "extractMetadata": true,
  "includeRawHtml": false
}
```

# Actor output Schema

## `dataset` (type: `string`):

Extracted web documents with clean Markdown, metadata, reading times, and semantic RAG chunks.

# 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 = {
    "urls": [
        "https://docs.anthropic.com/en/docs/welcome",
        "https://platform.openai.com/docs/models"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("slavako/clean-markdown-rag-fetcher").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 = { "urls": [
        "https://docs.anthropic.com/en/docs/welcome",
        "https://platform.openai.com/docs/models",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("slavako/clean-markdown-rag-fetcher").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 '{
  "urls": [
    "https://docs.anthropic.com/en/docs/welcome",
    "https://platform.openai.com/docs/models"
  ]
}' |
apify call slavako/clean-markdown-rag-fetcher --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,slavako/clean-markdown-rag-fetcher"
        }
    }
}
```

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/tbLSSpoGfMeKuN09M/builds/DJDXZLeDaL14Brrnx/openapi.json
