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
| Name | Required | Description | Default |
|---|---|---|---|
| type | No | ||
| filter | No |
Implementation Reference
- src/index.js:419-440 (handler)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 } } } },
- src/index.js:70-73 (schema)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() });