get_resource
Retrieve specific Excalidraw resources such as scenes, libraries, themes, or elements through a structured API, enabling efficient diagram management and manipulation.
Instructions
Get an Excalidraw resource
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| resource | Yes |
Implementation Reference
- src/index.js:442-478 (handler)Handler function for the 'get_resource' tool. Parses input using ResourceSchema, switches on the 'resource' type (scene, library, theme, elements), retrieves the corresponding data from sceneState or elements, and returns it as JSON text content.case 'get_resource': { const params = ResourceSchema.parse(args); const { resource } = params; logger.info('Getting resource', { resource }); let result; switch (resource) { case 'scene': result = { theme: sceneState.theme, viewport: sceneState.viewport, selectedElements: Array.from(sceneState.selectedElements) }; break; case 'library': result = { elements: Array.from(elements.values()) }; break; case 'theme': result = { theme: sceneState.theme }; break; case 'elements': result = { elements: Array.from(elements.values()) }; break; default: throw new Error(`Unknown resource: ${resource}`); } return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; }
- src/index.js:75-77 (schema)Zod schema used for input validation in the get_resource handler, defining the 'resource' parameter as an enum.const ResourceSchema = z.object({ resource: z.enum(['scene', 'library', 'theme', 'elements']) });
- src/index.js:171-183 (registration)Registration of the 'get_resource' tool in the MCP server capabilities, including description and input schema matching the Zod schema.get_resource: { description: 'Get an Excalidraw resource', inputSchema: { type: 'object', properties: { resource: { type: 'string', enum: ['scene', 'library', 'theme', 'elements'] } }, required: ['resource'] } },