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
        }
      }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It mentions 'optional filters' but doesn't disclose behavioral traits like whether this is a read-only operation, if it requires specific permissions, how results are returned (e.g., pagination), or any rate limits. This leaves significant gaps for a query tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It's appropriately sized and front-loaded, clearly stating the tool's core function without unnecessary details.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, 0% schema coverage, no output schema, and 2 parameters (one with an enum but unexplained), the description is incomplete. It doesn't cover key aspects like return values, error handling, or how to interpret the 'filter' object, making it inadequate for effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It hints at 'optional filters' but doesn't explain what 'filter' or 'type' parameters mean, their formats, or how they interact. With 2 parameters and no schema descriptions, this adds minimal value beyond the bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Query Excalidraw elements with optional filters' states the verb (query) and resource (Excalidraw elements), which is clear. However, it doesn't distinguish this tool from siblings like 'get_resource' or 'update_element'—it's vague about what makes 'query' different from 'get' or how it relates to other element operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. With siblings like 'get_resource' (which might retrieve elements) and 'create_element'/'update_element' for modifications, the description offers no context for choosing 'query_elements' over them or any exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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