Skip to main content
Glama
Axus Revit

Axus Revit

execute_revit_code

Runs IronPython 2.7 code inside Revit within a single transaction and returns printed output, enabling custom model queries or modifications when no dedicated tool applies.

Instructions

Run IronPython 2.7 code inside Revit and return what it prints.

Only use this when no dedicated tool can do the job. The code runs inside a single transaction that is committed on success and rolled back on error, so do not start your own Transaction.

Available names: doc (active Document), DB (Autodesk.Revit.DB), revit (pyRevit helpers), System, clr, and print (its output is returned to you).

IronPython 2.7 rules:

  • no f-strings; use "{}".format(...)

  • Revit stores lengths in feet; divide millimeters by 304.8

  • build element IDs as DB.ElementId(System.Int64(n)); a bare int is ambiguous in Revit 2027

  • some elements lack .Name; read it defensively, e.g. getattr(el, "Name", None) or the ALL_MODEL_TYPE_NAME parameter

  • check doc.GetElement(...) for None before using the result

Example: walls = DB.FilteredElementCollector(doc)
.OfCategory(DB.BuiltInCategory.OST_Walls)
.WhereElementIsNotElementType().ToElements() print("walls: {}".format(len(walls)))

Args: code: IronPython source to execute. description: Short label; it becomes the transaction name shown in Revit's Undo menu.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "code": "<code>"
    },
    "name": "execute_revit_code"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYes
descriptionNoCode execution

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.2.0

TDQS

A4.5/5.0
Behavior3/5

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

With zero annotations, the description carries the full burden and does a lot: it discloses the single-transaction commit-on-success/rollback-on-error model, the available names in scope, and that print output is returned. However, it says nothing about runtime limits, output truncation, how errors surface to the caller, or the destructive potential of committed model changes.

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?

Front-loaded with purpose and the fallback rule, then progressively more detailed rules and an example. The length is justified by the 0% schema coverage, but the example plus six bulleted pitfalls is on the long side and could be trimmed slightly without losing guidance.

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

Completeness5/5

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

For a code-execution tool with no output schema, no annotations, and undocumented parameters, the description supplies everything an agent needs to call it correctly: runtime version, in-scope names, transaction semantics, output capture, and concrete IronPython/Revit pitfalls like feet-vs-mm and defensive .Name access.

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

Parameters5/5

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

Schema coverage is 0%, so the description must compensate, and it does: 'code' is defined as IronPython source, and 'description' is explained as a short label that becomes the transaction name in Revit's Undo menu — a non-obvious side effect the schema's bare 'title: Description, default: Code execution' does not convey.

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?

States a specific verb and resource ('Run IronPython 2.7 code inside Revit') plus the output contract ('return what it prints'). It also distinguishes itself from the many dedicated create_*/get_* siblings by framing itself as the escape hatch, so an agent can place it without opening the schema.

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

Usage Guidelines5/5

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

Explicit when-not guidance: 'Only use this when no dedicated tool can do the job.' It adds a hard operational constraint ('do not start your own Transaction') that prevents a common misuse, which is stronger than most usage sections.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.