Skip to main content
Glama

query_elements

Search for diagram elements in Excalidraw by type, locked status, or group ID to filter and locate specific components.

Instructions

Search for elements by type, locked status, or group ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
typeNo
lockedNo
groupIdNo

Implementation Reference

  • The main handler function queryElementsTool that executes the query_elements tool logic. It parses input arguments using QuerySchema, builds a search filter object from type/locked/groupId parameters, calls client.searchElements(), and returns the results with success status and count.
    export async function queryElementsTool(
      args: unknown,
      client: CanvasClient
    ) {
      const filter = QuerySchema.parse(args);
      const searchFilter: Record<string, string> = {};
      if (filter.type) searchFilter.type = filter.type;
      if (filter.locked !== undefined) searchFilter.locked = String(filter.locked);
      if (filter.groupId) searchFilter.groupId = filter.groupId;
    
      const elements = await client.searchElements(searchFilter);
      return { success: true, elements, count: elements.length };
    }
  • QuerySchema defines the input validation schema for the query_elements tool. It accepts optional type (enum of element types), locked (boolean), and groupId (string) fields for filtering elements.
    export const QuerySchema = z
      .object({
        type: ElementTypeSchema.optional(),
        locked: z.boolean().optional(),
        groupId: z.string().max(LIMITS.MAX_GROUP_ID_LENGTH).optional(),
      })
      .strict();
  • Registration of the query_elements tool in the MCP server. Defines the tool name, description, input schema using zod validation for optional type/locked/groupId filters, and the async handler function that builds search filters and returns JSON-formatted results.
    // --- Tool: query_elements ---
    server.tool(
      'query_elements',
      'Search for elements by type, locked status, or group ID',
      {
        type: z.enum(ELEMENT_TYPES).optional(),
        locked: z.boolean().optional(),
        groupId: z.string().max(LIMITS.MAX_GROUP_ID_LENGTH).optional(),
      },
      async (filter) => {
        try {
          const searchFilter: Record<string, string> = {};
          if (filter.type) searchFilter.type = filter.type;
          if (filter.locked !== undefined) searchFilter.locked = String(filter.locked);
          if (filter.groupId) searchFilter.groupId = filter.groupId;
    
          const elements = await client.searchElements(searchFilter);
          return {
            content: [{
              type: 'text',
              text: JSON.stringify({ elements, count: elements.length }, null, 2),
            }],
          };
        } catch (err) {
          return { content: [{ type: 'text', text: `Error: ${(err as Error).message}` }], isError: true };
        }
      }
    );
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the tool searches but doesn't describe what 'search' entails—e.g., whether it returns all matches, supports pagination, requires permissions, or has side effects. This is a significant gap for a tool with zero annotation coverage.

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 front-loads the core purpose ('Search for elements') and immediately specifies the criteria, making it easy to parse. Every word earns its place.

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 3 parameters with 0% schema coverage, no annotations, and no output schema, the description is incomplete. It doesn't explain return values, error conditions, or behavioral details like search scope. For a query tool with moderate complexity, this leaves the agent under-informed.

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

Parameters3/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 lists the three parameters (type, locked, groupId) and gives basic meaning (search by type, locked status, or group ID), adding value beyond the bare schema. However, it doesn't explain parameter interactions (e.g., if multiple params are used) or provide examples, leaving gaps.

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

Purpose4/5

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

The description clearly states the tool's purpose with the verb 'Search' and resource 'elements', specifying search criteria (type, locked status, group ID). It distinguishes from siblings like 'create_element' or 'delete_element' by focusing on retrieval rather than modification. However, it doesn't explicitly differentiate from potential similar search tools (none listed in siblings).

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, context for searching elements, or compare with other query/read operations (though no obvious query siblings exist). The agent must infer usage from the purpose alone.

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

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/debu-sinha/excalidraw-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server