Skip to main content
Glama
aliphi

touchdesigner-mcp

by aliphi

td_run_python

Run Python code inside TouchDesigner to control operators, create TOPs, set parameters, and position nodes using full path references.

Instructions

Execute Python code inside TouchDesigner. Use op() to reference operators. Examples:

  • op('/project1/container1') to get an operator

  • op('/project1').create(constantTOP, 'my_top') to create a TOP

  • op('/project1/my_top').par.colorr = 1.0 to set a parameter

  • op('/project1/my_top').nodeX = 200 to position in the network Always use full paths starting with /project1.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesPython code to execute in TouchDesigner

Implementation Reference

  • server.js:39-57 (registration)
    The 'td_run_python' tool is registered using server.tool() with schema (z.object) and handler.
    server.tool(
      "td_run_python",
      `Execute Python code inside TouchDesigner.
    Use op() to reference operators. Examples:
      - op('/project1/container1') to get an operator
      - op('/project1').create(constantTOP, 'my_top') to create a TOP
      - op('/project1/my_top').par.colorr = 1.0 to set a parameter
      - op('/project1/my_top').nodeX = 200 to position in the network
    Always use full paths starting with /project1.`,
      {
        code: z.string().describe("Python code to execute in TouchDesigner"),
      },
      async ({ code }) => {
        const result = await tdExecute(code);
        return {
          content: [{ type: "text", text: result }],
        };
      }
    );
  • Input schema: code is a required string, described as 'Python code to execute in TouchDesigner'.
    {
      code: z.string().describe("Python code to execute in TouchDesigner"),
    },
  • server.js:51-56 (handler)
    Handler function: receives { code }, calls tdExecute(code), and returns { content: [{ type: 'text', text: result }] }.
    async ({ code }) => {
      const result = await tdExecute(code);
      return {
        content: [{ type: "text", text: result }],
      };
    }
  • Helper function tdExecute(code): sends Python code via HTTP POST to TouchDesigner's Web Server DAT at localhost:9980.
    async function tdExecute(code) {
      try {
        const res = await fetch(`${TD_HOST}:${TD_PORT}`, {
          method: "POST",
          headers: { "Content-Type": "application/json" },
          body: JSON.stringify({ script: code }),
        });
        const text = await res.text();
        return text;
      } catch (err) {
        return `Error connecting to TouchDesigner: ${err.message}. Is TD running with the Web Server DAT on port ${TD_PORT}?`;
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. While it explains how to write code, it does not disclose potential risks, such as destructive operations or security implications. As a code execution tool, more transparency about side effects is needed.

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?

The description is concise and front-loaded with the purpose, followed by relevant examples. Every sentence serves a clear purpose, and the structure is efficient without unnecessary words.

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?

Given the tool's complexity (code execution) and lack of output schema, the description adequately explains how to interact (op() usage, full paths). It could mention error handling, but overall it is sufficiently complete for an agent to invoke correctly.

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?

The schema already describes the 'code' parameter with 100% coverage, but the description adds value by providing examples and best practices (e.g., full paths, common operations). This goes beyond the schema's basic description.

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 clearly states 'Execute Python code inside TouchDesigner', which is a specific verb+resource. It distinguishes itself from sibling tools like td_connect, td_create_operator, td_list_operators, and td_set_parameter, which handle specific operations 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 Guidelines3/5

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

The description provides examples and guidance on using op() and full paths, implying when to use the tool (for custom Python execution). However, it does not explicitly state when not to use it or provide alternatives, leaving the agent to infer usage context.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/aliphi/touchdesigner-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server