update_image
Modify image details in BookStack, such as changing the image name, to maintain accurate visual content references across your wiki.
Instructions
Update image details
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Image ID | |
| name | No | Image name |
Implementation Reference
- src/tools/search-user-tools.ts:511-517 (handler)The handler function for the 'update_image' tool. It destructures 'id' and 'name' from arguments, parses the ID to integer, calls the BookStackClient's updateImage method, and formats the API response.case "update_image": { const { id, name } = args; const imageId = parseInteger(id); const result = await client.updateImage(imageId, { name }); return formatApiResponse(result); }
- src/lib/bookstack-client.ts:396-411 (helper)The core helper method in BookStackClient that performs the HTTP PUT (or multipart POST if image provided) to the BookStack API endpoint `/image-gallery/{id}` to update the image name.async updateImage( id: number, data: { name?: string }, imageFile?: Buffer, filename?: string ): Promise<ImageGallery> { if (imageFile && filename) { const formData = new FormData(); if (data.name) formData.append("name", data.name); formData.append("image", imageFile, filename); return this.postMultipart<ImageGallery>(`/image-gallery/${id}`, formData); } else { return this.put<ImageGallery>(`/image-gallery/${id}`, data); } }
- src/tools/search-user-tools.ts:303-314 (registration)Registration of the 'update_image' tool in createSearchAndUserTools function, including name, description, and JSON input schema.{ name: "update_image", description: "Update image details", inputSchema: { type: "object", properties: { id: { type: "number", description: "Image ID" }, name: { type: "string", description: "Image name" }, }, required: ["id"], }, },
- src/index.ts:103-128 (registration)Dispatch registration in main server handler: 'update_image' is listed in searchUserToolNames and routed to handleSearchAndUserTool.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)) { result = await handleSearchAndUserTool(name, args, bookStackClient); } else {
- src/lib/validation.ts:118-120 (schema)Zod schema defining the structure for image update data (name optional string max 180 chars).export const UpdateImageSchema = z.object({ name: z.string().max(180).optional(), });
- src/lib/validation.ts:158-166 (helper)Helper function used in handler to parse image ID to integer.export function parseInteger(value: unknown): number { if (typeof value === "number") return value; if (typeof value === "string") { const parsed = parseInt(value, 10); if (isNaN(parsed)) throw new Error(`Invalid integer: ${value}`); return parsed; } throw new Error(`Expected integer, got ${typeof value}`); }