Skip to main content
Glama
Model MCP

Model MCP

Execute C# Code

revit_execute_code
Destructive

Run C# code on the Revit thread to automate live Revit models, with dry-run rollback and controlled transactions.

Instructions

Run a C# body or public static Script.Execute(ScriptContext ctx) on the Revit thread. revit_api_lookup supplies API metadata. Auto owns a Transaction; group lets scripts own Transactions and edit scopes inside one Undo group. Close all scopes before returning; transaction="none" is refused. Needs confirm_token except dry_run, which rolls back. May commit; revit_jobs polls; retry repeats.

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": "revit_execute_code"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYes
dry_runNo
documentNoTitle or file name substring of the target open document; needed when several are open.
transactionNoauto
confirm_tokenNo
timeout_secondsNo

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv2.0.0
    • changedInput schema / properties / transaction / enum
      Previous value: -[
      -  "auto",
      -  "none"
      -]New value: +[
      +  "auto",
      +  "group",
      +  "none"
      +]
  2. Changed10 schema fields changedv0.10.0
    • removedInput schema / properties / code / title
      Removed value: -"Code"
    • removedInput schema / properties / confirm_token / title
      Removed value: -"Confirm Token"
    • changedInput schema / properties / document / description
      Previous value: -"Case-insensitive substring of the target open document's title or file name. Required to disambiguate when the Revit process has more than one document open; omit only when a single document is open (the active document is used). An unknown or ambiguous reference is rejected before any change."New value: +"Title or file name substring of the target open document; needed when several are open."
    • removedInput schema / properties / document / title
      Removed value: -"Document"
    • removedInput schema / properties / dry_run / title
      Removed value: -"Dry Run"
    • removedInput schema / properties / response_timeout_s
      Removed value: -{
      -  "default": 600,
      -  "maximum": 3600,
      -  "minimum": 30,
      -  "title": "Response Timeout S",
      -  "type": "integer"
      -}
    • addedInput schema / properties / timeout_seconds
      Added value: +{
      +  "default": 600,
      +  "maximum": 3600,
      +  "minimum": 30,
      +  "type": "integer"
      +}
    • removedInput schema / properties / transaction / title
      Removed value: -"Transaction"
    • removedInput schema / title
      Removed value: -"revit_execute_codeArguments"
    • removedOutput schema / title
      Removed value: -"revit_execute_codeDictOutput"
  3. Addedv0.9.1

TDQS

A4.5/5.0
Behavior5/5

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

Annotations flag the tool as destructive and non-idempotent, and the description adds the critical mechanics: transaction ownership modes, the requirement to close all scopes before returning, that transaction="none" is refused, that dry_run rolls back, that the call may commit, and that retry repeats the operation. These are exactly the behaviors an agent needs to avoid corrupting a model.

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?

Purpose is front-loaded and nearly every clause carries load-bearing information (threading, transaction modes, confirmation, rollback, polling). The telegraphic style ('retry repeats') is terse to the point of being slightly cryptic, costing a little clarity.

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?

For a high-risk arbitrary-code-execution tool with an output schema already present, the description covers threading, transaction handling, confirmation, rollback, and follow-up via revit_jobs. The main omission is how an agent obtains a confirm_token and any sandbox/namespace limits on the code, which would round out completeness.

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?

With only 17% schema description coverage, the description does the heavy lifting: it explains the transaction enum ('auto' owns, 'group' lets scripts own scopes in one Undo group, 'none' refused), the confirm_token requirement, and dry_run's rollback semantics. It leaves timeout_seconds and the 200000-char code limit unexplained, so a small gap remains.

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 names a specific action (run C# code) and two accepted code forms ('C# body or public static Script.Execute(ScriptContext ctx)'), plus the execution context ('on the Revit thread'). This is unmistakably different from the CRUD/view siblings, and it points to revit_api_lookup as the metadata source and revit_jobs for polling.

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

Usage Guidelines4/5

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

It gives concrete operating guidance: use revit_api_lookup for API metadata, choose 'auto' vs 'group' for transaction ownership, and confirm_token is required except for dry_run. It does not explicitly say when to prefer this tool over revit_run_tool/revit_run_actions, so the when-not is implied rather than stated.

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

Deploy Server

Other Tools