MkDocs MCP Plugin

MkDocs MCP Plugin

Enables AI agents to interact with MkDocs documentation through intelligent search (keyword, vector, and hybrid), document retrieval, and automatic indexing. Automatically detects and launches MkDocs projects for seamless documentation querying.

Category
访问服务器

README

MkDocs MCP Plugin 🔍

A comprehensive MCP (Model Context Protocol) server for MkDocs documentation that provides intelligent search, retrieval, and integration capabilities for AI agents. This plugin automatically detects MkDocs projects, launches the development server, and provides powerful tools for querying documentation.

Features

🚀 Auto-Detection & Integration

  • Automatically detects mkdocs.yml or mkdocs.yaml in your project
  • Launches MkDocs development server alongside the MCP server
  • Seamless integration with existing MkDocs workflows

🔎 Advanced Search Capabilities

  • Keyword Search: Fast, accurate text-based search using Whoosh indexing
  • Vector Search: Semantic search using sentence transformers (all-MiniLM-L6-v2)
  • Hybrid Search: Combines both keyword and semantic search for optimal results
  • Real-time Indexing: Automatically indexes markdown files with full-text search

📄 Document Operations

  • Read individual markdown files with metadata extraction
  • List all available documentation with titles and paths
  • Extract headings, titles, and content structure
  • Support for nested directory structures

🤖 MCP Protocol Compliance

  • Full MCP server implementation using FastMCP
  • Tools, resources, and prompts for agent interaction
  • Structured responses with comprehensive error handling
  • Support for concurrent agent connections

Installation

Using UV/UVX (Recommended)

Install and run directly with uvx:

# Install and run in one command
uvx mkdocs-mcp-plugin

# Or install globally
uv tool install mkdocs-mcp-plugin

# Then run from any MkDocs project
mkdocs-mcp

Using pip

# Install from source
pip install git+https://github.com/douinc/mkdocs-mcp-plugin.git

# Or clone and install locally
git clone https://github.com/douinc/mkdocs-mcp-plugin.git
cd mkdocs-mcp-plugin
pip install -e .

Development Installation

git clone https://github.com/douinc/mkdocs-mcp-plugin.git
cd mkdocs-mcp-plugin

# Install with UV (recommended)
uv sync --all-extras

# Or with pip
pip install -e ".[dev]"

Usage

Basic Usage

Navigate to any directory containing a mkdocs.yml file and run:

mkdocs-mcp

The server will:

  1. Detect your MkDocs configuration
  2. Start the MkDocs development server (default: http://localhost:8000)
  3. Launch the MCP server for agent interaction
  4. Index your documentation for search

Configuration

The server automatically adapts to your MkDocs configuration:

# mkdocs.yml
site_name: My Documentation
docs_dir: docs  # Custom docs directory
site_url: https://mydocs.example.com
theme:
  name: material
plugins:
  - search

Environment Variables

  • MKDOCS_PORT: Port for the MkDocs server (default: 8000)
  • MCP_PORT: Port for the MCP server (auto-selected)

MCP Tools

Document Operations

read_document

Read a specific markdown file with metadata:

{
  "file_path": "getting-started.md",
  "docs_dir": "docs"  # Optional, auto-detected
}

list_documents

Get a list of all available documentation:

{
  "docs_dir": "docs"  # Optional, auto-detected
}

Search Operations

search (Hybrid Search)

Combines keyword and semantic search:

{
  "query": "authentication setup",
  "search_type": "hybrid",  # "keyword", "vector", or "hybrid"
  "max_results": 10
}

keyword_search

Fast text-based search:

{
  "query": "configuration options",
  "max_results": 10
}

vector_search

Semantic similarity search:

{
  "query": "how to deploy",
  "max_results": 10
}

Utility Tools

get_mkdocs_info

Get information about the current MkDocs project:

{}  # No parameters required

restart_mkdocs_server

Restart the MkDocs development server:

{
  "port": 8001  # Optional, defaults to 8000
}

rebuild_search_index

Rebuild the search index:

{
  "docs_dir": "docs"  # Optional, auto-detected
}

MCP Resources

mkdocs://documents

Access to document metadata and structure:

{
  "document_count": 25,
  "docs_dir": "/path/to/docs",
  "documents": [
    {
      "path": "index.md",
      "title": "Welcome",
      "size": 1024
    }
  ]
}

MCP Prompts

mkdocs-rag-search

Generate intelligent search queries for documentation:

{
  "topic": "authentication"  # Search topic
}

Advanced Features

Vector Search Dependencies

For semantic search capabilities, ensure these packages are installed:

# Included in default installation
pip install sentence-transformers scikit-learn numpy

If these packages are not available, the server will fall back to keyword-only search.

Custom Index Configuration

The server uses Whoosh for indexing with the following schema:

  • path: Document file path
  • title: Document title (from first H1 or filename)
  • content: Full text content (markdown converted to plain text)
  • headings: All heading text for structural search

Search Result Structure

All search operations return results in this format:

{
  "success": true,
  "query": "your search query",
  "result_count": 5,
  "results": [
    {
      "path": "docs/api/authentication.md",
      "title": "Authentication Guide",
      "score": 0.95,
      "snippet": "...highlighted excerpt...",
      "search_methods": ["keyword", "vector"]
    }
  ]
}

Integration Examples

Claude Code Configuration

Add to your Claude Code config:

{
  "mcpServers": {
    "mkdocs-mcp": {
      "command": "uvx",
      "args": [
        "--from",
        "git+https://github.com/douinc/mkdocs-mcp-plugin",
        "--with",
        "mkdocs-material",
        "--with",
        "mkdocs-git-revision-date-localized-plugin",
        "--with",
        "mkdocs-minify-plugin",
        "--with",
        "mkdocs-mermaid2-plugin",
        "--with",
        "mkdocs-print-site-plugin",
        "mkdocs-mcp"
      ],
      "env": {
        "MKDOCS_PORT": "8000"
      }
    }
  }
}

Error Handling

The server provides comprehensive error handling:

  • Missing MkDocs: Graceful fallback to MCP-only mode
  • Invalid configurations: Clear error messages with suggestions
  • Search failures: Automatic fallback between search methods
  • File access errors: Detailed error reporting with context

Troubleshooting

Common Issues

  1. MkDocs server not starting:

    # Check if MkDocs is installed
    mkdocs --version
    
    # Install if missing
    pip install mkdocs
    
  2. Vector search not working:

    # Install optional dependencies
    pip install sentence-transformers
    
  3. Permission errors:

    # Check file permissions
    ls -la mkdocs.yml
    

Debug Mode

Run with verbose output:

# Set environment variable for debug output
MKDOCS_DEBUG=1 mkdocs-mcp

Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Make your changes
  4. Run tests: uv run pytest
  5. Format code: uv run black . && uv run ruff check --fix .
  6. Submit a pull request

Development Setup

git clone https://github.com/douinc/mkdocs-mcp-plugin.git
cd mkdocs-mcp-plugin

# Install with all dependencies
uv sync --all-extras

# Run tests
uv run pytest

# Run linting
uv run ruff check
uv run black --check .

License

MIT License - see LICENSE file for details.

Changelog

v0.1.0

  • Initial release
  • MkDocs auto-detection and server integration
  • Hybrid search with keyword and vector capabilities
  • Full MCP protocol compliance
  • UV/UVX support

Support


Built with ❤️ by dou inc.

推荐服务器

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

官方
精选