Skip to main content
Glama
inventor-mcp-server

inventor-mcp-server

execute_python

Run Python code against a live Autodesk Inventor session to automate parametric modeling, inspect or modify active documents, and roll back changes on errors.

Instructions

Execute Python code against the live Inventor connection.

Pre-bound objects (re-resolved fresh on every call): inv — InventorConnection wrapper (all high-level methods, mm units) app — Inventor.Application COM object doc — active document comp — its ComponentDefinition body — comp.SurfaceBodies.Item(1) (or None) tg — TransientGeometry math — math module progress(msg) — status line manage_call shows while a long job runs cancelled() — True once manage_call(action='cancel') asked to stop: poll it in long loops Variables you assign persist between calls until the server restarts or reload_api runs — get_status shows the namespace's age and names. Each connected Inventor has its own namespace. Helpers you need every time: put them in a file and load_library it (or in ~/.inventor-mcp/startup.py) — they come back by themselves in a new namespace. Internal COM units are CENTIMETERS — divide mm by 10. Objects are late-bound: a Document from Documents.Open exposes ComponentDefinition directly. Don't use CastTo / gencache.EnsureDispatch (they create a gen_py cache). Runs with SilentOperation on, so Inventor answers its own prompts instead of opening a dialog. Save with the save_document tool or inv.save_document(): a plain doc.SaveAs also writes every dirty dependent, protected and Content Center files included. A call longer than the wait limit keeps running; follow it with manage_call(wait_seconds=30), which shows the prints so far; manage_call(action='cancel') stops it. Returns captured stdout + stderr (print your results!), or the traceback from your own code down on error (COM errors named: E_INVALIDARG, RPC_E_DISCONNECTED …).

Args: code: Python source. undo_on_error: Run inside one undo transaction on the active document and roll it back if the code raises — no half-built sketches or work planes left behind. timeout: Seconds; then cancelled() turns True, and the run is interrupted CANCEL_GRACE s later if it hasn't stopped — as manage_call(action='cancel') does (0 = none).

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_python"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYes
timeoutNo
instanceNoWhich connected Inventor to use (list_instances). Leave empty when only one is connected.
undo_on_errorNo

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.8.0

TDQS

A4.4/5.0
Behavior5/5

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

With no annotations, the description carries the full burden and does so thoroughly: namespace persistence, per-instance namespaces, SilentOperation, the SaveAs side-effects on dependent/protected/Content Center files, late-binding rules, cancellation grace period, and return of stdout/stderr or traceback with named COM errors.

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?

Length is justified by tool complexity and it is front-loaded with purpose followed by a structured pre-bound objects list. Dense but nearly every line earns its place; minor cognitive load from the compact multi-item bullet line ('doc — ... comp — ...').

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 powerful code-execution tool with an output schema (so return shape is covered structurally), the description still adds return/error detail, unit gotchas (cm vs mm), and save semantics. An agent has everything needed to call it correctly and safely.

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 coverage is only 25% (only `instance` is documented in-schema), and the description compensates well by explaining undo_on_error (rollback of half-built sketches/work planes) and timeout (cancelled() semantics and CANCEL_GRACE). `code` is only described minimally as 'Python source', leaving a small gap.

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 ('Execute Python code against the live Inventor connection') and the pre-bound object list makes clear this is a general escape-hatch distinct from the many specialized sibling tools (manage_features, extrude, fillet, etc.). An agent can tell exactly what this does versus its siblings.

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?

Provides rich operational context (cancellation flow, persistence, helper loading via load_library/startup.py) but never explicitly states when to reach for this over a specialized sibling like extrude or manage_features. Usage is implied by the escape-hatch nature rather than stated as a rule.

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