update_chapter
Modify an existing chapter in BookStack by updating its name, description, tags, priority, or default template using the chapter ID.
Instructions
Update an existing chapter
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| default_template_id | No | Default template ID for new pages | |
| description | No | Chapter description (plain text) | |
| description_html | No | Chapter description (HTML format) | |
| id | Yes | Chapter ID | |
| name | No | Chapter name (max 255 chars) | |
| priority | No | Chapter priority/order | |
| tags | No | Array of tags with name and value |
Implementation Reference
- src/tools/content-tools.ts:631-641 (handler)Handler logic for the 'update_chapter' tool: extracts chapter ID, validates update data using UpdateChapterSchema, converts tags, calls BookStackClient.updateChapter, and formats the response.case "update_chapter": { const { id, ...updateData } = args; const chapterId = parseInteger(id); const validatedData = UpdateChapterSchema.parse(updateData); const data = { ...validatedData, tags: convertTags(validatedData.tags), }; const result = await client.updateChapter(chapterId, data); return formatApiResponse(result); }
- src/tools/content-tools.ts:228-264 (registration)Tool registration in createContentTools: defines the 'update_chapter' tool with name, description, and inputSchema matching the validation schema.{ name: "update_chapter", description: "Update an existing chapter", inputSchema: { type: "object", properties: { id: { type: "number", description: "Chapter ID" }, name: { type: "string", description: "Chapter name (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: ["id"], },
- src/lib/validation.ts:39-41 (schema)Zod schema for validating input data for updating a chapter, derived from CreateChapterSchema by making fields optional and omitting book_id.export const UpdateChapterSchema = CreateChapterSchema.partial().omit({ book_id: true, });
- src/lib/bookstack-client.ts:159-164 (helper)BookStackClient method that performs the actual API PUT request to update a chapter.async updateChapter( id: number, data: Partial<CreateChapterRequest> ): Promise<Chapter> { return this.put<Chapter>(`/chapters/${id}`, data); }
- src/index.ts:86-86 (registration)Inclusion of 'update_chapter' in the contentToolNames array for routing tool calls to handleContentTool."update_chapter",