docs_preview
Preview documentation locally by starting a development server. Supports Docusaurus, MkDocs, and Sphinx frameworks with configurable port and docs directory.
Instructions
Start local development server to preview documentation
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| docsPath | Yes | Path to documentation directory | |
| framework | Yes | Documentation framework used | |
| port | No | Port number (default: 3000 for Docusaurus, 8000 for MkDocs/Sphinx) |
Implementation Reference
- src/tools/preview.ts:7-81 (handler)The handler function 'preview' that executes the docs_preview tool logic. Returns instructions for starting a local dev server (Docusaurus, MkDocs, or Sphinx) with framework-specific commands and port configuration.
export async function preview(args: any) { const { docsPath, framework, port } = args as PreviewArgs; const defaultPorts: Record<string, number> = { docusaurus: 3000, mkdocs: 8000, sphinx: 8000, }; const selectedPort = port || defaultPorts[framework] || 3000; const instructions: Record<string, string> = { docusaurus: `👀 Starting Docusaurus Preview: 1. Navigate to docs: cd ${docsPath} 2. Start dev server: npm start 3. Server will run on: http://localhost:${selectedPort} 4. Features: - Hot reload - Fast refresh - Search - Navigation Press Ctrl+C to stop the server.`, mkdocs: `👀 Starting MkDocs Preview: 1. Navigate to project: cd ${docsPath} 2. Start dev server: mkdocs serve -a localhost:${selectedPort} 3. Server will run on: http://localhost:${selectedPort} 4. Features: - Auto-reload on save - Live preview - Search Press Ctrl+C to stop the server.`, sphinx: `👀 Starting Sphinx Preview: 1. Build the docs: cd ${docsPath} make html 2. Start simple HTTP server: cd _build/html python -m http.server ${selectedPort} 3. Server will run on: http://localhost:${selectedPort} 4. For auto-rebuild, use sphinx-autobuild: pip install sphinx-autobuild sphinx-autobuild . _build/html --port ${selectedPort} Press Ctrl+C to stop the server.`, }; const instruction = instructions[framework] || "Framework not supported"; return { content: [ { type: "text", text: instruction, }, ], }; } - src/index.ts:180-200 (schema)The input schema definition for the 'docs_preview' tool, specifying required inputs: docsPath (string), framework (enum: docusaurus/mkdocs/sphinx), and optional port (number).
name: "docs_preview", description: "Start local development server to preview documentation", inputSchema: { type: "object", properties: { docsPath: { type: "string", description: "Path to documentation directory", }, framework: { type: "string", description: "Documentation framework used", enum: ["docusaurus", "mkdocs", "sphinx"], }, port: { type: "number", description: "Port number (default: 3000 for Docusaurus, 8000 for MkDocs/Sphinx)", }, }, required: ["docsPath", "framework"], }, - src/index.ts:312-313 (registration)The case handler in the CallToolRequestSchema switch that dispatches to the 'preview' function when tool name is 'docs_preview'.
case "docs_preview": return await preview(args); - src/tools/preview.ts:1-5 (helper)The PreviewArgs interface defining the shape of the documentation preview arguments (docsPath, framework, optional port).
interface PreviewArgs { docsPath: string; framework: string; port?: number; } - src/index.ts:16-16 (registration)The import of the 'preview' function from './tools/preview.js' into the main server file.
import { preview } from "./tools/preview.js";