LLMDoc
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@LLMDoc how do I create a tool in FastMCP?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
LLMDoc
MCP server with RAG (BM25) for llms.txt documentation. Provides semantic search across documentation sources with automatic background refresh.
Features
llms.txt support - Automatically parses and indexes documentation from llms.txt files
Hybrid two-stage search - DuckDB FTS with Porter stemming for broad recall, BM25 reranking for precision
Named sources - Configure sources with names like
fast_mcp:https://...for easy filteringSource filtering - Search across all sources or filter by specific source name
Persistent storage - DuckDB-based index that survives restarts
Background refresh - Configurable auto-refresh interval (default: 6 hours)
Source attribution - Every search result includes source name and URL
Related MCP server: team-docs-mcp
Quick Start
Add to Claude Code (
~/.claude/claude_code_config.json):
{
"mcpServers": {
"llmdoc": {
"command": "uvx",
"args": ["llmdoc"],
"env": {
"LLMDOC_SOURCES": "fast_mcp:https://gofastmcp.com/llms.txt"
}
}
}
}Restart Claude Code - the server will automatically fetch and index documentation.
Ask Claude questions like "How do I create a tool in FastMCP?" and it will search the indexed docs.
What is llms.txt?
llms.txt is a specification for providing LLM-friendly documentation. Websites add a /llms.txt markdown file to their root directory containing curated, concise content optimized for AI consumption. LLMDoc indexes these files and their linked documents to enable semantic search.
Example sources:
Installation
# Run directly with uvx (no install needed)
uvx llmdoc
# Or install with uv
uv tool install llmdoc
# Or install with pip
pip install llmdoc
# Or install with pipx
pipx install llmdocConfiguration
Source Format
Sources can be specified in two formats:
Named:
name:url- e.g.,fast_mcp:https://gofastmcp.com/llms.txtUnnamed: Just the URL - name is auto-generated from domain
Named sources allow you to filter search results by source name.
Environment Variables
# Comma-separated list of sources (named or unnamed)
export LLMDOC_SOURCES="fast_mcp:https://gofastmcp.com/llms.txt,pydantic_ai:https://ai.pydantic.dev/llms.txt"
# Optional: Custom database path (default: ~/.llmdoc/index.db)
export LLMDOC_DB_PATH="/path/to/index.db"
# Optional: Refresh interval in hours (default: 6)
export LLMDOC_REFRESH_INTERVAL="6"
# Optional: Max concurrent document fetches (default: 5)
export LLMDOC_MAX_CONCURRENT="5"
# Optional: Skip refresh on startup (default: false)
export LLMDOC_SKIP_STARTUP_REFRESH="true"
# Optional: Disable FTS indexing and use pure BM25 (default: true)
export LLMDOC_ENABLE_FTS="false"Config File
Create llmdoc.json in the working directory:
{
"sources": [
"fast_mcp:https://gofastmcp.com/llms.txt",
"pydantic_ai:https://ai.pydantic.dev/llms.txt"
],
"db_path": "~/.llmdoc/index.db",
"refresh_interval_hours": 6,
"max_concurrent_fetches": 5,
"skip_startup_refresh": false,
"enable_fts": true
}Or with explicit name/url objects:
{
"sources": [
{"name": "fast_mcp", "url": "https://gofastmcp.com/llms.txt"},
{"name": "pydantic_ai", "url": "https://ai.pydantic.dev/llms.txt"}
]
}Running the Server
LLMDoc uses stdio transport and is designed to be launched by MCP clients. Configure it in your MCP client (see below), and the client will start the server automatically.
For manual testing:
# Using uvx
uvx llmdoc
# Or as module
python -m llmdocMCP Tools
search_docs(query, limit, source)- Search documentation and return relevant passages with source URLs. Optionalsourceparameter filters by source name (e.g.,fast_mcp)get_doc(url, offset, limit)- Get document content with pagination support for large documents. Parameters:offset(default: 0) start position in bytes,limit(default: 50000, max: 100000) max bytes per call. Returns pagination metadata (has_more,total_length)get_doc_excerpt(url, query, max_chunks, context_chars)- Get relevant excerpts from a large document matching a querylist_sources()- List all configured documentation sources with statisticsrefresh_sources()- Manually trigger a refresh of all documentation
MCP Resources
doc://sources- Returns JSON with configured sources list and refresh interval
Adding to MCP Clients
Claude Code
Add to ~/.claude/claude_code_config.json:
{
"mcpServers": {
"llmdoc": {
"command": "uvx",
"args": ["llmdoc"],
"env": {
"LLMDOC_SOURCES": "fast_mcp:https://gofastmcp.com/llms.txt,pydantic_ai:https://ai.pydantic.dev/llms.txt"
}
}
}
}Standard MCP Configuration
Add to your MCP client's configuration file:
{
"mcpServers": {
"llmdoc": {
"command": "uvx",
"args": ["llmdoc"],
"env": {
"LLMDOC_SOURCES": "fast_mcp:https://gofastmcp.com/llms.txt"
}
}
}
}Example Usage
Once configured, the LLM can use these tools:
User: How do I create a tool in FastMCP?
LLM: [calls search_docs("create tool FastMCP")]
Result:
[
{
"title": "Tools",
"snippet": "Creating a tool is as simple as decorating a Python function with @mcp.tool...",
"url": "https://gofastmcp.com/servers/tools.md",
"source": "fast_mcp",
"source_url": "https://gofastmcp.com/llms.txt",
"score": 12.5
}
]Filtering by Source
You can filter results to a specific documentation source:
User: How do I create an agent in PydanticAI?
LLM: [calls search_docs("create agent", source="pydantic_ai")]
Result:
[
{
"title": "Agents",
"snippet": "Agents are the primary interface for interacting with LLMs in PydanticAI...",
"url": "https://ai.pydantic.dev/agents.md",
"source": "pydantic_ai",
"source_url": "https://ai.pydantic.dev/llms.txt",
"score": 10.2
}
]Getting Full Document Content
Use get_doc to retrieve document content (supports pagination for large documents):
LLM: [calls get_doc("https://ai.pydantic.dev/agents.md")]
Result:
{
"title": "Agents",
"content": "# Agents\n\nAgents are the primary interface for interacting with LLMs in PydanticAI...",
"url": "https://ai.pydantic.dev/agents.md",
"source": "pydantic_ai",
"source_url": "https://ai.pydantic.dev/llms.txt",
"offset": 0,
"length": 5432,
"total_length": 5432,
"has_more": false
}Architecture
+------------------+
| MCP Client |
| (Claude, Cursor) |
+--------+---------+
| stdio
v
+------------------+ +------------------+ +------------------+
| FastMCP Server |---->| Document Store |<----|Document Fetcher |
| | | (DuckDB) | | (async HTTP) |
| - search_docs | | | | |
| - get_doc | | - Persistence | | - llms.txt parse |
| - list_sources | | - Deduplication | | - HTML→Markdown |
| - refresh | | - Change detect | | - Concurrent |
+--------+---------+ +------------------+ +------------------+
|
v
+------------------+
| BM25 Index |
| (in-memory) |
| |
| - Chunking |
| - Tokenization |
| - Scoring |
+------------------+LLMDoc fetches documentation from llms.txt sources, stores it in DuckDB, and provides fast BM25 search through the MCP protocol.
How It Works
Document Fetching
When configured with documentation sources, LLMDoc:
Parses llms.txt files to discover all linked documents
Fetches each document concurrently (with rate limiting)
Converts HTML pages to Markdown automatically
Extracts titles from the first H1 heading
Indexing
Documents are processed for efficient search:
Chunking: Large documents are split into ~500 character chunks at sentence boundaries
Tokenization: Text is lowercased and stopwords are removed
Indexing: BM25 algorithm indexes all chunks for relevance scoring
Search
LLMDoc uses a hybrid two-stage retrieval approach:
Stage 1 - DuckDB FTS (Recall):
Query is processed by DuckDB's full-text search with Porter stemming
"running" matches "run", "café" matches "cafe"
Top 100 candidate chunks are retrieved
Stage 2 - Python BM25 (Precision):
Candidates are re-scored using exact-match BM25
Documents with exact query terms rank higher
Results are deduplicated by document URL
Top results are returned with relevance scores and snippets
Background Refresh
LLMDoc automatically keeps documentation up-to-date:
Checks for staleness on startup
Refreshes every 6 hours (configurable)
Uses content hashing to skip unchanged documents
Removes documents no longer in llms.txt
Technical Details
Hybrid Two-Stage Search
LLMDoc combines DuckDB's native FTS with Python BM25 for optimal search quality:
Stage 1 - DuckDB FTS:
Porter stemming normalizes words (running → run, documents → document)
Accent handling (café → cafe)
571 built-in English stopwords
Fast candidate retrieval using native C implementation
Stage 2 - Python BM25:
BM25Okapi algorithm from
rank_bm25libraryExact term matching boosts precise matches
Term frequency saturation, document length normalization, IDF weighting
Thread-safe using
threading.RLock()
Chunking Strategy
Documents are chunked using a multi-level approach:
Paragraph splitting: First split on double newlines (
\n\n)Sentence-boundary aware: Long paragraphs split at
.!?followed by whitespaceOverlap: 100 character overlap between chunks maintains context
Configuration:
chunk_size: 500 characters (default)chunk_overlap: 100 characters (default)
Database Schema
DuckDB stores documents and chunks:
CREATE TABLE documents (
id INTEGER PRIMARY KEY,
source_name TEXT NOT NULL, -- e.g., 'fast_mcp'
source_url TEXT NOT NULL, -- llms.txt URL
doc_url TEXT NOT NULL UNIQUE, -- document URL
title TEXT,
content TEXT NOT NULL,
content_hash TEXT NOT NULL, -- SHA256 for change detection
updated_at TIMESTAMP NOT NULL
)
CREATE TABLE chunks (
id INTEGER PRIMARY KEY,
doc_id INTEGER NOT NULL, -- references documents.id
content TEXT NOT NULL, -- chunk text for FTS indexing
start_pos INTEGER NOT NULL, -- position in original document
end_pos INTEGER NOT NULL
)FTS index on chunks table with Porter stemmer for hybrid search.
Concurrency Model
LLMDoc supports multiple concurrent instances:
Read operations: Multiple instances can search simultaneously (read-only DuckDB mode)
Write operations: Single instance holds exclusive lock during refresh
Graceful handling: If refresh is locked, operation skips with status message
Document fetching uses asyncio.Semaphore to limit concurrent HTTP requests (default: 5).
Stopwords
Two stopword lists are used:
DuckDB FTS (Stage 1): 571 built-in English stopwords
Python BM25 (Stage 2): 209 custom stopwords including articles, prepositions, pronouns, auxiliaries, and common verbs
License
MIT License - see LICENSE file.
Available Tools
5 toolsget_docGet DocumentARead-onlyIdempotent
Get document content with pagination support for large documents.
For documents larger than 50KB, use offset/limit to paginate through content. The response includes has_more=True if more content is available. For targeted retrieval, use get_doc_excerpt instead.
Args: url: The URL of the document (as returned by search_docs). offset: Start position in bytes (default: 0). limit: Max bytes to return per call (default: 50000, max: 100000).
Returns: Document with content chunk, pagination metadata (offset, length, total_length, has_more).
Inputs: url (required), limit, offset. Returns: Full document content with pagination support.
get_doc_excerptGet Document ExcerptARead-onlyIdempotent
Get relevant excerpts from a large document matching a query.
Use this instead of get_doc for large documents. Returns targeted excerpts based on BM25 relevance to your query.
Args: url: The URL of the document. query: Query to find relevant sections within the document. max_chunks: Maximum number of chunks to return (default: 5). context_chars: Extra context characters around each chunk (default: 500).
Returns: Document metadata with list of relevant excerpts, each containing content, position, and relevance score.
Inputs: url (required), query (required), max_chunks, context_chars. Returns: Document with relevant excerpts.
list_sourcesList SourcesARead-onlyIdempotent
List all configured documentation sources with their statistics.
Use this to discover what documentation sources are available for searching. Each source has a name that can be used to filter search_docs results.
Returns: List of sources with name, url, doc_count, and last_updated.
Inputs: no named parameters. Returns: result
refresh_sourcesRefresh SourcesA
Manually trigger a refresh of all documentation sources.
This fetches documentation from all configured llms.txt URLs and updates the local index. Use this when you need the latest documentation content.
Returns: Dictionary with refreshed_count, indexed_documents, indexed_chunks, sources, and any errors.
Inputs: no named parameters. Returns: Result of a refresh operation.
search_docsSearch DocumentationARead-onlyIdempotent
Search documentation and return relevant passages with source URLs.
Use this tool when you need to find information about specific topics, APIs, or concepts. The search uses BM25 ranking for relevance.
Args: query: The search query to find relevant documentation. limit: Maximum number of results to return (default: 5). source: Optional source name to filter results (e.g., 'fast_mcp', 'pydantic_ai').
Returns: List of search results with title, snippet, url, source (name), source_url, and score.
Inputs: query (required), limit, source. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool has a clearly distinct purpose: search_docs for global search, get_doc for full content with pagination, get_doc_excerpt for targeted extraction, list_sources for source discovery, and refresh_sources for index updates. The overlap between search_docs and get_doc_excerpt is adequately clarified by their descriptions.
All tool names follow a consistent verb_noun snake_case pattern (search_, get_, list_, refresh_), making the API predictable and easy to navigate.
With 5 tools, the server is well-scoped for a documentation search and retrieval service. Each tool is necessary and covers a distinct operation without redundancy.
The core workflow is covered: discover sources, search, retrieve full or excerpted content, and refresh the index. Minor gaps exist around source management (e.g., adding/removing sources) and listing all documents within a source, but these are not critical for standard usage.
Maintenance
Related MCP Connectors
Self-hosted AI workspace: semantic RAG document search, long-term memory, and AI chat via MCP.
MCP server for querying Forkast documentation
MCP server for langchain documentation, generated by doc2mcp.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceMCP server for semantic and hybrid search over RHEL documentation using docs2db RAG, with cross-encoder reranking and support for multiple MCP clients.4Apache 2.0
- AlicenseNot gradedqualityDmaintenanceAn MCP server for team documentation and knowledge bases, enabling semantic search over documentation files using local embeddings.MIT
- AlicenseNot gradedqualityDmaintenanceMCP server for documentation search that automatically indexes web documentation sites and provides semantic, full-text, or hybrid search capabilities.10 npmMIT
- AlicenseAqualityDmaintenanceMCP server that enables local hybrid semantic and keyword search over private PDF, DOCX, Markdown, and text documents without sending data to embedding APIs.95,381 npmMIT