update_shelf
Modify an existing shelf in BookStack by updating its name, description, books, or tags using the shelf ID.
Instructions
Update an existing shelf
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"id": "<id>"
},
"name": "update_shelf"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Shelf ID | |
| name | No | Shelf name (max 255 chars) | |
| description | No | Shelf description (plain text) | |
| description_html | No | Shelf description (HTML format) | |
| books | No | Array of book IDs (replaces existing books) | |
| tags | No | Array of tags with name and value |
Implementation Reference
- src/tools/content-tools.ts:755-765 (handler)MCP tool handler for 'update_shelf': extracts shelf ID, validates input with UpdateShelfSchema, converts tags, calls BookStack client.updateShelf, and returns formatted 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/tools/content-tools.ts:487-523 (registration)Tool registration: defines the 'update_shelf' Tool object with name, description, and inputSchema matching the validation.
{ 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/validation.ts:70-79 (schema)Zod schemas: CreateShelfSchema for full creation, UpdateShelfSchema as partial for updates, used to validate tool inputs.
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/lib/bookstack-client.ts:271-276 (helper)BookStackClient helper method: performs PUT request to /shelves/{id} to update the shelf via the API.
async updateShelf( id: number, data: Partial<CreateShelfRequest> ): Promise<Shelf> { return this.put<Shelf>(`/shelves/${id}`, data); } - src/index.ts:98-100 (registration)Dispatch registration: 'update_shelf' listed in contentToolNames array to route calls to handleContentTool.
"update_shelf", "delete_shelf", ];