# Docs & Help Center to RAG Markdown Chunker (`kickybreaks/docs-to-rag-markdown-chunker`) Actor

Crawl any documentation site, help center, or sitemap.xml and output clean, boilerplate-free, heading-aware Markdown chunks with token counts — ready to embed into Pinecone, Supabase pgvector, LangChain, LlamaIndex, and n8n.

- **URL**: https://apify.com/kickybreaks/docs-to-rag-markdown-chunker.md
- **Developed by:** [Julian Gilbert-Roberts](https://apify.com/kickybreaks) (community)
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 documentation pages chunked

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/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

## Docs & Help Center to RAG Markdown Chunker

Turn any documentation website, help center, or `sitemap.xml` into **clean, boilerplate-free, heading-aware Markdown chunks** with token estimates — ready to embed straight into **Pinecone**, **Supabase pgvector**, **Qdrant**, **LangChain**, **LlamaIndex**, **n8n**, or **AI / MCP agents**.

Built with an ultra-fast **HTTP-first engine** (128–512 MB RAM, zero browser overhead) that strips navigation bars, sidebars, cookie banners, and footers while preserving **Markdown headings, bullet lists, tables, and fenced code blocks**.

***

### Why Use This for RAG Pipelines?

- **Clean Signal, Zero Boilerplate:** Automatically locates `<article>` / `<main>` content and strips `<nav>`, `<footer>`, `<aside>`, TOCs, and scripts so you don't waste embedding tokens on menu links.
- **Heading-Aware Semantic Chunking:** Tracks the active section heading (`heading`) and splits along paragraph/section boundaries with configurable `chunkSizeChars` and `chunkOverlapChars`.
- **Vector-DB Ready Schema:** Every item includes a deterministic `chunkId`, `url`, `pageTitle`, `heading`, `chunkIndex`, `totalChunksOnPage`, `estimatedTokens`, `charCount`, and `markdown`.
- **Sitemap Auto-Expansion:** Pass any `sitemap.xml` URL + optional `urlIncludeSubstrings` (e.g. `["/docs/", "/tutorial/"]`) to index an entire knowledge base in seconds.

***

### Example Input

```json
{
  "startUrls": [
    "https://fastapi.tiangolo.com/tutorial/first-steps/",
    "https://fastapi.tiangolo.com/tutorial/path-params/"
  ],
  "crawlSitemap": true,
  "maxPages": 15,
  "chunkSizeChars": 2000,
  "chunkOverlapChars": 200
}
```

### Example Output

````json
{
  "chunkId": "9f8c1d2e3a4b5c6d",
  "url": "https://fastapi.tiangolo.com/tutorial/first-steps/",
  "domain": "fastapi.tiangolo.com",
  "pageTitle": "First Steps",
  "heading": "Step 1: import FastAPI",
  "chunkIndex": 0,
  "totalChunksOnPage": 3,
  "estimatedTokens": 482,
  "charCount": 1928,
  "markdown": "# First Steps\n\nThe simplest FastAPI file could look like this:\n\n```python\nfrom fastapi import FastAPI\napp = FastAPI()\n```"
}
````

***

### Performance & Cost Benchmark

- **Speed:** Crawls and chunks 50 documentation pages into ~150–300 RAG-ready chunks in ~6 seconds (128–512 MB RAM, pure HTTP).
- **Pricing:** **$3.00 per 1,000 chunked pages** (`$0.003` per `page-chunked` event — regardless of how many chunks a page produces!). Failed pages are never charged, and runs automatically stop cleanly if your spending cap is reached.

### Need Custom RAG Pipelines, Private Docs Ingestion, or n8n / MCP Integration?

Built and maintained by **Julian Gilbert-Roberts** (Senior AI & Full-Stack Systems Engineer). Need authenticated Confluence/Notion/Zendesk sync, custom pgvector/Pinecone RAG pipelines, or MCP servers for your engineering team?

- **Email:** julian.g.roberts@gmail.com
- **LinkedIn:** https://www.linkedin.com/in/julian-g-roberts

# Actor input Schema

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

List of documentation page URLs, site roots, or sitemap.xml URLs (e.g. 'https://fastapi.tiangolo.com/tutorial/first-steps/').

## `crawlSitemap` (type: `boolean`):

When enabled, if a start URL is a sitemap.xml (or a site root), automatically extracts page URLs from the sitemap up to maxPages.

## `urlIncludeSubstrings` (type: `array`):

Only crawl sitemap URLs containing at least one of these substrings (e.g. '/docs/', '/tutorial/', '/api/').

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

Maximum number of documentation pages to fetch and chunk.

## `chunkSizeChars` (type: `integer`):

Target maximum character length per Markdown chunk (~4 chars per token; 2000 chars ≈ 500 tokens).

## `chunkOverlapChars` (type: `integer`):

Number of characters repeated between adjacent chunks to preserve semantic context.

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

Number of pages to fetch in parallel.

## Actor input object example

```json
{
  "startUrls": [
    "https://fastapi.tiangolo.com/tutorial/first-steps/",
    "https://fastapi.tiangolo.com/tutorial/path-params/"
  ],
  "crawlSitemap": true,
  "maxPages": 15,
  "chunkSizeChars": 2000,
  "chunkOverlapChars": 200,
  "maxConcurrency": 5
}
```

# Actor output Schema

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

No description

## `dataset` (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://fastapi.tiangolo.com/tutorial/first-steps/",
        "https://fastapi.tiangolo.com/tutorial/path-params/"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("kickybreaks/docs-to-rag-markdown-chunker").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://fastapi.tiangolo.com/tutorial/first-steps/",
        "https://fastapi.tiangolo.com/tutorial/path-params/",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("kickybreaks/docs-to-rag-markdown-chunker").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://fastapi.tiangolo.com/tutorial/first-steps/",
    "https://fastapi.tiangolo.com/tutorial/path-params/"
  ]
}' |
apify call kickybreaks/docs-to-rag-markdown-chunker --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,kickybreaks/docs-to-rag-markdown-chunker"
        }
    }
}
```

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/ZQPa3zZUINpQepAPZ/builds/BOy739yUA0FWXOn98/openapi.json
