Detailed guide to file management tools in the MkDocs MCP Server.
Create new documentation files with proper structure.
Signature:
create_doc(
file_path: str,
content: str,
frontmatter: Optional[Dict[str, Any]] = None
) -> str
Parameters:
file_path (required): Relative path from docs directorycontent (required): Markdown content for the pagefrontmatter (optional): YAML metadata dictionaryExamples:
{
"file_path": "guides/tutorial.md",
"content": "# Tutorial\n\nLearn how to use our product..."
}
{
"file_path": "api/users.md",
"content": "# Users API\n\n## Endpoints\n\n### GET /users\n...",
"frontmatter": {
"title": "Users API Reference",
"description": "User management endpoints",
"tags": ["api", "users"],
"version": "2.0"
}
}
{
"file_path": "guides/advanced/performance.md",
"content": "# Performance Optimization\n\n..."
}
Parent directories are created automatically.
Read file contents including frontmatter.
Signature:
read_doc(file_path: str) -> str
Parameters:
file_path (required): Relative path to the fileResponse Structure:
{
"path": "api/users.md",
"frontmatter": {
"title": "Users API",
"tags": ["api"]
},
"content": "# Users API\n\nThe markdown content..."
}
Use Cases:
Modify existing documentation files.
Signature:
update_doc(
file_path: str,
content: str,
frontmatter: Optional[Dict[str, Any]] = None
) -> str
Parameters:
file_path (required): Relative path to existing filecontent (required): New markdown contentfrontmatter (optional): New/updated metadata (preserves existing if not provided)Frontmatter Behavior:
{}: Removes frontmatterExamples:
{
"file_path": "getting-started.md",
"content": "# Getting Started (Updated)\n\nNew content..."
}
Preserves existing frontmatter
{
"file_path": "api/users.md",
"content": "# Users API v2\n\n...",
"frontmatter": {
"title": "Users API v2",
"version": "2.0",
"updated": "2026-02-16"
}
}
{
"file_path": "simple.md",
"content": "# Simple Page\n\nNo metadata needed.",
"frontmatter": {}
}
Remove documentation files.
Signature:
delete_doc(file_path: str) -> str
Parameters:
file_path (required): Relative path to fileExample:
{
"file_path": "deprecated/old-api.md"
}
Important:
Discover and filter documentation files.
Signature:
list_docs(pattern: str = "**/*.md") -> str
Parameters:
pattern (optional): Glob pattern (default: all markdown files)Glob Pattern Examples:
"**/*.md" # All markdown files (default)
"api/**/*.md" # All files under api/
"getting-started/*.md" # Files directly in getting-started/
"**/*guide*.md" # Files with 'guide' in name
"*.md" # Files in root docs/ only
Response:
{
"count": 15,
"files": [
{
"path": "api/authentication.md",
"size": 2048,
"modified": 1708123456.0,
"title": "Authentication Guide",
"has_metadata": true
}
]
}
Use Cases:
✅ Good:
getting-started.mdapi-reference.mduser-authentication.md❌ Avoid:
Getting Started.md (spaces)API_Reference.md (underscores)userAuth.md (camelCase)docs/
├── index.md # Home page
├── getting-started/ # User onboarding
│ ├── installation.md
│ └── quick-start.md
├── guides/ # How-to guides
│ ├── basic.md
│ └── advanced.md
├── api/ # API reference
│ ├── authentication.md
│ └── endpoints.md
└── examples/ # Code examples
└── python.md
Essential metadata:
title: Page Title
description: Brief page description
Enhanced metadata:
title: Advanced Configuration
description: Detailed configuration options
tags: [configuration, advanced]
author: Team Name
date: 2026-02-16
version: 2.0
Good document structure:
# Main Title (H1)
Brief introduction paragraph.
## Section (H2)
Content...
### Subsection (H3)
Details...
## Next Section (H2)
More content...
Use:
Create multiple related files:
# Ask AI:
"Create these API documentation pages:
- api/authentication.md
- api/users.md
- api/posts.md
Each should have title frontmatter and basic structure."
Apply consistent structure:
# Ask AI:
"Create api/products.md using the same structure as api/users.md
but for the Products endpoint"
Move content between files:
# Ask AI:
"Read old-guide.md, create a new version at guides/new-guide.md
with improved formatting, then delete the old file"
{
"error": "File already exists: api/users.md"
}
Solution: Use update_doc instead or delete first
{
"error": "File not found: api/missing.md"
}
Solution: Check path, use list_docs to verify
{
"error": "Documentation path does not exist: /wrong/path"
}
Solution: Verify MKDOCS_DOCS_PATH environment variable