create_chapter
Create a new chapter within a BookStack book by specifying the parent book ID and chapter name, with optional details like description, tags, priority, and template.
Instructions
Create a new chapter in a book
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| book_id | Yes | Parent book ID | |
| default_template_id | No | Default template ID for new pages | |
| description | No | Chapter description (plain text) | |
| description_html | No | Chapter description (HTML format) | |
| name | Yes | Chapter name (required, max 255 chars) | |
| priority | No | Chapter priority/order | |
| tags | No | Array of tags with name and value |
Implementation Reference
- src/tools/content-tools.ts:621-629 (handler)The core handler logic for the 'create_chapter' tool within the handleContentTool switch statement. Validates input using CreateChapterSchema, processes tags, invokes the BookStackClient, and formats the response.case "create_chapter": { const validatedData = CreateChapterSchema.parse(args); const data = { ...validatedData, tags: convertTags(validatedData.tags), }; const result = await client.createChapter(data); return formatApiResponse(result); }
- src/tools/content-tools.ts:187-227 (registration)Tool registration object defining the 'create_chapter' tool, including name, description, and inputSchema for MCP listTools endpoint.{ name: "create_chapter", description: "Create a new chapter in a book", inputSchema: { type: "object", properties: { book_id: { type: "number", description: "Parent book ID" }, name: { type: "string", description: "Chapter name (required, max 255 chars)", }, description: { type: "string", description: "Chapter description (plain text)", }, description_html: { type: "string", description: "Chapter description (HTML format)", }, tags: { type: "array", description: "Array of tags with name and value", items: { type: "object", properties: { name: { type: "string" }, value: { type: "string" }, order: { type: "number" }, }, required: ["name", "value"], }, }, priority: { type: "number", description: "Chapter priority/order" }, default_template_id: { type: "number", description: "Default template ID for new pages", }, }, required: ["book_id", "name"], }, },
- src/lib/validation.ts:29-37 (schema)Zod schema for validating 'create_chapter' tool inputs, used in the handler for parsing arguments.export const CreateChapterSchema = z.object({ book_id: z.number(), name: z.string().min(1).max(255), description: z.string().optional(), description_html: z.string().optional(), tags: z.array(TagSchema).optional(), priority: z.number().optional(), default_template_id: z.number().optional(), });
- src/lib/bookstack-client.ts:155-157 (helper)BookStackClient helper method that sends POST request to /api/chapters to create the chapter.async createChapter(data: CreateChapterRequest): Promise<Chapter> { return this.post<Chapter>("/chapters", data); }
- src/types/index.ts:278-286 (schema)TypeScript interface defining the shape of CreateChapterRequest used in BookStackClient.export interface CreateChapterRequest { book_id: number; name: string; description?: string; description_html?: string; tags?: Tag[]; priority?: number; default_template_id?: number; }