create_page
Create a new page in a BookStack wiki by specifying content in HTML or Markdown format, organizing it within books or chapters, and adding 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) | |
| html | No | Page content in HTML format | |
| markdown | No | Page content in Markdown format | |
| name | Yes | Page name (required, max 255 chars) | |
| priority | No | Page priority/order | |
| tags | No | Array of tags with name and value |
Implementation Reference
- src/tools/content-tools.ts:683-691 (handler)The main handler logic for the 'create_page' tool within the handleContentTool switch statement. Validates input using CreatePageSchema, processes tags, calls the BookStackClient.createPage method, and returns a 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/tools/content-tools.ts:318-357 (registration)Tool registration definition including name, description, and input schema for the MCP tool list.{ 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/lib/validation.ts:43-58 (schema)Zod validation schema used in the handler to parse and validate arguments for create_page.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/lib/bookstack-client.ts:211-213 (helper)BookStackClient helper method that performs the actual API POST request to create a page.async createPage(data: CreatePageRequest): Promise<Page> { return this.post<Page>("/pages", data); }
- src/types/index.ts:288-296 (schema)TypeScript interface defining the shape of the CreatePageRequest used by the client and handler.export interface CreatePageRequest { book_id?: number; chapter_id?: number; name: string; html?: string; markdown?: string; tags?: Tag[]; priority?: number; }