Documentation Fetcher & RAG Search

Documentation Fetcher & RAG Search

Enables AI assistants to fetch, index, and perform semantic RAG-based searches on API documentation from various sources. It provides tools for hybrid search and collection management, allowing users to access up-to-date documentation from projects like Gemini and FastMCP.

Category
访问服务器

README

Documentation Fetcher & RAG Search

A modular system for fetching API documentation and enabling semantic search via RAG (Retrieval-Augmented Generation). Designed to give AI coding assistants like Claude access to up-to-date documentation from any project.

Features

  • Fetch Documentation: Download complete documentation from API providers in markdown format
  • Semantic Search: Hybrid search combining vector embeddings with keyword matching
  • MCP Server: Expose search as tools accessible from Claude Code in any project
  • Modular Design: Easy to add new documentation sources

Supported Documentation Sources

Source Documents Description
Gemini ~2000 Google Gemini API - LLM, function calling, embeddings, multimodal
FastMCP ~1900 FastMCP framework - MCP servers, tools, resources, authentication

Quick Start

Prerequisites

  • Python 3.12+
  • Ollama with bge-m3 model
  • Claude Code (for MCP integration)

Installation

# Clone the repository
git clone <repository-url>
cd documentation

# Create virtual environment
python3.12 -m venv .venv
source .venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Pull the embedding model
ollama pull bge-m3

Fetch & Index Documentation

# Fetch documentation
python -m src.main fetch gemini
python -m src.main fetch fastmcp

# Index for search (requires Ollama running)
python -m src.rag.index gemini
python -m src.rag.index fastmcp

Search Documentation

# Search Gemini docs
python -m src.main search "function calling"

# Search FastMCP docs
python -m src.main search "how to create a tool" -c fastmcp

# More results
python -m src.main search "rate limits" -n 10

MCP Server Integration

The MCP server exposes documentation search as tools that Claude Code can use from any project.

Install in Claude Code

IMPORTANT: MCP configuration requires absolute paths. The cwd field is NOT supported by Claude Code.

Option 1: Using Claude CLI (recommended)

# Replace /path/to/documentation with your actual absolute path
claude mcp add docs-search --scope user --transport stdio -- \
  /path/to/documentation/.venv/bin/python \
  /path/to/documentation/src/mcp_server.py

Option 2: Add to ~/.claude.json manually

{
  "mcpServers": {
    "docs-search": {
      "command": "/path/to/documentation/.venv/bin/python",
      "args": ["/path/to/documentation/src/mcp_server.py"]
    }
  }
}

Common mistakes to avoid:

  • Do NOT use cwd - it's not a valid MCP configuration field
  • Do NOT use relative paths - they resolve from the caller's directory
  • Do NOT use -m src.mcp_server - this requires being in the project directory

Verify Installation

# Check server is registered
claude mcp list

# In Claude Code, check connection status
/mcp

Available Tools

Tool Description
search_docs(query, collection, num_results) Search documentation with hybrid semantic + keyword search
list_collections() List available documentation collections

Available Resources

Resource URI Description
docs://collections JSON list of all collections
docs://gemini/pages List of all Gemini documentation pages
docs://fastmcp/pages List of all FastMCP documentation pages
docs://gemini/search-help Search tips for Gemini docs
docs://fastmcp/search-help Search tips for FastMCP docs

Usage from Claude Code

Once installed, you can ask Claude from any project:

  • "Search the gemini docs for function calling"
  • "What documentation collections are available?"
  • "Search fastmcp for how to create tools"
  • "Find rate limit information in gemini docs"

Project Structure

documentation/
├── src/
│   ├── main.py                 # CLI entry point
│   ├── mcp_server.py           # MCP server for Claude Code
│   ├── core/
│   │   ├── fetcher.py          # HTTP/markdown fetching
│   │   └── parser.py           # Navigation parsing
│   ├── modules/
│   │   ├── base.py             # Abstract base class
│   │   ├── gemini/             # Gemini documentation module
│   │   └── fastmcp/            # FastMCP documentation module
│   └── rag/
│       ├── chunker.py          # Markdown-aware chunking
│       ├── embedder.py         # Ollama bge-m3 embeddings
│       ├── sqlite_store.py     # SQLite + sqlite-vec vector store
│       ├── search.py           # Hybrid search with RRF
│       ├── query_expander.py   # Multi-query expansion (LLM)
│       ├── reranker.py         # Cross-encoder reranking
│       └── index.py            # Indexing CLI
├── output/                     # Fetched documentation
│   ├── gemini/
│   └── fastmcp/
├── data/
│   └── docs.db                 # SQLite vector database
├── requirements.txt
└── README.md

Adding New Documentation Sources

  1. Create a new module in src/modules/<name>/:
# src/modules/example/config.py
BASE_URL = "https://docs.example.com"
SITEMAP_URL = "https://docs.example.com/sitemap.xml"
MARKDOWN_SUFFIX = ".md"  # or ".md.txt" for Google sites
# src/modules/example/module.py
from src.modules.base import BaseModule

class ExampleModule(BaseModule):
    @property
    def name(self) -> str:
        return "example"

    def get_doc_urls(self) -> list[NavLink]:
        # Parse sitemap or navigation
        ...

    def fetch_page(self, url: str) -> str:
        # Fetch markdown content
        ...
  1. Register in src/main.py:
from src.modules.example.module import ExampleModule

# In fetch_command():
elif args.module == "example":
    module = ExampleModule()
    module.run(output_dir)
  1. Add to KNOWN_COLLECTIONS in src/mcp_server.py

  2. Fetch and index:

python -m src.main fetch example
python -m src.rag.index example

How It Works

Fetching

  1. Parse navigation/sitemap to discover documentation pages
  2. Fetch each page in markdown format (using source-specific tricks like .md.txt suffix)
  3. Save with source URL metadata

Indexing

  1. Chunk markdown by headers (preserving code blocks)
  2. Generate embeddings via Ollama bge-m3 (1024 dimensions)
  3. Store in SQLite with sqlite-vec (vectors) and FTS5 (keywords)

Searching

  1. Generate query embedding
  2. Perform semantic search (sqlite-vec vector similarity)
  3. Perform keyword search (FTS5 BM25)
  4. Combine with Reciprocal Rank Fusion (RRF)
  5. Optionally expand query with LLM variations
  6. Optionally rerank with cross-encoder
  7. Return ranked results with source URLs

Configuration

Environment Variables

Variable Description Default
OLLAMA_HOST Ollama server URL http://localhost:11434

SQLite Database

Vector database stored in data/docs.db. Each documentation source gets its own collection within the database.

Development

# Run tests
python -m pytest

# Check MCP server
claude mcp list

# Test search functionality
python -m src.rag.search

Troubleshooting

"Ollama connection failed"

# Make sure Ollama is running
ollama serve

# Pull the embedding model
ollama pull bge-m3

"No results found"

# Check if collection is indexed
python -m src.rag.index --status gemini

# Re-index if needed
python -m src.rag.index --clear gemini

MCP server not connecting

# Check server status
claude mcp list

# Reinstall
claude mcp remove docs-search
fastmcp install claude-code src/mcp_server.py --name docs-search

License

MIT

Credits

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选