Skip to main content
Glama
yctimlin

Excalidraw MCP Server

by yctimlin

get_resource

Retrieve specific Excalidraw resources such as scenes, libraries, themes, or elements using the Excalidraw MCP Server for diagram manipulation and management.

Instructions

Get an Excalidraw resource

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
resourceYes

Implementation Reference

  • The handler case for 'get_resource' tool execution. Validates input with ResourceSchema, fetches the specified resource ('scene', 'library'/'elements', 'theme') from sceneState or canvas API, and returns JSON stringified result.
    case 'get_resource': { const params = ResourceSchema.parse(args); const { resource } = params; logger.info('Getting resource', { resource }); let result: any; switch (resource) { case 'scene': result = { theme: sceneState.theme, viewport: sceneState.viewport, selectedElements: Array.from(sceneState.selectedElements) }; break; case 'library': case 'elements': try { // Get elements from HTTP server const response = await fetch(`${EXPRESS_SERVER_URL}/api/elements`); if (!response.ok) { throw new Error(`HTTP server error: ${response.status} ${response.statusText}`); } const data = await response.json() as ApiResponse; result = { elements: data.elements || [] }; } catch (error) { throw new Error(`Failed to get elements: ${(error as Error).message}`); } break; case 'theme': result = { theme: sceneState.theme }; break; default: throw new Error(`Unknown resource: ${resource}`); } return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; }
  • src/index.ts:314-327 (registration)
    Registration of the 'get_resource' tool in the tools array, defining its name, description, and input schema for MCP capabilities and list_tools.
    { name: 'get_resource', description: 'Get an Excalidraw resource', inputSchema: { type: 'object', properties: { resource: { type: 'string', enum: ['scene', 'library', 'theme', 'elements'] } }, required: ['resource'] } },
  • Zod validation schema (ResourceSchema) used in the handler to parse and validate the tool input parameters.
    const ResourceSchema = z.object({ resource: z.enum(['scene', 'library', 'theme', 'elements']) });

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/yctimlin/mcp_excalidraw'

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