Skip to main content
Glama

get_selected_elements

Retrieve currently selected elements in Revit with optional limit control for focused data extraction.

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

  • The handler function that executes the 'get_selected_elements' MCP tool. It processes the input limit, sends the command to the Revit client, and returns the response as formatted JSON or an 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)
              }`,
            },
          ],
        };
      }
  • Zod input schema for the 'get_selected_elements' tool, defining an optional 'limit' parameter as a number.
    {
      limit: z
        .number()
        .optional()
        .describe("Maximum number of elements to return"),
    },
  • Function that registers the 'get_selected_elements' tool with the MCP server by calling server.tool with 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 but lacks critical details: it doesn't specify what happens if no elements are selected (e.g., returns empty list or error), whether this is a read-only operation, or any performance implications. For a tool with zero annotation coverage, this is inadequate.

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 appropriately concise with two sentences that directly address the tool's function and parameter usage. It's front-loaded with the main purpose and avoids unnecessary details, though it could be slightly more structured by explicitly stating the tool's scope.

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 lack of annotations and output schema, the description is incomplete for a tool that interacts with a complex system like Revit. It doesn't explain the return format (e.g., list of element IDs or full data), error conditions, or dependencies on user selection state, leaving significant gaps for an AI agent to use it correctly.

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 minimal value beyond the input schema: 'You can limit the number of returned elements' implies the 'limit' parameter's purpose but doesn't provide additional semantics like default behavior if omitted or constraints. With 100% schema description coverage, the baseline is 3, and the description doesn't significantly enhance parameter understanding.

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

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 optional parameter usage but doesn't specify when to use this tool versus alternatives like 'get_current_view_elements' or 'ai_element_filter'. No explicit when/when-not or alternative tool references are included.

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

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