Skip to main content
Glama

Execute Code

execute_code
Destructive

Run Python or MEL code in an active Maya session to inspect scenes, build assets, or verify results. Requires an existing session; changes cannot be undone.

Instructions

Execute arbitrary Python or MEL code in an active Maya session.

Runs arbitrary code with full session privileges of the connected Maya process. Execution is irreversible and cannot be undone (modifications do not register an automatic undo chunk). The return value shape is governed by the result_type envelope parameter. Requires an established Maya session (discoverable via list_sessions).

Input Schema

NameRequiredDescriptionDefault
codeYesPython or MEL code to execute in Maya.
result_typeNoReturn envelope handling for the execution result: - "NONE": Execute statements, don't capture result (returns None) - "JSON": Evaluate expression, JSON-encode result - "RAW": Evaluate expression, return string representationNONE
session_keyNoMaya session key (optional if only one session exists).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv0.5.0
    • changedInput schema / properties / code / description
      Previous value: -"Python code to execute."New value: +"Python or MEL code to execute in Maya."
    • changedInput schema / properties / result_type / description
      Previous value: -"How to handle the result:\n- \"NONE\": Execute statements, don't capture result\n- \"JSON\": Evaluate expression, JSON encode result\n- \"RAW\": Evaluate expression, return string representation"New value: +"Return envelope handling for the execution result:\n- \"NONE\": Execute statements, don't capture result (returns None)\n- \"JSON\": Evaluate expression, JSON-encode result\n- \"RAW\": Evaluate expression, return string representation"
    • changedInput schema / properties / session_key / description
      Previous value: -"Session key (optional if only one session exists)"New value: +"Maya session key (optional if only one session exists)."
  2. First observedv0.4.1

TDQS

A4.5/5.0
Behavior5/5

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

Adds substantial context beyond annotations: runs with full session privileges, execution is irreversible and cannot be undone, modifications do not register an automatic undo chunk, and the return value shape is governed by result_type. This is exactly the behavioral detail an agent needs for a destructive code-execution tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loads purpose, then behavior, irreversibility, return handling, and session requirement. Every sentence adds a necessary operational detail with no filler.

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 dangerous arbitrary-code tool with no output schema, the description covers execution scope, privileges, irreversibility, undo behavior, return envelope control, and session requirements. An agent has enough context to invoke it correctly and cautiously.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already explains code, result_type, and session_key in detail. The description only notes that result_type governs the return envelope, adding little beyond the structured field documentation. Baseline 3 is appropriate.

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 arbitrary Python or MEL code in an active Maya session. This distinguishes it from all scene_* siblings, which operate on scene data rather than arbitrary code execution.

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?

Provides a clear prerequisite: an active Maya session, discoverable via list_sessions. It does not explicitly name alternatives or when not to use this tool versus scene_* tools, but the intended context is unambiguous.

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