api-docs-mcp
An MCP server that gives AI coding assistants access to up-to-date API documentation via RAG by crawling documentation sites, indexing them into a vector store, and enabling semantic queries.
README
api-docs-mcp
An MCP (Model Context Protocol) server that gives AI coding assistants access to up-to-date API documentation via Retrieval-Augmented Generation (RAG). Crawl any documentation site, index it into a vector store, and query it semantically — so your LLM always has accurate, current docs at its fingertips.
Problem
LLMs have stale or incomplete knowledge of specific APIs and libraries. This project solves that by letting you:
- Crawl any documentation website
- Index the content into a local vector database
- Query it semantically through an MCP server
AI assistants (like GitHub Copilot, Claude Desktop, Cursor, etc.) can then retrieve precise, current API documentation on demand.
How It Works
┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ Crawling │ ──▶│ Chunking │ ──▶│ Embedding │ ──▶│ Storage │
│ (crawl4ai) │ │ (headings + │ │ (sentence- │ │ (ChromaDB) │
│ │ │ paragraphs) │ │ transformers)│ │ │
└──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘
▲
┌──────────────┐ ┌──────────────┐ │
│ MCP Client │ ──▶│ Retrieval │ ──▶ Similarity Search ─────┘
│ (Copilot, │ │ Engine │
│ Claude, │ │ │
│ Cursor…) │ └──────────────┘
└──────────────┘
Pipeline Stages
-
Crawling — Uses
crawl4ai(headless browser) to recursively crawl a documentation site from a root URL, following links within the same domain/path prefix. Extracts clean markdown from each page. -
Chunking — Splits markdown on
h1/h2/h3headings to preserve logical structure. Builds breadcrumb heading paths (e.g.,std > HashMap > insert). Sub-splits oversized sections at paragraph boundaries with overlap. Tags chunks withhas_code=trueif they contain fenced code blocks. -
Embedding & Storage — Embeds chunks using
all-MiniLM-L6-v2(384-dim vectors viasentence-transformers), then upserts them into ChromaDB collections (one collection per programming language). -
Retrieval — Embeds the user's query, performs filtered similarity search in ChromaDB, and returns formatted results with source URLs and context.
Incremental Updates
Re-running an ingestion for the same library is efficient:
- Pages are hashed (MD5) and compared against stored hashes
- Unchanged pages are skipped entirely
- Pages removed from the site have their chunks automatically deleted
Installation
Prerequisites
- Python 3.10+
uvpackage manager
Setup
git clone https://github.com/akshaysadanand/api-docs-mcp.git
cd api-docs-mcp
uv sync
Usage
CLI
The project ships with a api-docs-mcp command-line tool for managing documentation indexes.
Index a Documentation Site
# Index Rust standard library docs
uv run api-docs-mcp add "https://doc.rust-lang.org/std/" --language rust --library std
# Index Python docs with custom limits
uv run api-docs-mcp add "https://docs.python.org/3/library/" \
--language python --library stdlib --max-pages 100 --max-depth 2
# Index with a specific version
uv run api-docs-mcp add "https://numpy.org/doc/stable/reference/" \
--language python --library numpy --version 1.26
Search Indexed Documentation
# Search across all indexed docs for a language
uv run api-docs-mcp search "how to parse JSON" --language python
# Search within a specific library
uv run api-docs-mcp search "HashMap insert or update" --language rust --library std
# Get more results (default: 5)
uv run api-docs-mcp search "async await coroutine" --language kotlin -k 10
List Indexed Sources
# List all indexed sources
uv run api-docs-mcp list
# Filter by language
uv run api-docs-mcp list --language rust
Remove Indexed Documentation
uv run api-docs-mcp remove --language rust --library tokio
CLI Reference
| Command | Description | Key Arguments |
|---|---|---|
add |
Crawl and index a documentation URL | URL, -l/--language, -L/--library, -v/--version, --max-pages, --max-depth |
search |
Search indexed docs semantically | QUERY, -l/--language, -L/--library, -k/--top-k |
list |
List all indexed sources | -l/--language (optional filter) |
remove |
Remove indexed docs for a library | -l/--language, -L/--library |
MCP Server
Configure the MCP server in your AI assistant's settings to enable documentation search from within your editor.
VS Code (GitHub Copilot)
Add to your .vscode/mcp.json or user MCP settings:
{
"inputs": [],
"servers": {
"api-docs-mcp": {
"command": "bash",
"args": ["<path-to-project>/start.sh"]
}
}
}
Or start the server directly:
uv run api-docs-mcp serve
Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"api-docs-mcp": {
"command": "uv",
"args": ["run", "api-docs-mcp", "serve"],
"cwd": "<path-to-project>"
}
}
}
Available MCP Tools
| Tool | Description | Parameters |
|---|---|---|
search_documentation |
Semantic search across indexed docs | query, language, library (optional), top_k (default: 5) |
add_documentation |
Crawl and index a new doc site | url, language, library, version, max_pages, max_depth |
list_sources |
List all indexed sources with statistics | language (optional filter) |
get_code_examples |
Search specifically for code snippets | query, language, library (optional), top_k |
lookup_api_symbol |
Exact-match symbol lookup (e.g., HashMap::insert) |
symbol, language, library (optional) |
Storage
- Database: ChromaDB (persistent, disk-based)
- Default location:
~/.local/share/api-docs-mcp/(followsXDG_DATA_HOME) - Structure: One ChromaDB collection per programming language
- Chunk metadata:
library,version,source_url,page_hash,heading_path,has_code,chunk_index - Embeddings: 384-dimensional normalized vectors from
all-MiniLM-L6-v2(~80MB model)
Configuration
| Option | Default | Description |
|---|---|---|
--max-pages |
200 | Maximum pages to crawl per run |
--max-depth |
3 | Maximum link depth from start URL |
--version |
latest |
Documentation version string |
--top-k |
5 | Number of search results (max: 20) |
| Embedding batch size | 32 | Chunks processed per embedding batch |
| Upsert batch size | 5000 | Chunks upserted to ChromaDB per batch |
Project Structure
api-docs-mcp/
├── pyproject.toml # Project metadata & dependencies
├── start.sh # MCP server startup script
├── api_docs_mcp/
│ ├── cli.py # Click-based CLI commands
│ ├── server.py # MCP server (stdio transport)
│ ├── embeddings/
│ │ └── model.py # Sentence-transformer embedding model
│ ├── ingestion/
│ │ ├── crawler.py # Headless browser web crawler
│ │ ├── chunker.py # Markdown-aware document chunking
│ │ └── processor.py # Orchestration & incremental updates
│ ├── retrieval/
│ │ └── engine.py # Semantic search engine
│ └── storage/
│ └── vector_store.py # ChromaDB vector store wrapper
├── tests/
│ ├── test_vector_store.py
│ └── test_get_metadata.py
└── docs/
└── implementation_plan.md
Dependencies
| Package | Purpose |
|---|---|
mcp |
MCP server framework (stdio transport) |
click |
CLI framework |
chromadb |
Vector database for persistent storage |
sentence-transformers |
Text embedding model (all-MiniLM-L6-v2) |
crawl4ai |
Headless browser web crawler with markdown extraction |
Examples
Indexing Multiple Libraries
# Rust ecosystem
uv run api-docs-mcp add "https://doc.rust-lang.org/std/" -l rust -L std
uv run api-docs-mcp add "https://docs.rs/tokio/latest/tokio/" -l rust -L tokio
# Python ecosystem
uv run api-docs-mcp add "https://docs.python.org/3/library/" -l python -L stdlib --max-pages 150
uv run api-docs-mcp add "https://numpy.org/doc/stable/reference/" -l python -L numpy
# Kotlin
uv run api-docs-mcp add "https://kotlinlang.org/docs/home.html" -l kotlin -L standard --max-pages 200
Typical Workflow
- Index the documentation you work with most frequently
- Configure the MCP server in your editor
- Ask your AI assistant questions like:
- "How do I use
HashMap::entryin Rust?" - "Show me examples of pandas DataFrame filtering"
- "What's the Kotlin coroutine flow API?"
- "How do I use
License
This project is open-sourced under the MIT License
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。