update_chapter
Modify existing chapters in BookStack by updating content, metadata, tags, and organizational settings to maintain accurate documentation.
Instructions
Update an existing chapter
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Chapter ID | |
| name | No | Chapter name (max 255 chars) | |
| description | No | Chapter description (plain text) | |
| description_html | No | Chapter description (HTML format) | |
| tags | No | Array of tags with name and value | |
| priority | No | Chapter priority/order | |
| default_template_id | No | Default template ID for new pages |
Implementation Reference
- src/tools/content-tools.ts:631-641 (handler)The main execution logic for the 'update_chapter' tool within the handleContentTool switch statement. It extracts the chapter ID, validates the update data using UpdateChapterSchema, converts tags, calls the BookStack client to update the chapter, and formats the API 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)MCP Tool registration definition for 'update_chapter', including the tool name, description, and input schema specification used for tool listing and validation.{ 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 definition for validating the input parameters of the update_chapter tool. It is a partial version of CreateChapterSchema, omitting the book_id field since updates target an existing chapter by ID.export const UpdateChapterSchema = CreateChapterSchema.partial().omit({ book_id: true, });
- src/lib/bookstack-client.ts:159-164 (helper)Helper method in BookStackClient that performs the actual HTTP PUT request to the BookStack API endpoint /chapters/{id} to update the chapter data.async updateChapter( id: number, data: Partial<CreateChapterRequest> ): Promise<Chapter> { return this.put<Chapter>(`/chapters/${id}`, data); }
- src/index.ts:76-100 (registration)Registration of 'update_chapter' in the contentToolNames array used by the MCP server to route tool calls to the appropriate handler (handleContentTool).const contentToolNames = [ "list_books", "get_book", "create_book", "update_book", "delete_book", "export_book", "list_chapters", "get_chapter", "create_chapter", "update_chapter", "delete_chapter", "export_chapter", "list_pages", "get_page", "create_page", "update_page", "delete_page", "export_page", "list_shelves", "get_shelf", "create_shelf", "update_shelf", "delete_shelf", ];
- src/tools/content-tools.ts:21-30 (helper)Helper utility function used in the update_chapter handler to convert input tags to the proper Tag format expected by the BookStack API.function convertTags( inputTags?: { name: string; value: string; order?: number }[] ): Tag[] | undefined { if (!inputTags) return undefined; return inputTags.map((tag) => ({ name: tag.name, value: tag.value, order: tag.order ?? 0, })); }