update_shelf
Modify an existing shelf's properties including name, description, books, and tags in BookStack to maintain organized content structure.
Instructions
Update an existing shelf
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| books | No | Array of book IDs (replaces existing books) | |
| description | No | Shelf description (plain text) | |
| description_html | No | Shelf description (HTML format) | |
| id | Yes | Shelf ID | |
| name | No | Shelf name (max 255 chars) | |
| tags | No | Array of tags with name and value |
Implementation Reference
- src/tools/content-tools.ts:755-765 (handler)Handler logic for the 'update_shelf' tool within the handleContentTool switch statement. Parses arguments, validates input using UpdateShelfSchema, converts tags, calls the BookStack client to update the shelf, and formats the response.case "update_shelf": { const { id, ...updateData } = args; const shelfId = parseInteger(id); const validatedData = UpdateShelfSchema.parse(updateData); const data = { ...validatedData, tags: convertTags(validatedData.tags), }; const result = await client.updateShelf(shelfId, data); return formatApiResponse(result); }
- src/lib/validation.ts:70-78 (schema)Zod schema definitions for shelf creation and updates. UpdateShelfSchema is a partial of CreateShelfSchema and is used for input validation in the handler.export const CreateShelfSchema = z.object({ name: z.string().min(1).max(255), description: z.string().optional(), description_html: z.string().optional(), books: z.array(z.number()).optional(), tags: z.array(TagSchema).optional(), }); export const UpdateShelfSchema = CreateShelfSchema.partial();
- src/tools/content-tools.ts:487-523 (registration)Tool registration in createContentTools function, defining the 'update_shelf' tool name, description, and input schema for MCP.{ name: "update_shelf", description: "Update an existing shelf", inputSchema: { type: "object", properties: { id: { type: "number", description: "Shelf ID" }, name: { type: "string", description: "Shelf name (max 255 chars)" }, description: { type: "string", description: "Shelf description (plain text)", }, description_html: { type: "string", description: "Shelf description (HTML format)", }, books: { type: "array", description: "Array of book IDs (replaces existing books)", items: { type: "number" }, }, 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"], }, }, }, required: ["id"], },
- src/lib/bookstack-client.ts:271-276 (helper)BookStackClient method that performs the actual API PUT request to update a shelf via `/shelves/{id}` endpoint.async updateShelf( id: number, data: Partial<CreateShelfRequest> ): Promise<Shelf> { return this.put<Shelf>(`/shelves/${id}`, data); }
- src/index.ts:97-100 (registration)Lists 'update_shelf' in the contentToolNames array used to route tool calls to handleContentTool in the main MCP server handler."create_shelf", "update_shelf", "delete_shelf", ];