docs_preview
Start a local development server to preview documentation before deployment, supporting Docusaurus, MkDocs, and Sphinx frameworks.
Instructions
Start local development server to preview documentation
Input Schema
TableJSON 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 main handler function for the 'docs_preview' tool. It generates framework-specific (Docusaurus, MkDocs, Sphinx) instructions for starting a local preview server, including commands and port information.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:179-201 (registration)Registration of the 'docs_preview' tool in the tools array provided to ListToolsRequestHandler. Includes name, description, and input schema.{ 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)Dispatch case in the CallToolRequestHandler switch statement that invokes the preview handler function.case "docs_preview": return await preview(args);
- src/tools/preview.ts:1-5 (schema)TypeScript interface defining the expected input arguments for the preview function, matching the tool schema.interface PreviewArgs { docsPath: string; framework: string; port?: number; }
- src/index.ts:16-16 (helper)Import statement for the preview handler function used in the tool dispatch.import { preview } from "./tools/preview.js";