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.
README
MkDocs MCP Example
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) orCmd+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 documentationfind_by_title- Find pages by title or headinglist_pages- List all available documentation pagesget_page_outline- Extract page structure and headingssearch_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
- Edit content in the
docs/directory - Add new pages and update navigation in
mkdocs.yml - Preview changes at http://localhost:8000
- Use Markdown features like admonitions, code blocks, and diagrams
For Python Developers
- Modify MCP server in
mcp-server/src/mkdocs_mcp/ - Add new tools or resources for AI access
- Run tests with
make test - Follow type hints and modern Python practices
For DevOps Engineers
- Customize DevContainer in
.devcontainer/ - Configure CI/CD pipelines using the Makefile targets
- Deploy documentation using MkDocs build outputs
- 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
- Fork the repository
- Clone your fork
- Open in DevContainer
- Run
make setup - Make your changes
- Run
make ci-check - 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
- MkDocs - Static site generator
- Material for MkDocs - Beautiful theme
- Model Context Protocol - AI integration standard
- uv - Fast Python package manager
- Ruff - Python linting and formatting
- Podman - Container runtime
๐ Support
- Documentation: Project Documentation
- Issues: GitHub Issues
- Discussions: GitHub Discussions
โญ Star this repo if you find it helpful!
Built with โค๏ธ using modern Python development practices.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.