docs-search

docs-search

Enables semantic search over documentation sites by indexing them via sitemap and using OpenAI embeddings, stored locally in ChromaDB.

Category
访问服务器

README

Documentation Search MCP Server

A Model Context Protocol (MCP) server that provides semantic search over documentation sites. Index any documentation by URL, and search it from Claude Code, Cursor, or any MCP-compatible client.

Features

  • 🔍 Semantic Search: OpenAI embeddings for intelligent documentation search
  • 🌐 Auto-Discovery: Automatically finds and parses sitemaps
  • 📦 Local Storage: ChromaDB for persistent, local vector storage
  • 🎨 Simple GUI: Gradio interface for managing indexed sites
  • 🔄 Easy Reindexing: Update documentation with one click
  • 🚀 MCP Compatible: Works with Claude Code, Cursor, and other MCP clients

Installation

Prerequisites

Setup

  1. Clone or navigate to the project directory:
cd docs-mcp-server
  1. Create a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Configure OpenAI API key:

Create a .env file in the project root:

cp .env.example .env

Edit .env and add your OpenAI API key:

OPENAI_API_KEY=sk-...

Usage

1. Launch the GUI to Index Documentation

Start the Gradio interface:

python -m src.gui

This will open a web interface at http://127.0.0.1:7860 where you can:

  • Add documentation sites by URL
  • View indexed sites and statistics
  • Reindex existing sites
  • Delete sites

Example: Indexing LangGraph docs

  1. Go to the "Add Documentation Site" tab
  2. Enter base URL: https://langchain-ai.github.io/langgraph/
  3. Leave sitemap URL empty (auto-discovery)
  4. Click "Index Site"

The indexer will:

  • Find the sitemap automatically
  • Crawl all pages
  • Convert HTML to Markdown
  • Generate embeddings
  • Store in local ChromaDB

2. Configure MCP Server

For Claude Code

Add to your Claude Code MCP settings (~/.config/claude-code/mcp.json or via Claude Code settings):

{
  "mcpServers": {
    "docs-search": {
      "command": "python",
      "args": ["-m", "src.server"],
      "cwd": "/absolute/path/to/docs-mcp-server",
      "env": {
        "OPENAI_API_KEY": "sk-..."
      }
    }
  }
}

For Cursor

Add to Cursor MCP settings:

{
  "mcpServers": {
    "docs-search": {
      "command": "python",
      "args": ["-m", "src.server"],
      "cwd": "/absolute/path/to/docs-mcp-server",
      "env": {
        "OPENAI_API_KEY": "sk-..."
      }
    }
  }
}

3. Use the Search Tool

Once configured, you can use the search_docs tool in your MCP client:

Example queries:

  • "How do I create a state graph in LangGraph?"
  • "What are the different types of nodes in LangGraph?"
  • "Show me examples of conditional edges"

The tool will return relevant documentation chunks with:

  • Source URL
  • Similarity score
  • Page content

Project Structure

docs-mcp-server/
├── src/
│   ├── __init__.py        # Package initialization
│   ├── server.py          # MCP server implementation
│   ├── indexer.py         # Documentation crawler and indexer
│   ├── embedder.py        # OpenAI embedding generation
│   ├── db.py              # ChromaDB wrapper
│   └── gui.py             # Gradio management interface
├── data/
│   ├── chroma/            # ChromaDB storage (auto-created)
│   └── config.json        # Indexed sites configuration
├── requirements.txt       # Python dependencies
├── .env.example           # Environment variables template
└── README.md              # This file

How It Works

  1. Indexing Pipeline:

    • Discovers sitemap from base URL
    • Fetches all pages from sitemap
    • Converts HTML to clean Markdown
    • Splits content into overlapping chunks
    • Generates embeddings using OpenAI
    • Stores in ChromaDB with metadata
  2. Search Process:

    • User query is embedded using OpenAI
    • ChromaDB performs cosine similarity search
    • Top results are returned with metadata
    • Results include source URL and similarity score

Configuration Options

Indexing Parameters

When adding a site via GUI or code:

  • base_url: Main documentation URL (required)
  • sitemap_url: Custom sitemap URL (optional, auto-discovered if not provided)
  • max_pages: Limit number of pages to index (optional, useful for testing)

Chunking

Default chunk settings in indexer.py:

  • chunk_size: 1000 characters
  • overlap: 200 characters

These can be adjusted in the chunk_text() method for your specific needs.

Embedding Model

Default: text-embedding-3-small (OpenAI)

To use a different model, modify embedder.py:

self.model = "text-embedding-3-large"  # More accurate but more expensive

Troubleshooting

"No documentation has been indexed yet"

Run the GUI and add at least one documentation site before using the search tool.

"Could not find sitemap.xml"

Some sites don't have a sitemap. Try providing the sitemap URL manually or ensure the site has a publicly accessible sitemap.

"OpenAI API key not found"

Make sure your .env file exists and contains a valid OPENAI_API_KEY.

ChromaDB errors

Delete the data/chroma/ directory to reset the database:

rm -rf data/chroma/

Then reindex your sites.

Cost Estimation

OpenAI Embedding Costs (text-embedding-3-small):

  • ~$0.02 per 1M tokens
  • Average documentation site (500 pages): ~$0.10-0.50
  • Search queries: ~$0.0001 per query

Storage:

  • ChromaDB is stored locally (no cloud costs)
  • Average site: 50-200 MB

Advanced Usage

Programmatic Indexing

You can index sites programmatically:

from src.embedder import Embedder
from src.db import DocsDatabase
from src.indexer import DocumentIndexer

embedder = Embedder(api_key="sk-...")
database = DocsDatabase()
indexer = DocumentIndexer(embedder, database)

result = indexer.index_site(
    base_url="https://docs.example.com",
    max_pages=100  # Optional limit
)

print(f"Indexed {result['pages_indexed']} pages")

Custom Search

from src.embedder import Embedder
from src.db import DocsDatabase

embedder = Embedder()
database = DocsDatabase()

# Search
query_embedding = embedder.embed_text("your query")
results = database.search_all_collections(query_embedding, n_results=10)

for result in results:
    print(f"URL: {result['metadata']['url']}")
    print(f"Content: {result['document'][:200]}...")

Roadmap

  • [ ] Support for custom embedding models (local transformers)
  • [ ] Incremental updates (detect changed pages)
  • [ ] Better HTML parsing for specific doc frameworks
  • [ ] Export/import indexed data
  • [ ] REST API for search
  • [ ] Support for PDF documentation

Contributing

Contributions welcome! Some ideas:

  • Add support for more documentation formats
  • Improve HTML to Markdown conversion
  • Add more embedding providers
  • Enhance the GUI

License

MIT License - feel free to use and modify!

Credits

Built with:

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选