Skip to main content
Glama

docpile is a forkable template for building your own personal documentation server. It uses the Model Context Protocol to serve indexed documentation directly into your LLM's context window. You bring the docs -- docpile handles the indexing, full-text search, AI re-ranking, and serving.

Why docpile?

  • Your docs, your way -- scrape exactly the libraries and sources you need

  • Free forever -- no API keys, no subscriptions, no usage limits

  • Offline-first -- all docs stored locally in SQLite, works without internet

  • AI re-ranking -- multi-signal scoring (BM25 + title match + code density + section diversity)

  • Any LLM client -- works with Claude Code, VS Code Copilot, Cursor, OpenCode, LM Studio, and any MCP-compatible tool

  • Forkable -- clone it, customize the scrapers, build your own knowledge base


Related MCP server: docs-mcp

How It Works

  1. You scrape documentation from any source (official doc sites, GitHub repos, wikis, etc.)

  2. docpile indexes the content into SQLite with FTS5 full-text search

  3. Your LLM queries the index via MCP tools and gets the most relevant snippets

You run scrapers (web scraping, GitHub API, manual import)
        |
        v
   SQLite + FTS5 Index (local, portable, single file)
        |
        v
   docpile MCP Server (stdio or HTTP)
        |
        v
   Your LLM Client (Claude Code, Cursor, VS Code, etc.)

Quick Start

1. Clone and build

git clone https://github.com/Ruler-Dev/docpile.git
cd docpile
npm install
npm run build

2. Initialize the database

npx docpile init

This creates an empty SQLite database at data/docpile.db.

3. Add libraries and scrape

# Add libraries with their documentation URLs
npx docpile add facebook/react -n "React" -u "https://react.dev/reference"
npx docpile add vercel/next.js -n "Next.js" -u "https://nextjs.org/docs"
npx docpile add fastapi/fastapi -n "FastAPI" -u "https://fastapi.tiangolo.com"

# Scrape and index all added libraries
npx docpile update

4. Start the MCP server

# Stdio transport (for CLI-based clients like Claude Code)
npx docpile start

# HTTP transport (for GUI clients like Cursor, VS Code, LM Studio)
npx docpile serve

5. Connect your LLM client

See Connecting Your LLM Client below.


What You Can Scrape

docpile's built-in scraper can index any documentation website. It uses cheerio + turndown to convert HTML to Markdown, splits by headings, and stores everything with FTS5 full-text search.

Supported content types

Content

How to scrape

Example

Library docs

Point at any doc site URL

React, Django, Tokio, Flask, Express, etc.

GitHub repos

Scrape README + docs/ folder via GitHub API

Any public repo

Architecture guides

Scrape pattern catalogs and methodology sites

refactoring.guru, microservices.io, 12factor.net

Security references

Scrape pentesting wikis, cheat sheets, tool docs

OWASP, HackTricks, PortSwigger, Nmap

Standards & specs

Scrape MDN, RFC pages, language specs

MDN Web Docs, RFCs, ECMAScript spec

Competitive programming

Scrape algorithm encyclopedias

CP Algorithms, Big-O Cheat Sheet

Game dev docs

Scrape engine documentation

Godot, Bevy, LearnOpenGL

Embedded/IoT

Scrape hardware reference docs

Arduino, ESP-IDF, FreeRTOS

DevOps/SRE

Scrape infrastructure docs

Kubernetes, Terraform, Nginx

Data science/ML

Scrape ML framework docs and tutorials

PyTorch, scikit-learn, HuggingFace

Quick references

Scrape cheat sheet sites

Devhints.io, tldr-pages, QuickRef.me

Custom/internal docs

Point at any HTML-based doc site

Your company's internal documentation

Library types

When adding libraries, you can tag them with a type for better search filtering:

library, architecture, security, devops, sysdesign, datascience, algorithms, gamedev, embedded, reference, standards

The curated catalog

src/seed/catalog.ts contains a curated list of ~200 popular libraries across every ecosystem with their documentation URLs. Use it as a starting point:

  • JavaScript/TypeScript: React, Next.js, Vue, Svelte, Angular, Node.js, Deno, Bun, Express, Fastify, NestJS, Prisma, Drizzle, Tailwind, shadcn/ui, Vitest, Playwright, Zod, LangChain, Vercel AI SDK

  • Python: FastAPI, Django, Flask, PyTorch, TensorFlow, scikit-learn, Pandas, LangChain, Pydantic, SQLAlchemy

  • Go: Gin, Fiber, Echo, GORM, Cobra

  • Rust: Tokio, Axum, Actix, Serde, Tauri

  • Mobile: React Native, Expo, Flutter, SwiftUI

  • Databases: PostgreSQL, MongoDB, Redis, SQLite, Supabase

  • DevOps: Docker, Kubernetes, Terraform, GitHub Actions

  • Security: HackTricks, PortSwigger, OWASP, Nmap, Metasploit, Burp Suite, GTFOBins, PayloadsAllTheThings

  • Architecture: Design Patterns, SOLID, Microservices, 12-Factor, DDD

  • Standards: MDN Web Docs, RFCs (HTTP, OAuth, JWT, TLS), OpenAPI, ECMAScript

  • And more: algorithms, game dev, embedded, data science, system design, quick references


Building Your Database

Method 1: CLI (simplest)

npx docpile init
npx docpile add facebook/react -n "React" -u "https://react.dev/reference"
npx docpile update

Method 2: Custom Node.js scraper

Create a script that directly inserts into the database. See scripts/examples/scrape-web.mjs for a full working example.

// scripts/my-scraper.mjs
import Database from "better-sqlite3";
import * as cheerio from "cheerio";
import TurndownService from "turndown";
import { request } from "undici";

const db = new Database("./data/docpile.db");
db.pragma("journal_mode = WAL");
db.pragma("foreign_keys = ON");

const turndown = new TurndownService({ headingStyle: "atx", codeBlockStyle: "fenced" });

const LIBRARIES = [
  { name: "React", slug: "facebook/react", docUrl: "https://react.dev/reference" },
  { name: "Vue", slug: "vuejs/vue", docUrl: "https://vuejs.org/guide" },
];

async function scrapePage(url) {
  const { statusCode, body } = await request(url, {
    headers: { "User-Agent": "docpile-scraper/0.1", Accept: "text/html" },
  });
  if (statusCode !== 200) throw new Error(`HTTP ${statusCode}`);
  const html = await body.text();
  const $ = cheerio.load(html);
  $("nav, footer, aside, script, style").remove();
  const main = $("main").html() || $("article").html() || $("body").html() || "";
  return { title: ($("h1").first().text() || url).trim(), content: turndown.turndown(main).trim() };
}

function chunkByHeadings(content) {
  return content.split(/^(?=##\s)/m).filter(s => s.trim()).map(section => {
    const match = section.match(/^##\s+(.+)/);
    return { title: match ? match[1] : "Introduction", content: section.trim(), tokens: Math.ceil(section.length / 4) };
  });
}

const insertLib = db.prepare("INSERT OR IGNORE INTO libraries (name, slug, doc_url, status, type, source) VALUES (?, ?, ?, 'pending', 'library', 'scraped')");
const insertChunk = db.prepare("INSERT INTO chunks (library_id, title, content, section, token_count, chunk_index) VALUES (?, ?, ?, ?, ?, ?)");
const deleteChunks = db.prepare("DELETE FROM chunks WHERE library_id = ?");
const updateStatus = db.prepare("UPDATE libraries SET status = ?, last_updated = unixepoch() WHERE id = ?");

for (const lib of LIBRARIES) {
  console.log(`Scraping ${lib.name}...`);
  insertLib.run(lib.name, lib.slug, lib.docUrl);
  const row = db.prepare("SELECT id FROM libraries WHERE slug = ?").get(lib.slug);
  if (!row) continue;

  try {
    const doc = await scrapePage(lib.docUrl);
    const chunks = chunkByHeadings(doc.content);
    const tx = db.transaction(() => {
      deleteChunks.run(row.id);
      chunks.forEach((c, i) => insertChunk.run(row.id, c.title, c.content, c.title, c.tokens, i));
      updateStatus.run("synced", row.id);
    });
    tx();
    console.log(`  -> ${chunks.length} chunks`);
    await new Promise(r => setTimeout(r, 2000)); // be polite
  } catch (err) {
    console.error(`  -> Failed: ${err.message}`);
    updateStatus.run("error", row.id);
  }
}
db.close();

Method 3: Python bulk scraper

See scripts/examples/scrape-bulk.py for a full working example.

Method 4: GitHub API scraper

See scripts/examples/scrape-github.py for fetching docs from GitHub repos.

Backup & restore

# Backup (it's just a single file)
cp data/docpile.db data/docpile-backup.db

# Restore
cp data/docpile-backup.db data/docpile.db

# Share with teammates
# Just copy the .db file to their data/ folder

Inspect your database

sqlite3 data/docpile.db "SELECT name, slug, status, source FROM libraries ORDER BY name;"
sqlite3 data/docpile.db "SELECT COUNT(*) as libs FROM libraries; SELECT COUNT(*) as chunks FROM chunks;"

Connecting Your LLM Client

Claude Code

Add to .mcp.json in your project root:

{
  "mcpServers": {
    "docpile": {
      "command": "node",
      "args": ["/path/to/docpile/dist/index.js", "start"]
    }
  }
}

Or via CLI: claude mcp add docpile -- node /path/to/docpile/dist/index.js start

Or with HTTP (if running docpile serve or Docker):

{
  "mcpServers": {
    "docpile": {
      "url": "http://localhost:3777/mcp"
    }
  }
}

VS Code + GitHub Copilot

Create .vscode/mcp.json:

{
  "servers": {
    "docpile": {
      "command": "node",
      "args": ["/path/to/docpile/dist/index.js", "start"]
    }
  }
}

Switch to Agent mode in Copilot Chat to use the tools.

Cursor

Create .cursor/mcp.json:

{
  "mcpServers": {
    "docpile": {
      "command": "node",
      "args": ["/path/to/docpile/dist/index.js", "start"]
    }
  }
}

Or go to Cursor Settings -> MCP -> Add new MCP server.

OpenCode

Create opencode.json in your project root:

{
  "mcp": {
    "docpile": {
      "type": "stdio",
      "command": "node",
      "args": ["/path/to/docpile/dist/index.js", "start"]
    }
  }
}

LM Studio

Edit ~/.lmstudio/mcp.json:

{
  "mcpServers": {
    "docpile": {
      "command": "node",
      "args": ["/path/to/docpile/dist/index.js", "start"]
    }
  }
}

HTTP transport is recommended for LM Studio:

{
  "mcpServers": {
    "docpile": {
      "url": "http://localhost:3777/mcp"
    }
  }
}

Any MCP Client

docpile supports two transport protocols:

Protocol

Endpoint

Use case

Streamable HTTP

POST /mcp

Modern clients (MCP 2025-11-25)

Legacy SSE

GET /sse + POST /messages

Older clients (MCP 2024-11-05)

Health check

GET /health

Monitoring

Works with: Windsurf, Zed, Continue.dev, Cline, Aider, Roo Code, and any MCP-compatible client.

See docs/ folder for detailed per-client setup guides.


MCP Tools

Once connected, your LLM has access to these tools:

Tool

Description

search

Search libraries by name. Returns slugs for use with get_docs

get_docs

Get documentation for a library with optional topic filter

get_guide

Cross-source knowledge synthesis across a domain

add_library

Add a new library and trigger doc sync

list_libraries

List all tracked libraries and sync status

update_library

Re-fetch and re-index a library's docs

Example prompts

"Show me React hooks documentation"
"Search for ORM libraries"
"Get a guide about microservices patterns"
"Add axios to docpile with doc URL https://axios-http.com/docs/intro"
"Update the React documentation"
"Get nmap port scanning docs"
"Get a security guide about SQL injection"

Your LLM will automatically call the right tools -- no need to mention tool names.


CLI Commands

docpile init              # Initialize config and empty database
docpile start             # Start MCP server (stdio transport)
docpile serve             # Start HTTP MCP server (port 3777)
docpile update [library]  # Scrape and index docs (all or specific)
docpile add <slug>        # Add a library to track
docpile remove <slug>     # Remove a library
docpile list              # Show all tracked libraries

Configuration

docpile.config.json:

{
  "libraries": [
    { "name": "React", "slug": "facebook/react", "docUrl": "https://react.dev/reference" }
  ],
  "settings": {
    "dbPath": "./data/docpile.db",
    "updateIntervalHours": 24,
    "maxChunkTokens": 1500,
    "httpPort": 3777,
    "rateLimitPerMinute": 30
  }
}

Setting

Default

Description

dbPath

./data/docpile.db

Path to SQLite database

updateIntervalHours

24

Auto-update interval (0 to disable)

maxChunkTokens

1500

Max tokens per documentation chunk

httpPort

3777

HTTP server port

rateLimitPerMinute

30

Max scraping requests per minute


Docker

docker compose up -d

# Health check
curl http://localhost:3777/health

The container serves the HTTP MCP server on port 3777. Mount your database and config:

services:
  docpile:
    build: .
    ports:
      - "3777:3777"
    volumes:
      - ./data:/app/data
      - ./docpile.config.json:/app/docpile.config.json:ro
    restart: unless-stopped

Search Pipeline

When your LLM calls get_docs:

  1. Library Resolution -- matches your query to a library (exact slug, name, or fuzzy)

  2. FTS5 Search -- full-text search using BM25 with porter stemming

  3. AI Re-ranking -- multi-signal scoring (BM25 30%, title match 25%, code density 20%, section diversity 15%, term density 10%)

  4. Diverse Selection -- picks best chunks from different sections

  5. Token Budget -- returns results up to the token limit (default: 5000)


Tech Stack

  • Runtime: Node.js 22+ / TypeScript (ESM)

  • MCP: @modelcontextprotocol/sdk

  • Database: SQLite + FTS5 via better-sqlite3 + drizzle-orm

  • Scraping: cheerio + turndown (HTML to Markdown)

  • HTTP: undici

  • CLI: commander

  • Scheduler: node-cron

  • Validation: zod


License

MIT

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      A comprehensive, domain-agnostic documentation scraping and AI integration toolkit. Scrape any documentation website, create structured databases, and integrate with Claude Desktop via MCP (Model Context Protocol) for seamless AI-powered documentation assistance.
      5
      -
    • F
      license
      Not graded
      quality
      D
      maintenance
      Indexes documentation sites by base URL and serves keyword search, optional semantic search, and Markdown page retrieval as MCP tools, all from a single SQLite file.
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      Index any documentation website and search it from AI coding assistants via the Model Context Protocol (MCP).
      11 npm
      11
      MIT