Skip to main content
Glama

query_elements

Find specific elements in Excalidraw diagrams by applying filters to search for shapes, text, or drawings based on type or other criteria.

Instructions

Query Excalidraw elements with optional filters

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
typeNo
filterNo

Implementation Reference

  • The handler function for the 'query_elements' tool. It parses the input arguments using QuerySchema, filters the global 'elements' Map based on optional 'type' and 'filter' parameters, and returns the matching elements as a JSON string in the tool response content.
    case 'query_elements': { const params = QuerySchema.parse(args || {}); const { type, filter } = params; let results = Array.from(elements.values()); if (type) { results = results.filter(element => element.type === type); } if (filter) { results = results.filter(element => { return Object.entries(filter).every(([key, value]) => { return element[key] === value; }); }); } return { content: [{ type: 'text', text: JSON.stringify(results, null, 2) }] }; }
  • src/index.js:155-170 (registration)
    Registration of the 'query_elements' tool in the MCP server capabilities object, defining its description and input schema for tool discovery.
    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 } } } },
  • Zod validation schema (QuerySchema) used internally in the 'query_elements' handler to parse and validate input parameters.
    const QuerySchema = z.object({ type: z.enum(Object.values(EXCALIDRAW_ELEMENT_TYPES)).optional(), filter: z.record(z.any()).optional() });

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