create_documentation_section
Create a new documentation section with an index file to organize content in markdown documentation systems.
Instructions
Create a new navigation section with an index.md file.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | ||
| title | Yes | ||
| order | No |
Implementation Reference
- src/handlers/documents.ts:683-737 (handler)The core handler implementation for the create_documentation_section tool. This method in the DocumentHandler class creates a new directory at the specified path and generates an index.md file with appropriate frontmatter (title, description, date, status, optional order) and basic content.async createSection( title: string, sectionPath: string, order?: number ): Promise<ToolResponse> { try { // Create the directory for the section const validPath = await this.validatePath(sectionPath); await fs.mkdir(validPath, { recursive: true }); // Create an index.md file for the section const indexPath = path.join(validPath, "index.md"); const validIndexPath = await this.validatePath(indexPath); // Create content with frontmatter let content = "---\n"; content += `title: ${title}\n`; content += `description: ${title} section\n`; content += `date: ${new Date().toISOString()}\n`; content += `status: published\n`; if (order !== undefined) { content += `order: ${order}\n`; } content += "---\n\n"; content += `# ${title}\n\n`; content += `Welcome to the ${title} section.\n`; // Write the index file await fs.writeFile(validIndexPath, content, "utf-8"); return { content: [ { type: "text", text: `Successfully created section: ${title} at ${sectionPath}`, }, ], metadata: { title, path: sectionPath, indexPath: path.join(sectionPath, "index.md"), order, }, }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Error creating section: ${errorMessage}` }, ], isError: true, }; } }
- src/schemas/tools.ts:86-90 (schema)Zod schema defining the input parameters for the create_documentation_section tool: title (required string), path (required string), order (optional number). Extends base ToolInputSchema.export const CreateSectionSchema = ToolInputSchema.extend({ title: z.string(), path: z.string(), order: z.number().optional(), });
- src/index.ts:278-282 (registration)Tool registration in the ListToolsRequestHandler, defining the tool name, description, and input schema for create_documentation_section.{ name: "create_documentation_section", description: "Create a new navigation section with an index.md file.", inputSchema: zodToJsonSchema(CreateSectionSchema) as any, },
- src/index.ts:455-467 (registration)Tool dispatch in the CallToolRequestHandler switch statement. Note: uses case 'create_section' (possible mismatch with tool name 'create_documentation_section'), parses input with CreateSectionSchema, and calls documentHandler.createSection.case "create_section": { const parsed = CreateSectionSchema.safeParse(args); if (!parsed.success) { throw new Error( `Invalid arguments for create_section: ${parsed.error}` ); } return await documentHandler.createSection( parsed.data.title, parsed.data.path, parsed.data.order ); }