Skip to main content
Glama

create_chapter

Create a new chapter within a BookStack book by specifying the parent book ID and chapter name, with optional details like description, tags, priority, and template.

Instructions

Create a new chapter in a book

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
book_idYesParent book ID
default_template_idNoDefault template ID for new pages
descriptionNoChapter description (plain text)
description_htmlNoChapter description (HTML format)
nameYesChapter name (required, max 255 chars)
priorityNoChapter priority/order
tagsNoArray of tags with name and value

Implementation Reference

  • The core handler logic for the 'create_chapter' tool within the handleContentTool switch statement. Validates input using CreateChapterSchema, processes tags, invokes the BookStackClient, and formats the response.
    case "create_chapter": { const validatedData = CreateChapterSchema.parse(args); const data = { ...validatedData, tags: convertTags(validatedData.tags), }; const result = await client.createChapter(data); return formatApiResponse(result); }
  • Tool registration object defining the 'create_chapter' tool, including name, description, and inputSchema for MCP listTools endpoint.
    { name: "create_chapter", description: "Create a new chapter in a book", inputSchema: { type: "object", properties: { book_id: { type: "number", description: "Parent book ID" }, name: { type: "string", description: "Chapter name (required, 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: ["book_id", "name"], }, },
  • Zod schema for validating 'create_chapter' tool inputs, used in the handler for parsing arguments.
    export const CreateChapterSchema = z.object({ book_id: z.number(), name: z.string().min(1).max(255), description: z.string().optional(), description_html: z.string().optional(), tags: z.array(TagSchema).optional(), priority: z.number().optional(), default_template_id: z.number().optional(), });
  • BookStackClient helper method that sends POST request to /api/chapters to create the chapter.
    async createChapter(data: CreateChapterRequest): Promise<Chapter> { return this.post<Chapter>("/chapters", data); }
  • TypeScript interface defining the shape of CreateChapterRequest used in BookStackClient.
    export interface CreateChapterRequest { book_id: number; name: string; description?: string; description_html?: string; tags?: Tag[]; priority?: number; default_template_id?: number; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/lautarobarba/bookstack_mcp_server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server