Skip to main content
Glama

get_selected_elements

Retrieve elements currently selected in Revit. Optionally limit the number of returned elements to manage data volume.

Instructions

Get elements currently selected in Revit. You can limit the number of returned elements.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of elements to return

Implementation Reference

  • Executes the tool logic: prepares parameters, sends 'get_selected_elements' command via revitClient within a Revit connection, formats response as JSON or error message.
      async (args, extra) => {
        const params = {
          limit: args.limit || 100,
        };
    
        try {
          const response = await withRevitConnection(async (revitClient) => {
            return await revitClient.sendCommand("get_selected_elements", params);
          });
    
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(response, null, 2),
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `get selected elements failed: ${
                  error instanceof Error ? error.message : String(error)
                }`,
              },
            ],
          };
        }
      }
    );
  • Input schema using Zod: optional 'limit' (number) to cap the number of returned elements.
    {
      limit: z
        .number()
        .optional()
        .describe("Maximum number of elements to return"),
    },
  • Function to register the 'get_selected_elements' tool on the MCP server, invoked dynamically from src/tools/register.ts. Includes tool name, description, schema, and handler.
    export function registerGetSelectedElementsTool(server: McpServer) {
      server.tool(
        "get_selected_elements",
        "Get elements currently selected in Revit. You can limit the number of returned elements.",
        {
          limit: z
            .number()
            .optional()
            .describe("Maximum number of elements to return"),
        },
        async (args, extra) => {
          const params = {
            limit: args.limit || 100,
          };
    
          try {
            const response = await withRevitConnection(async (revitClient) => {
              return await revitClient.sendCommand("get_selected_elements", params);
            });
    
            return {
              content: [
                {
                  type: "text",
                  text: JSON.stringify(response, null, 2),
                },
              ],
            };
          } catch (error) {
            return {
              content: [
                {
                  type: "text",
                  text: `get selected elements failed: ${
                    error instanceof Error ? error.message : String(error)
                  }`,
                },
              ],
            };
          }
        }
      );
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the ability to limit returned elements, which is useful, but fails to cover critical aspects: whether this is a read-only operation, what happens if no elements are selected, the format of returned data, potential performance impacts, or any authentication/rate limits. For a tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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

Conciseness4/5

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

The description is concise and front-loaded, with the core purpose stated first in a single sentence. The second sentence adds useful parameter context without redundancy. While efficient, it could be slightly improved by integrating the parameter note more seamlessly, but overall it avoids waste and is well-structured.

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 the tool's complexity (interacting with Revit selections) and lack of annotations or output schema, the description is insufficient. It doesn't explain what 'elements' entail, the return format, error conditions, or dependencies like needing an active Revit session. For a tool with no structured data to fall back on, this leaves too many unknowns for effective agent use.

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?

The description adds some value by explaining the 'limit' parameter's purpose ('limit the number of returned elements'), which aligns with the schema's 100% coverage. However, it doesn't provide additional context beyond what the schema already documents, such as default behavior when 'limit' is omitted or practical usage examples. With high schema coverage, the baseline is met but not exceeded.

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: 'Get elements currently selected in Revit.' It specifies the verb ('Get') and resource ('elements currently selected in Revit'), making the function unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'get_current_view_elements' or 'ai_element_filter', which prevents a perfect score.

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 minimal guidance: 'You can limit the number of returned elements' hints at an optional parameter but offers no context on when to use this tool versus alternatives like 'get_current_view_elements' or 'ai_element_filter'. There's no mention of prerequisites, such as needing an open document or active selection, nor any exclusions or typical use cases.

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/ideook/revit-mcp'

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