create-image-item-using-file
Add images to Miro boards from device files or chat uploads by specifying board ID, position, and image data.
Instructions
Create a new image item on a Miro board using file from device or from chat
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| boardId | Yes | Unique identifier (ID) of the board where the image will be created | |
| imageData | Yes | Base64 encoded image data from the chat | |
| position | Yes | Position of the image on the board | |
| title | No | Title of the image |
Implementation Reference
- Handler function that processes the tool inputs, decodes base64 image data into a buffer, constructs position metadata, and invokes the Miro API to create an image item on the specified board.fn: async ({ boardId, imageData, position, title }) => { try { if (!boardId) { return ServerResponse.error("Board ID is required"); } if (!imageData) { return ServerResponse.error("Image data is required"); } let imageBuffer; try { const base64Data = imageData.replace(/^data:image\/\w+;base64,/, ''); imageBuffer = Buffer.from(base64Data, 'base64'); } catch (error) { return ServerResponse.error(`Error decoding Base64 image data: ${error.message}`); } try { const metadata = {}; if (position) { metadata['position'] = { ...position, origin: position.origin || 'center', relativeTo: position.relativeTo || 'canvas_center' }; } if (title) { metadata['title'] = title; } const result = await MiroClient.getApi().createImageItemUsingLocalFile(boardId, imageBuffer, metadata); return ServerResponse.text(JSON.stringify(result, null, 2)); } catch (error) { return ServerResponse.error(`Error uploading image to Miro: ${error.message}`); } } catch (error) { return ServerResponse.error(error); } }
- Zod schema defining the input parameters for the tool: boardId, imageData (base64), position object, and optional title.args: { boardId: z.string().describe("Unique identifier (ID) of the board where the image will be created"), imageData: z.string().describe("Base64 encoded image data from the chat"), position: z.object({ x: z.number().describe("X coordinate of the image"), y: z.number().describe("Y coordinate of the image"), origin: z.string().optional().nullish().describe("Origin of the image (center, top-left, etc.)"), relativeTo: z.string().optional().nullish().describe("Reference point (canvas_center, etc.)") }).describe("Position of the image on the board"), title: z.string().optional().nullish().describe("Title of the image") },
- src/index.ts:52-52 (registration)Import statement for the create-image-item-using-file tool definition.import createImageItemUsingFileFromDeviceTool from './tools/createImageItemUsingFileFromDevice.js';
- src/index.ts:152-152 (registration)Registration of the tool with the ToolBootstrapper..register(createImageItemUsingFileFromDeviceTool)