Skip to main content
Glama

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
NameRequiredDescriptionDefault
resourceYes

Implementation Reference

  • 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) }] }; }
  • 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'] } },

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Abdullah007bajwa/mcp_excalidraw'

If you have feedback or need assistance with the MCP directory API, please join our Discord server