Skip to main content
Glama
yctimlin

Excalidraw MCP Server

by yctimlin

query_elements

Retrieve specific elements from Excalidraw diagrams using customizable filters, enabling targeted diagram analysis and manipulation via structured API queries.

Instructions

Query Excalidraw elements with optional filters

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filterNo
typeNo

Implementation Reference

  • The handler for the 'query_elements' tool. Parses input using QuerySchema, constructs a query to the canvas API (/api/elements/search), fetches matching elements, and returns them as JSON.
    case 'query_elements': { const params = QuerySchema.parse(args || {}); const { type, filter } = params; try { // Build query parameters const queryParams = new URLSearchParams(); if (type) queryParams.set('type', type); if (filter) { Object.entries(filter).forEach(([key, value]) => { queryParams.set(key, String(value)); }); } // Query elements from HTTP server const url = `${EXPRESS_SERVER_URL}/api/elements/search?${queryParams}`; const response = await fetch(url); if (!response.ok) { throw new Error(`HTTP server error: ${response.status} ${response.statusText}`); } const data = await response.json() as ApiResponse; const results = data.elements || []; return { content: [{ type: 'text', text: JSON.stringify(results, null, 2) }] }; } catch (error) { throw new Error(`Failed to query elements: ${(error as Error).message}`); } }
  • Zod schema for validating input parameters (type and filter) used in the query_elements handler.
    const QuerySchema = z.object({ type: z.enum(Object.values(EXCALIDRAW_ELEMENT_TYPES) as [ExcalidrawElementType, ...ExcalidrawElementType[]]).optional(), filter: z.record(z.any()).optional() });
  • src/index.ts:297-313 (registration)
    Registration of the 'query_elements' tool in the tools array, including its MCP input schema definition. Used for tool listing and capabilities.
    { name: 'query_elements', description: 'Query Excalidraw elements with optional filters', inputSchema: { type: 'object', properties: { type: { type: 'string', enum: Object.values(EXCALIDRAW_ELEMENT_TYPES) }, filter: { type: 'object', additionalProperties: true } } } },
  • JSON schema for the 'query_elements' tool input, defining optional 'type' enum and flexible 'filter' object. Part of tool registration.
    inputSchema: { type: 'object', properties: { type: { type: 'string', enum: Object.values(EXCALIDRAW_ELEMENT_TYPES) }, filter: { type: 'object', additionalProperties: true } }

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