# Fast LLM-Ready Markdown & Sitemap Crawler (RAG / MCP) (`danlopes18/apify-llm-markdown-crawler`) Actor

Ultra-fast, zero-browser HTML-to-Markdown crawler for RAG pipelines, Claude, Cursor, n8n & MCP agents. Supports direct URLs or automatic sitemap.xml discovery, strips boilerplate/nav/scripts, preserves headings & code blocks, and estimates token counts.

- **URL**: https://apify.com/danlopes18/apify-llm-markdown-crawler.md
- **Developed by:** [Daniel Lopes](https://apify.com/danlopes18) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 extracted markdown pages

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## Fast LLM-Ready Markdown & Sitemap Crawler (RAG / MCP)

Ultra-fast, **zero-browser** HTML-to-Markdown crawler built for **RAG pipelines, Claude, Cursor, n8n, Make, and autonomous MCP agents (`mcp.apify.com`)**.

Runs on pure native Node.js 22 without heavy headless browsers — extracting clean, token-counted Markdown up to **10x faster and cheaper** than Chromium crawlers.

***

### Why Use This Crawler for AI & RAG

- **Automatic Boilerplate Stripping:** Removes `<nav>`, `<footer>`, `<aside>`, `<script>`, `<style>`, and `<svg>`, isolating `<main>` / `<article>` content cleanly.
- **Preserves Developer Structure:** Keeps `#` headings, fenced code blocks (with language tags), inline code, lists, and resolved absolute links.
- **Native Sitemap Discovery:** Pass any `sitemap.xml` (including nested `<sitemapindex>` files) or enable `discoverSitemap` to crawl docs & blogs automatically up to `maxPages`.
- **Regex Filtering:** Use `includePattern` (e.g. `/docs/|/guides/`) and `excludePattern` (e.g. `/login|/pricing`) to extract only high-signal pages.
- **Built-in Token Estimation:** Every dataset item includes `wordCount`, `estimatedTokens`, `headings`, `fetchMs`, and clean `markdown` capped cleanly via `maxCharsPerPage`.
- **Hardened Security:** DNS-verified SSRF protection blocks private networks and cloud metadata endpoints automatically.

***

### Ideal Use Cases

1. **Knowledge Base & Docs Ingestion for RAG / Vector DBs** (Pinecone, Qdrant, Supabase `pgvector`).
2. **n8n / Make AI Workflows:** Feed clean Markdown straight into OpenAI, Claude, or Gemini nodes without wasting 70% of your context window on HTML tags.
3. **MCP Tool Call (`mcp.apify.com`):** Let Claude or Cursor read any documentation page or `/llms.txt` cleanly in <500ms.

***

### Example Input

```json
{
  "startUrls": [
    "https://danlopes18-ctrl.github.io/",
    "https://danlopes18-ctrl.github.io/sitemap.xml"
  ],
  "maxPages": 25,
  "includePattern": "",
  "excludePattern": "/login|/cart",
  "maxCharsPerPage": 50000
}
```

# Actor input Schema

## `startUrls` (type: `array`):

Direct page URLs (e.g. https://danlopes18-ctrl.github.io/) or sitemap URLs (e.g. https://danlopes18-ctrl.github.io/sitemap.xml).

## `discoverSitemap` (type: `boolean`):

When enabled, if a domain root URL is provided, also probe /sitemap.xml to crawl subpages up to maxPages.

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

Maximum number of pages to extract per run (1-500).

## `includePattern` (type: `string`):

Only extract URLs matching this regular expression (e.g. /docs/|/blog/).

## `excludePattern` (type: `string`):

Skip URLs matching this regular expression (e.g. /login|/pricing).

## `maxCharsPerPage` (type: `integer`):

Trim page markdown above this character limit to keep LLM context windows lean (1000-200000).

## `maxConcurrency` (type: `integer`):

Parallel HTTP fetches (1-20).

## Actor input object example

```json
{
  "startUrls": [
    "https://docs.apify.com/sitemap.xml",
    "https://stripe.com/docs"
  ],
  "discoverSitemap": false,
  "maxPages": 25,
  "includePattern": "",
  "excludePattern": "",
  "maxCharsPerPage": 50000,
  "maxConcurrency": 6
}
```

# Actor output Schema

## `overview` (type: `string`):

No description

## `items` (type: `string`):

No description

# 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 = {
    "startUrls": [
        "https://danlopes18-ctrl.github.io/",
        "https://danlopes18-ctrl.github.io/sitemap.xml"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("danlopes18/apify-llm-markdown-crawler").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 = { "startUrls": [
        "https://danlopes18-ctrl.github.io/",
        "https://danlopes18-ctrl.github.io/sitemap.xml",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("danlopes18/apify-llm-markdown-crawler").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 '{
  "startUrls": [
    "https://danlopes18-ctrl.github.io/",
    "https://danlopes18-ctrl.github.io/sitemap.xml"
  ]
}' |
apify call danlopes18/apify-llm-markdown-crawler --silent --output-dataset

```

## MCP server setup

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

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/mdcbmKnuOSuHTwS1x/builds/UcXHKBhU0p4CphDlo/openapi.json
