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) }`, }, ], }; } } ); }

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