Skip to main content

A lightweight MCP server for MkDocs documentation sites

Project description

papermoon-mkdocs-mcp

A lightweight MCP server for MkDocs documentation sites. Reads markdown files directly from disk, provides full-text and optional semantic search, and exposes project structure through the Model Context Protocol.

Features

  • 5 MCP tools -- search, read_document, list_documents, get_project_info, get_document_outline
  • SQLite FTS5 keyword search with BM25 ranking (zero external dependencies)
  • Optional semantic vector search via sentence-transformers
  • Hybrid search combining keyword + vector results with Reciprocal Rank Fusion
  • Incremental indexing -- fast updates when files change
  • Persistent SQLite index that survives server restarts
  • Navigation-aware -- parses mkdocs.yml and .nav.yml
  • Security-first -- path traversal prevention, read-only search connections
  • Minimal dependencies -- 3 required, 2 optional

Installation

pip install papermoon-mkdocs-mcp

To enable vector search:

pip install papermoon-mkdocs-mcp[vector]

Quick Start

Run from the root of any MkDocs project (where mkdocs.yml lives):

cd /path/to/your/mkdocs-project
papermoon-mkdocs-mcp

Or point to a specific config file:

papermoon-mkdocs-mcp --config /path/to/mkdocs.yml

The server auto-detects mkdocs.yml in the current directory when --config is omitted.

MCP Client Configuration

Claude Desktop

Add to your Claude Desktop configuration file:

{
  "mcpServers": {
    "mkdocs": {
      "command": "papermoon-mkdocs-mcp",
      "args": ["--config", "/path/to/mkdocs.yml"]
    }
  }
}

Claude Code / VS Code

Add to .mcp.json in your project root:

{
  "mcpServers": {
    "mkdocs": {
      "command": "papermoon-mkdocs-mcp",
      "args": ["--config", "/path/to/mkdocs.yml"]
    }
  }
}

Available Tools

search

Search documentation using keyword, semantic, or hybrid search.

Parameter Type Default Description
query str (required) The search query string
search_type str "hybrid" "keyword", "vector", or "hybrid"
max_results int 10 Maximum results to return (1--100)

Returns ranked results with path, title, relevance score (normalized 0.0--1.0), and text snippet.

read_document

Read a documentation file by its relative path.

Parameter Type Default Description
path str (required) Relative path from docs dir (e.g. guide/setup.md)

Returns the markdown body (frontmatter stripped), parsed frontmatter as a separate field, heading structure, and file metadata.

list_documents

List all documentation files, optionally filtered by section.

Parameter Type Default Description
section str or null null Directory prefix to filter by (e.g. guide)

Returns document metadata (path, title, description, categories, size, mtime).

get_project_info

Get MkDocs project metadata. Takes no parameters.

Returns site name, site URL, docs directory, theme, navigation tree, document count, and index status.

get_document_outline

Get the heading structure (table of contents) for a document.

Parameter Type Default Description
path str (required) Relative path from docs dir (e.g. guide/setup.md)

Returns the document title and a list of headings with level, text, and anchor.

Architecture

src/mkdocs_mcp/
  config.py      -- MkDocs config detection and nav parsing
  repository.py  -- SQLite schema and CRUD operations
  indexer.py     -- Index orchestration with incremental updates
  searcher.py    -- Keyword, vector, and hybrid search
  server.py      -- FastMCP server with 5 tool definitions
  utils.py       -- Path validation, frontmatter parsing, text extraction
  models.py      -- Pydantic response models

At startup the server reads mkdocs.yml, scans the docs directory, and builds (or incrementally updates) a SQLite FTS5 index. Search queries hit the index directly; vector search embeds the query with all-MiniLM-L6-v2 and compares against stored document embeddings. Hybrid mode fuses both result lists using Reciprocal Rank Fusion.

Development

git clone https://github.com/aspect-build/mkdocs-mcp.git
cd mkdocs-mcp
pip install -e ".[dev]"
pytest

Linting and type checking:

ruff check .
mypy src/

Requirements

  • Python >= 3.10
  • Required: fastmcp (>=3.0, <4), pydantic (>=2.0, <3), pyyaml (>=6.0), markdown (>=3.4)
  • Optional (vector search): sentence-transformers (>=3.0), numpy (>=1.24)

License

See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

papermoon_mkdocs_mcp-0.1.0b1.tar.gz (719.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

papermoon_mkdocs_mcp-0.1.0b1-py3-none-any.whl (26.4 kB view details)

Uploaded Python 3

File details

Details for the file papermoon_mkdocs_mcp-0.1.0b1.tar.gz.

File metadata

  • Download URL: papermoon_mkdocs_mcp-0.1.0b1.tar.gz
  • Upload date:
  • Size: 719.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.5

File hashes

Hashes for papermoon_mkdocs_mcp-0.1.0b1.tar.gz
Algorithm Hash digest
SHA256 373364e2ca643440ccdad70b57a846b9003d4e1d9466fbd42c4cc581ae650127
MD5 cacb41be55f941e637a2974ba85da62e
BLAKE2b-256 42c770227716015fb0090e92fa2c2819eafcd1d6a1ec69dc22ba733643cd29a8

See more details on using hashes here.

File details

Details for the file papermoon_mkdocs_mcp-0.1.0b1-py3-none-any.whl.

File metadata

File hashes

Hashes for papermoon_mkdocs_mcp-0.1.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 6b3b7771ca9bc52367e30e4404aef130570a21a5f0c0227a1ea615f8b36cf1c1
MD5 4a33336dbf604b411290c88f480cc613
BLAKE2b-256 8a47769674503f308505d029e128b39d16088ac9a0218a419a9058545803a007

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page