Manage your MkDocs site navigation structure programmatically.
The navigation tools allow you to view and modify the navigation structure defined in mkdocs.yml.
Retrieve the current navigation structure.
Signature:
get_navigation() -> str
Parameters: None
Response:
{
"site_name": "My Documentation",
"nav": [
{ "Home": "index.md" },
{
"Getting Started": [
{ "Installation": "getting-started/installation.md" },
{ "Quick Start": "getting-started/quick-start.md" }
]
},
{
"API": [
{ "Authentication": "api/auth.md" },
{ "Users": "api/users.md" }
]
}
],
"theme": "material"
}
Response Fields:
site_name: Name of the documentation sitenav: Navigation structure (array of items)theme: Theme name (if configured)Modify the navigation structure.
Signature:
update_navigation(navigation: List[Any]) -> str
Parameters:
navigation (required): New navigation structureExample:
{
"navigation": [
{ "Home": "index.md" },
{
"Documentation": [
{ "Guide": "guide.md" },
{ "Reference": "reference.md" }
]
}
]
}
Single page:
{ "Page Title": "path/to/file.md" }
Nested structure:
{
"Section Name": [
{ "Page 1": "section/page1.md" },
{ "Page 2": "section/page2.md" }
]
}
Multiple levels:
{
"API": [
{ "Overview": "api/index.md" },
{
"Endpoints": [
{ "Users": "api/endpoints/users.md" },
{ "Posts": "api/endpoints/posts.md" }
]
},
{
"Authentication": [
{ "OAuth2": "api/auth/oauth2.md" },
{ "JWT": "api/auth/jwt.md" }
]
}
]
}
[
{ "Home": "index.md" },
{
"Getting Started": [...]
},
{
"Guides": [...]
},
{
"API Reference": [...]
},
{
"Examples": [...]
}
]
Before:
{
"nav": [
{ "Home": "index.md" },
{ "Guide": "guide.md" }
]
}
Ask AI:
Add tutorials.md to the navigation after Guide
After:
{
"nav": [
{ "Home": "index.md" },
{ "Guide": "guide.md" },
{ "Tutorials": "tutorials.md" }
]
}
Ask AI:
Create a new “API Reference” section with auth.md and users.md
Result:
{
"nav": [
{ "Home": "index.md" },
{
"API Reference": [
{ "Authentication": "api/auth.md" },
{ "Users": "api/users.md" }
]
}
]
}
Before:
[
{ "Home": "index.md" },
{ "API": [...] },
{ "Getting Started": [...] }
]
Ask AI:
Move “Getting Started” before “API”
After:
[
{ "Home": "index.md" },
{ "Getting Started": [...] },
{ "API": [...] }
]
Ask AI:
Rename “Guides” section to “Tutorials”
Navigation structure updated with new name.
Ask AI:
Remove the deprecated.md page from navigation
Item removed from structure.
Before:
{
"Simple Guides": [
{ "Guide 1": "guides/guide1.md" }
]
}
Ask AI:
Flatten the “Simple Guides” section since it only has one item
After:
{ "Guide 1": "guides/guide1.md" }
Ask AI:
Under API section, create an “Advanced” subsection with caching.md and rate-limiting.md
Result:
{
"API": [
{ "Overview": "api/index.md" },
{
"Advanced": [
{ "Caching": "api/advanced/caching.md" },
{ "Rate Limiting": "api/advanced/rate-limiting.md" }
]
}
]
}
✅ Good:
Home
├── Getting Started
│ ├── Installation
│ └── Quick Start
├── Guides
│ ├── Basic
│ └── Advanced
└── API Reference
├── Authentication
└── Endpoints
❌ Avoid:
Home
├── Page 1
├── Section
│ └── Page 2
├── Page 3
└── Another Section
└── Subsection
└── Page 4
Try to keep similar content at similar nesting levels:
✅ Good:
{
"API": [
{ "Users": "api/users.md" },
{ "Posts": "api/posts.md" },
{ "Comments": "api/comments.md" }
]
}
❌ Avoid:
{
"API": [
{ "Users": "api/users.md" },
{
"Posts": [
{ "Posts": "api/posts.md" }
]
}
]
}
✅ Good:
❌ Avoid:
Aim for 3-7 items per section:
✅ Good:
Getting Started (4 items)
├── Installation
├── Configuration
├── Quick Start
└── First Steps
❌ Too many:
Getting Started (15 items)
├── Step 1
├── Step 2
├── ... (13 more items)
Organize by product features:
Home
├── Authentication
├── Data Management
├── Analytics
├── Integrations
└── Settings
Organize by user progression:
Home
├── Getting Started
├── Basic Usage
├── Intermediate Topics
├── Advanced Topics
└── Reference
Organize by user role:
Home
├── For End Users
├── For Developers
├── For Administrators
└── For Contributors
Organize by product line:
Home
├── Product A
│ ├── Guide
│ └── API
├── Product B
│ ├── Guide
│ └── API
└── Platform
create_docget_navigationupdate_navigationget_navigationProblem: File exists but not in navigation
Solution:
1. Get navigation
2. Add file reference to appropriate section
3. Update navigation
Problem: Navigation references non-existent file
Solution:
1. Search navigation for item
2. Either create the file or remove the reference
3. Update navigation
Problem: Pages at wrong depth level
Solution:
1. Review entire navigation structure
2. Reorganize sections logically
3. Update navigation with corrected structure
Generate navigation from file structure:
1. List all docs: list_docs()
2. Analyze directory structure
3. Generate navigation object
4. Update navigation
Apply consistent patterns:
For each new product:
1. Create docs/products/{name}/
2. Add to navigation under Products section
3. Follow standard subsections: Overview, Setup, API, Examples
Check navigation integrity:
1. Get navigation
2. Extract all file paths
3. Verify files exist with list_docs
4. Report missing files
5. Report files not in navigation