Skip to main content
Glama
mcp-servers-for-revit

MCP server for Revit - Python

execute_revit_code

Run IronPython scripts directly in Revit to access the active document, modify models, and control the UI.

Instructions

Execute IronPython code directly in Revit context.

The code has access to:

  • doc: The active Revit document

  • uidoc: The active UIDocument (use for UI operations like switching the active view)

  • DB: Revit API Database namespace

  • revit: pyRevit module

  • print: Function to output text (returned in response)

No transaction is opened automatically. Wrap model-modifying code yourself: t = DB.Transaction(doc, "My change") t.Start() # ... modify model ... t.Commit()

For UI operations that cannot run inside a transaction (e.g. switching the active view): all_views = DB.FilteredElementCollector(doc).OfClass(DB.View).ToElements() target = next((v for v in all_views if v.Name == "Level 1"), None) if target: uidoc.ActiveView = target

Tips:

  • Use getattr(element, 'Name', 'N/A') to safely access the Name property

  • Check elements exist before use: if element:

  • Use hasattr() for optional properties

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes
descriptionNoCode execution
Behavior4/5

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

Discloses key behaviors: no auto-transaction, print output returned, variables available, and UI operations outside transactions. No annotations provided, so description carries full burden.

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?

Well-structured with sections, front-loaded purpose, and helpful examples, though slightly lengthy.

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

Completeness4/5

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

Covers tool purpose, variables, transaction handling, and usage tips sufficient for correct invocation, despite no output schema or annotations.

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

Parameters4/5

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

Schema has 0% description coverage; description explains code parameter with context of available variables and print, and description parameter as label, adding significant meaning.

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

Purpose5/5

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

The description clearly states it executes IronPython code in Revit context, listing specific variables and capabilities, distinguishing it from siblings that handle specific operations.

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

Usage Guidelines3/5

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

Implicit guidance is given through transaction and UI operation examples, but no explicit when-to-use or alternatives compared to siblings.

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

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