Skip to content

jberends/servemd

Repository files navigation

servemd

Serve docs to humans and AI.

Beautiful markdown documentation with native llms.txt support. Zero configuration, production-ready.

PyPI Docker Hub Python 3.11+ FastAPI MCP Tests License: Apache 2.0 CodeQL


Why servemd?

Unlike basic markdown servers, servemd is built for the AI era:

Markdown β†’ Beautiful HTML    β†’ Humans
         β†’ llms.txt          β†’ AI/LLMs
         β†’ llms-full.txt     β†’ Complete AI context
         β†’ /mcp endpoint     β†’ AI assistants (250x less context)

For humans: Nuxt UI-inspired design, three-column layout, zero configuration. For AI: Native llms.txt support, structured context, ready for the Model Context Protocol era.


✨ Features

  • 🎨 Beautiful Design β€” Nuxt UI-inspired three-column layout (sidebar, content, TOC)
  • πŸ€– AI-Native β€” Built-in llms.txt and llms-full.txt for Claude, ChatGPT, Cursor, etc.
  • πŸ”Œ MCP Support β€” Model Context Protocol endpoint for interactive AI queries (250x less context)
  • ✨ Zero Configuration β€” Drop .md files and go
  • ⚑ Fast β€” Smart disk caching, <5ms cached responses
  • 🐳 Docker Ready β€” Production-optimized container
  • πŸ§ͺ Well Tested β€” 208 tests, 100% passing
  • πŸ“± Responsive β€” Mobile, tablet, and desktop support

πŸš€ Quick Start

Install

pip install servemd

Run

# Serve docs from current directory
servemd

# Or specify a directory
servemd ./my-docs

Visit http://localhost:8080 β€” your documentation is live.

Live demo: https://servemd.me.cloudns.cl

Alternative: Docker

# Quick start - mount your docs
docker run -p 8080:8080 -v $(pwd)/docs:/app/__docs__ jberends/servemd:latest

# Or build custom image with docs baked in
FROM jberends/servemd:latest
COPY ./my-docs/ /app/__docs__/

See DOCKER_README.md for complete Docker usage guide.

Alternative: uvx (no install)

uvx servemd ./my-docs

πŸ“š Complete Setup Guide β†’

For Contributors

git clone https://github.com/servemd/servemd
cd servemd
uv sync
uv run python -m docs_server

πŸ€– AI-Native: llms.txt & MCP Support

servemd automatically serves your docs in AI-friendly formats:

Endpoint Purpose Audience Context Size
/{page}.html Rendered HTML with navigation Humans N/A
/{page}.md Raw markdown AI/LLMs Per-page
/llms.txt Documentation index AI assistants Small (~5KB)
/llms-full.txt Complete context (all pages) AI deep context Large (~500KB+)
/mcp Interactive queries AI (MCP clients) Minimal (250x less)

llms.txt - Static Index

Example: Give an AI assistant your docs:

"Read my documentation at https://docs.example.com/llms.txt"

The AI gets a structured index with absolute URLs to every page. For complete context, use /llms-full.txt which includes all page content inline.

MCP - Interactive Queries (Recommended for AI)

Model Context Protocol provides on-demand documentation access with 250x less context:

POST /mcp
{
  "method": "tools/call",
  "params": {
    "name": "search_docs",
    "arguments": {
      "query": "authentication",
      "limit": 5
    }
  }
}

Benefits:

  • 🎯 Precise β€” AI queries only what it needs
  • ⚑ Fast β€” No sending entire documentation every time
  • πŸ’° Cost-effective β€” 250x less tokens than llms-full.txt
  • πŸ” Smart β€” Full-text search with Whoosh

Available MCP Tools:

  • search_docs β€” Semantic search across documentation
  • get_doc_page β€” Retrieve specific pages with section filtering
  • list_doc_pages β€” List all available pages by category

See MCP Integration Guide for details.


✨ Key Features

For Humans

  • 🎨 Nuxt UI-inspired three-column layout (sidebar, content, TOC)
  • 🎨 Syntax highlighting with Pygments
  • 🎨 Responsive design (mobile, tablet, desktop)
  • 🎨 Dark mode ready
  • βœ… Tables, task lists, footnotes, Mermaid diagrams

For AI

  • πŸ€– llms.txt β€” Structured documentation index (5KB)
  • πŸ€– llms-full.txt β€” Complete context export (500KB+)
  • πŸ”Œ MCP endpoint β€” Interactive queries via Model Context Protocol
    • 250x less context than llms-full.txt
    • Full-text search with Whoosh
    • On-demand page retrieval
    • Section filtering
  • πŸ€– Automatic link transformation to absolute URLs
  • πŸ€– Curated or auto-generated indexes

For Developers

  • ⚑ Fast β€” disk caching, <5ms cached responses
  • πŸ”₯ Hot reload in debug mode
  • πŸ”§ Zero configuration required
  • 🐍 Python 3.11-3.14, FastAPI, Pydantic
  • πŸ§ͺ 208 tests, 100% passing

πŸ“ File Structure

Your documentation needs just 3 required files:

docs/
β”œβ”€β”€ index.md       # Homepage (required)
β”œβ”€β”€ sidebar.md     # Navigation (required)
β”œβ”€β”€ topbar.md      # Top bar (required)
β”œβ”€β”€ llms.txt       # AI index (optional)
└── your-content.md # Your pages

βš™οΈ Configuration

Configure via environment variables:

DOCS_ROOT=./docs                 # Documentation directory
CACHE_ROOT=./__cache__           # Cache directory
PORT=8080                        # Server port
DEBUG=true                       # Enable debug mode
BASE_URL=https://docs.site.com   # Base URL for llms.txt
MCP_ENABLED=true                 # Enable MCP endpoint (default: true)
MCP_RATE_LIMIT_REQUESTS=120      # MCP rate limit (requests per window)
MCP_RATE_LIMIT_WINDOW=60         # MCP rate limit window (seconds)

See Configuration Guide for details.


🎯 Use Cases

servemd is perfect for:

  • SaaS Documentation β€” Customer-facing support docs with AI assistant integration
  • Open Source Projects β€” Self-hosted, beautiful docs
  • Internal Teams β€” Company knowledge bases and wikis
  • API Documentation β€” REST/GraphQL API docs
  • Technical Writing β€” Blogs and tutorials

πŸ“˜ Deployment

Method Best For
Local Development Development, previewing
Docker Production, CI/CD
Cloud Platforms Heroku, Railway, Fly.io, DigitalOcean
Kubernetes k8s, k3s, Helm charts

πŸ› οΈ Examples

Check examples/ for ready-to-use templates:

  • Dockerfile.user-template β€” Custom Docker image
  • docker-compose.user.yml β€” Docker Compose setup
  • k8s-simple.yaml β€” Kubernetes deployment

πŸ—οΈ Architecture

Clean, modular FastAPI application:

src/docs_server/
β”œβ”€β”€ config.py           # Settings & environment
β”œβ”€β”€ helpers.py          # Utilities & navigation
β”œβ”€β”€ caching.py          # Smart caching
β”œβ”€β”€ markdown_service.py # Markdown rendering
β”œβ”€β”€ llms_service.py     # LLMs.txt generation
β”œβ”€β”€ templates.py        # HTML templates
β”œβ”€β”€ main.py             # FastAPI routes
└── mcp/                # Model Context Protocol
    β”œβ”€β”€ server.py       # MCP JSON-RPC handler
    β”œβ”€β”€ tools.py        # MCP tools (search, get, list)
    β”œβ”€β”€ search.py       # Full-text search with Whoosh
    └── indexer.py      # Documentation indexing

πŸ§ͺ Testing

uv run pytest tests/ -v

# 208 tests, 100% passing βœ…

πŸ”§ Development

git clone https://github.com/servemd/servemd
cd servemd
uv sync --group dev
uv run pytest tests/ -v
DEBUG=true uv run python -m docs_server

πŸ“Š Performance

Endpoint First Request Cached
Rendered HTML 50-100ms <5ms
Raw Markdown <10ms <10ms
LLMs.txt 100-200ms <5ms

πŸ“– Documentation


πŸ™‹ Support


πŸ“œ License

MIT License β€” use freely for any project.


πŸŽ‰ Get Started Now

pip install servemd
servemd ./my-docs

Visit http://localhost:8080 β€” beautiful docs for humans, structured context for AI.


servemd β€” Serve docs to humans and AI

Built with Python, FastAPI, and Markdown

Documentation Β· Live Demo Β· PyPI Β· GitHub

About

ServeMD is a markdown document server in FastAPI with AI and LLM integrations

Resources

License

Stars

2 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages