td_create_operator
Creates a new TouchDesigner operator with a specified type, name, and network coordinates. Supports all operator classes such as TOPs, CHOPs, SOPs, DATs, and COMPs.
Instructions
Create a new operator in TouchDesigner. Operator types use TD class names like: TOPs: constantTOP, noiseTOP, compositeTOP, levelTOP, feedbackTOP, moviefileinTOP, renderTOP CHOPs: noiseCHOP, lfoCHOP, mathCHOP, filterCHOP, constantCHOP SOPs: sphereSOP, boxSOP, gridSOP, noiseSOP, transformSOP DATs: textDAT, tableDAT, scriptDAT COMPs: geometryCOMP, cameraCOMP, lightCOMP, containerCOMP
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| parent_path | No | Parent operator path, e.g. /project1 | /project1 |
| op_type | Yes | Operator type class name, e.g. noiseTOP, sphereSOP | |
| name | Yes | Name for the new operator | |
| x | No | Horizontal position in network | |
| y | No | Vertical position in network |
Implementation Reference
- server.js:62-96 (registration)Registration of the 'td_create_operator' tool via server.tool() on the MCP server instance.
server.tool( "td_create_operator", `Create a new operator in TouchDesigner. Operator types use TD class names like: TOPs: constantTOP, noiseTOP, compositeTOP, levelTOP, feedbackTOP, moviefileinTOP, renderTOP CHOPs: noiseCHOP, lfoCHOP, mathCHOP, filterCHOP, constantCHOP SOPs: sphereSOP, boxSOP, gridSOP, noiseSOP, transformSOP DATs: textDAT, tableDAT, scriptDAT COMPs: geometryCOMP, cameraCOMP, lightCOMP, containerCOMP`, { parent_path: z .string() .default("/project1") .describe("Parent operator path, e.g. /project1"), op_type: z .string() .describe("Operator type class name, e.g. noiseTOP, sphereSOP"), name: z.string().describe("Name for the new operator"), x: z.number().default(0).describe("Horizontal position in network"), y: z.number().default(0).describe("Vertical position in network"), }, async ({ parent_path, op_type, name, x, y }) => { const code = ` n = op('${parent_path}').create(${op_type}, '${name}') n.nodeX = ${x} n.nodeY = ${y} result = f"Created {n.type} at {n.path}" result `.trim(); const result = await tdExecute(code); return { content: [{ type: "text", text: result }], }; } ); - server.js:83-95 (handler)Handler async function that builds TD Python code to create an operator via op().create(), sets its position, and executes it via tdExecute.
async ({ parent_path, op_type, name, x, y }) => { const code = ` n = op('${parent_path}').create(${op_type}, '${name}') n.nodeX = ${x} n.nodeY = ${y} result = f"Created {n.type} at {n.path}" result `.trim(); const result = await tdExecute(code); return { content: [{ type: "text", text: result }], }; } - server.js:71-82 (schema)Input schema using Zod for parent_path, op_type, name, x, y parameters.
{ parent_path: z .string() .default("/project1") .describe("Parent operator path, e.g. /project1"), op_type: z .string() .describe("Operator type class name, e.g. noiseTOP, sphereSOP"), name: z.string().describe("Name for the new operator"), x: z.number().default(0).describe("Horizontal position in network"), y: z.number().default(0).describe("Vertical position in network"), }, - server.js:14-26 (helper)Helper function tdExecute() that sends Python code to TouchDesigner via HTTP POST and returns the result.
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}?`; } }