Skip to main content
Glama
Aitidi
by Aitidi

execute_python_script

Run custom Python code in Cinema 4D to access the full c4d API for complex scene manipulation, animation, and MoGraph operations when other tools fall short.

Instructions

Execute a Python script in Cinema 4D's Python environment.

This is the most reliable tool for non-trivial operations — it gives full access
to the c4d API and avoids wrapper/schema mismatches that can affect other tools.

Args:
    script: Python code to execute in Cinema 4D. Has access to `c4d` and
        `c4d.modules.mograph` modules.

Important usage notes:
    - For animated/MoGraph data, always call doc.ExecutePasses() after SetTime():
        doc.SetTime(c4d.BaseTime(frame, fps))
        doc.ExecutePasses(None, True, True, True, c4d.BUILDFLAGS_NONE)
    - For MoGraph/effector data, iterate frames sequentially (0..N) rather than
      jumping directly to a later frame — sequential stepping produces more
      faithful results.
    - Security restrictions block certain keywords: import os, subprocess, exec(, eval(.
      Keep scripts within the c4d API surface.
    - For heavy operations (dense frame loops, complex MoGraph scenes), split work
      into multiple smaller scripts rather than one large monolith.
    - Use print() to return results — output is captured and returned.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
scriptYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.2

TDQS

A4.4/5.0
Behavior4/5

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

No annotations are given, so the description carries the behavioral disclosure burden. It discloses security restrictions, print-based output capture, and advises sequential frame stepping for fidelity—all behaviors beyond the raw schema. It could additionally state scene mutation/side effects, but it already makes the environment and restrictions clear.

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?

The description is front-loaded with the tool's purpose and then supplies operationLogically organized bullet-point notes. It is somewhat longer than a one-liner, but every sentence earns its place by giving necessary execution, security, and frame-iteration guidance.

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 an open-ended Python execution tool, the description is fairly rich: publication does not explicitly mention `doc` is in scope, but examples use it. Given output schema is declared and this is a powerful script executor, the existing notes cover the main hazards; minor omission of the doc variable remains, but the overall context is enough.

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?

The input schema provides only the name 'script' with type string and zero description coverage. The description fully compensates by stating the script is Python code to execute can import c4d and c4d.modules.mograph, and some print() returns results? Actually the description explains all meaning needed for the sole parameter.

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 states a specific verb-resource pair: 'Execute a Python script in Cinema 4D's Python environment.' It also distinguishes this tool from siblings by highlighting full c4d API access and calling it the most reliable tool for non-trivial operations, so an agent can clearly tell when it fits.

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 clear context for when to use the tool, such as for animated/MoGraph data needing doc.ExecutePasses(), sequential frame iteration, and heavy operations split into smaller scripts. It does not explicitly list alternative tools for exclusion, but the context is specific enough to guide correct invocation.

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