MkDocs MCP Server

MkDocs MCP Server

Enables AI assistants to access and search MkDocs documentation through tools for full-text search, page navigation, and code block extraction. It serves documentation pages as readable resources and provides structural outlines to help LLMs navigate documentation content.

Category
访问服务器

README

MkDocs MCP Example

Python MkDocs MCP uv License: MIT

A comprehensive example project demonstrating the integration of MkDocs Material documentation with a Model Context Protocol (MCP) server, showcasing modern Python development practices with uv, devcontainers, and VSCode.

🌟 Features

📚 Beautiful Documentation

  • MkDocs Material theme with modern design
  • Responsive layout for all devices
  • Advanced search with full-text indexing
  • Dark/light mode with system preference detection
  • Mermaid diagrams and syntax highlighting
  • Auto-generated API documentation with mkdocstrings

🤖 AI-Powered Documentation Access

  • MCP Server providing AI access to documentation
  • Resource serving for direct content access
  • Advanced search tools for content discovery
  • Code block extraction and analysis
  • Page outline generation and navigation

🛠️ Modern Development Stack

  • Python 3.11+ with type hints and modern practices
  • uv for lightning-fast dependency management
  • DevContainers for consistent development environments
  • VSCode integration with comprehensive tooling
  • Rootless Podman support for secure containerization

🧪 Quality Assurance

  • Comprehensive testing with pytest and coverage
  • Code formatting with Ruff
  • Type checking with MyPy
  • Pre-commit hooks for automated quality checks
  • CI/CD ready configuration

🚀 Quick Start

Prerequisites

  • Podman (rootless preferred)
  • VSCode with Dev Containers extension
  • Git

1. Clone & Open

git clone https://github.com/robmatesick/mkdocs-mcp-example.git
cd mkdocs-mcp-example
code .

2. Start DevContainer

  • Press Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (macOS)
  • Select "Dev Containers: Reopen in Container"
  • Wait for container setup (~5-10 minutes on first run)

3. Start Development

# Terminal 1: Documentation server
make docs-serve

# Terminal 2: MCP server
make mcp-server

Visit http://localhost:8000 to see your documentation!

📁 Project Structure

mkdocs-mcp-example/
├── 📁 docs/                    # Documentation source
│   ├── index.md               # Homepage
│   ├── getting-started/       # Setup guides
│   ├── mcp-server/           # MCP documentation  
│   ├── api/                  # Auto-generated API docs
│   └── examples/             # Usage examples
│
├── 📁 mkdocs-site/            # MkDocs configuration
│   ├── mkdocs.yml            # Main configuration
│   ├── pyproject.toml        # Dependencies
│   └── docs/                 # Theme customizations
│
├── 📁 mcp-server/             # MCP server implementation
│   ├── src/mkdocs_mcp/       # Source code
│   │   ├── server.py         # Main server
│   │   ├── resources.py      # Resource management
│   │   └── tools.py          # Search tools
│   ├── tests/                # Unit tests
│   └── pyproject.toml        # Dependencies
│
├── 📁 .devcontainer/          # DevContainer config
├── 📁 .vscode/                # VSCode settings
├── 📁 tests/                  # Integration tests
├── pyproject.toml             # Workspace configuration
├── Makefile                   # Development commands
└── README.md                  # This file

🔧 Development Commands

The project includes a comprehensive Makefile with common development tasks:

📦 Setup & Installation

make setup          # Complete development setup
make install        # Install dependencies only

🧹 Code Quality

make format         # Format code with Ruff
make lint           # Lint code and fix issues
make typecheck      # Run MyPy type checking
make quality        # Run all quality checks

🧪 Testing

make test           # Run all tests
make test-cov       # Run tests with coverage
make test-watch     # Run tests in watch mode

📚 Documentation

make docs-serve     # Start documentation server
make docs-build     # Build static documentation
make docs-clean     # Clean build artifacts

🤖 MCP Server

make mcp-server     # Start MCP server
make mcp-test       # Run MCP server tests

🚀 Development Workflow

make dev            # Start both docs and MCP server
make clean          # Clean all build artifacts
make ci-check       # Run all CI checks

🏗️ Architecture

graph TB
    A[📚 MkDocs Site] --> B[📄 Documentation Files]
    B --> C[🤖 MCP Server]
    C --> D[🧠 AI Assistant]
    D --> E[👥 Users]
    
    F[👨‍💻 Developer] --> G[🐳 DevContainer]
    G --> H[📦 uv Environment]
    H --> A
    H --> C
    
    I[🔄 CI/CD] --> J[🧪 Tests]
    I --> K[🏗️ Build]
    I --> L[🚀 Deploy]

🤖 MCP Server Usage

The MCP server provides AI assistants with direct access to your documentation:

Available Resources

  • Documentation pages as readable resources
  • Automatic metadata extraction from frontmatter
  • Hierarchical navigation support

Available Tools

  • search_docs - Full-text search across documentation
  • find_by_title - Find pages by title or heading
  • list_pages - List all available documentation pages
  • get_page_outline - Extract page structure and headings
  • search_code_blocks - Find and filter code examples

Example Usage

from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client

# Connect to MCP server
server_params = StdioServerParameters(
    command="python", 
    args=["-m", "mkdocs_mcp.server"]
)

async with stdio_client(server_params) as (read, write):
    async with ClientSession(read, write) as session:
        # List available documentation
        resources = await session.list_resources()
        print(f"Found {len(resources.resources)} pages")
        
        # Search documentation
        result = await session.call_tool("search_docs", {
            "query": "installation",
            "max_results": 5
        })
        print(result.content[0].text)

🏃‍♂️ Getting Started Guide

For Documentation Writers

  1. Edit content in the docs/ directory
  2. Add new pages and update navigation in mkdocs.yml
  3. Preview changes at http://localhost:8000
  4. Use Markdown features like admonitions, code blocks, and diagrams

For Python Developers

  1. Modify MCP server in mcp-server/src/mkdocs_mcp/
  2. Add new tools or resources for AI access
  3. Run tests with make test
  4. Follow type hints and modern Python practices

For DevOps Engineers

  1. Customize DevContainer in .devcontainer/
  2. Configure CI/CD pipelines using the Makefile targets
  3. Deploy documentation using MkDocs build outputs
  4. Monitor MCP server performance and usage

🔒 Security & Best Practices

  • Rootless containers for enhanced security
  • No secrets in code - use environment variables
  • Input validation in MCP server endpoints
  • Type safety with comprehensive type hints
  • Dependency scanning with automated security checks

📖 Documentation

Complete documentation is available at:

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Setup

  1. Fork the repository
  2. Clone your fork
  3. Open in DevContainer
  4. Run make setup
  5. Make your changes
  6. Run make ci-check
  7. Submit a pull request

📋 Requirements

System Requirements

  • OS: Linux, macOS, or Windows with WSL2
  • RAM: 4GB minimum, 8GB recommended
  • Storage: 2GB free space

Software Requirements

  • Python: 3.11 or higher
  • Podman: Latest stable version
  • VSCode: With Dev Containers extension
  • Git: For version control

🆘 Troubleshooting

Common Issues

Container build fails

# Clean Podman cache and try again
podman system prune -a

# Or rebuild DevContainer from VSCode
# Ctrl+Shift+P -> "Dev Containers: Rebuild Container"

Port conflicts

make docs-serve MKDOCS_PORT=8002

Dependency issues

make clean
make dev-install

See the Troubleshooting Guide for more solutions.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

📞 Support


Star this repo if you find it helpful!

Built with ❤️ using modern Python development practices.

推荐服务器

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

官方
精选