create_book
Create a new book in BookStack with required name, optional description, tags, and default template settings for organizing wiki content.
Instructions
Create a new book in the system
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| default_template_id | No | Default template ID for new pages | |
| description | No | Book description (plain text) | |
| description_html | No | Book description (HTML format) | |
| name | Yes | Book name (required, max 255 chars) | |
| tags | No | Array of tags with name and value |
Implementation Reference
- src/tools/content-tools.ts:559-567 (handler)Handler function for the 'create_book' tool. Validates input arguments using CreateBookSchema, converts tags if provided, calls the BookStackClient.createBook method, and returns a formatted API response.case "create_book": { const validatedData = CreateBookSchema.parse(args); const data = { ...validatedData, tags: convertTags(validatedData.tags), }; const result = await client.createBook(data); return formatApiResponse(result); }
- src/lib/validation.ts:19-25 (schema)Zod schema used for runtime validation of input parameters for the create_book tool.export const CreateBookSchema = z.object({ name: z.string().min(1).max(255), description: z.string().optional(), description_html: z.string().optional(), tags: z.array(TagSchema).optional(), default_template_id: z.number().optional(), });
- src/tools/content-tools.ts:59-97 (registration)Tool registration/specification in createContentTools function, defining name, description, and inputSchema for MCP tool discovery and validation.{ name: "create_book", description: "Create a new book in the system", inputSchema: { type: "object", properties: { name: { type: "string", description: "Book name (required, max 255 chars)", }, description: { type: "string", description: "Book description (plain text)", }, description_html: { type: "string", description: "Book 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"], }, }, default_template_id: { type: "number", description: "Default template ID for new pages", }, }, required: ["name"], }, },
- src/lib/bookstack-client.ts:95-97 (helper)BookStack API client method that performs the actual HTTP POST request to create a book via the BookStack /books endpoint.async createBook(data: CreateBookRequest): Promise<Book> { return this.post<Book>("/books", data); }
- src/index.ts:76-126 (registration)Registration of create_book as a content tool: included in the list of handled tools and routed to handleContentTool in the MCP server's call tool handler.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", ]; // Search and user tools const searchUserToolNames = [ "search_all", "list_users", "get_user", "create_user", "update_user", "delete_user", "list_roles", "get_role", "create_role", "update_role", "delete_role", "list_attachments", "get_attachment", "delete_attachment", "list_images", "get_image", "update_image", "delete_image", ]; if (contentToolNames.includes(name)) { result = await handleContentTool(name, args, bookStackClient); } else if (searchUserToolNames.includes(name)) {