Skip to main content
Glama

query_elements

Query and filter diagram elements in Excalidraw for precise selection and manipulation, enabling efficient scene management and diagram customization via structured API calls.

Instructions

Query Excalidraw elements with optional filters

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filterNo
typeNo

Implementation Reference

  • The switch case that implements the core logic for the 'query_elements' tool. It parses the input arguments using QuerySchema, retrieves all elements, filters them optionally by 'type' and custom 'filter' object matching exact property values, and returns the results as a JSON-formatted text content block.
    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) }] }; }
  • Zod schema defining the input structure for query_elements: optional 'type' enum from EXCALIDRAW_ELEMENT_TYPES and optional 'filter' as a record object for property matching.
    const QuerySchema = z.object({ type: z.enum(Object.values(EXCALIDRAW_ELEMENT_TYPES)).optional(), filter: z.record(z.any()).optional() });
  • src/index.js:155-170 (registration)
    Registration of the 'query_elements' tool in the MCP server capabilities, including description and inputSchema matching the QuerySchema for MCP protocol compliance.
    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 } } } },

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