create_page
Add a new page to a BookStack wiki by specifying content in HTML or Markdown format, organizing it within books or chapters, and applying tags for categorization.
Instructions
Create a new page in a book or chapter
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| book_id | No | Parent book ID (required if not in chapter) | |
| chapter_id | No | Parent chapter ID (required if not directly in book) | |
| name | Yes | Page name (required, max 255 chars) | |
| html | No | Page content in HTML format | |
| markdown | No | Page content in Markdown format | |
| tags | No | Array of tags with name and value | |
| priority | No | Page priority/order |
Implementation Reference
- src/tools/content-tools.ts:683-691 (handler)Handler logic for the 'create_page' tool: validates input using CreatePageSchema, processes tags, calls BookStackClient.createPage, and returns formatted response.case "create_page": { const validatedData = CreatePageSchema.parse(args); const data = { ...validatedData, tags: convertTags(validatedData.tags), }; const result = await client.createPage(data); return formatApiResponse(result); }
- src/lib/validation.ts:43-58 (schema)Zod validation schema (CreatePageSchema) used in the handler to parse and validate tool arguments.export const CreatePageSchema = z .object({ book_id: z.number().optional(), chapter_id: z.number().optional(), name: z.string().min(1).max(255), html: z.string().optional(), markdown: z.string().optional(), tags: z.array(TagSchema).optional(), priority: z.number().optional(), }) .refine((data) => data.book_id || data.chapter_id, { message: "Either book_id or chapter_id must be provided", }) .refine((data) => data.html || data.markdown, { message: "Either html or markdown content must be provided", });
- src/tools/content-tools.ts:319-357 (registration)MCP Tool registration object for 'create_page', including name, description, and JSON inputSchema, returned by createContentTools().name: "create_page", description: "Create a new page in a book or chapter", inputSchema: { type: "object", properties: { book_id: { type: "number", description: "Parent book ID (required if not in chapter)", }, chapter_id: { type: "number", description: "Parent chapter ID (required if not directly in book)", }, name: { type: "string", description: "Page name (required, max 255 chars)", }, html: { type: "string", description: "Page content in HTML format" }, markdown: { type: "string", description: "Page content in Markdown 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: "Page priority/order" }, }, required: ["name"], },
- src/index.ts:76-100 (registration)Registration of 'create_page' in the dispatch array contentToolNames, used to route calls to 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/lib/bookstack-client.ts:211-213 (helper)BookStackClient helper method that makes the actual API POST request to create a page.async createPage(data: CreatePageRequest): Promise<Page> { return this.post<Page>("/pages", data); }