docs_create_page
Create or edit individual documentation pages with Markdown content, specifying path, title, and content for multi-language project documentation.
Instructions
Create or edit individual documentation pages with Markdown content
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| docsPath | Yes | Path to documentation directory | |
| pagePath | Yes | Relative path for the page (e.g., 'guides/getting-started.md') | |
| title | Yes | Page title | |
| content | Yes | Markdown content for the page |
Implementation Reference
- src/index.ts:85-108 (registration)Tool schema definition for docs_create_page registered in the tools array with input validation schema (docsPath, pagePath, title, content) and required fields.
name: "docs_create_page", description: "Create or edit individual documentation pages with Markdown content", inputSchema: { type: "object", properties: { docsPath: { type: "string", description: "Path to documentation directory", }, pagePath: { type: "string", description: "Relative path for the page (e.g., 'guides/getting-started.md')", }, title: { type: "string", description: "Page title", }, content: { type: "string", description: "Markdown content for the page", }, }, required: ["docsPath", "pagePath", "title", "content"], }, - src/tools/createPage.ts:11-42 (handler)Core handler function that creates a Markdown documentation page: creates directories recursively, formats content with YAML frontmatter (title), writes to file, and returns success message.
export async function createPage(args: any) { const { docsPath, pagePath, title, content } = args as CreatePageArgs; try { const fullPath = path.resolve(docsPath, pagePath); const dir = path.dirname(fullPath); await fs.mkdir(dir, { recursive: true }); const formattedContent = `--- title: ${title} --- # ${title} ${content} `; await fs.writeFile(fullPath, formattedContent, "utf-8"); return { content: [ { type: "text", text: `✅ Page created successfully at: ${fullPath}`, }, ], }; } catch (error) { throw new Error(`Failed to create page: ${error}`); } } - src/tools/createPage.ts:4-9 (schema)TypeScript interface defining the expected arguments for createPage: docsPath, pagePath, title, and content (all required strings).
interface CreatePageArgs { docsPath: string; pagePath: string; title: string; content: string; } - src/index.ts:304-328 (registration)Route registration in the CallToolRequestSchema handler that dispatches the "docs_create_page" tool name to the createPage function.
case "docs_create_page": return await createPage(args); case "docs_generate_api": return await generateApi(args); case "docs_build_static": return await buildStatic(args); case "docs_export_pdf": return await exportPdf(args); case "docs_preview": return await preview(args); case "docs_generate_openapi": return await generateOpenApi(args); case "docs_generate_sales_docs": return await generateSalesDocs(args); default: throw new Error(`Unknown tool: ${name}`); } } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Error: ${errorMessage}` }], isError: true, }; } }); - src/index.ts:12-13 (registration)Import statement importing the createPage handler from the tools module.
import { createPage } from "./tools/createPage.js"; import { generateApi } from "./tools/generateApi.js";