td_set_parameter
Set a parameter on any TouchDesigner operator using its path, parameter name, and value. Supports strings, numbers, and booleans for TOPs, SOPs, CHOPs, and general parameters.
Instructions
Set a parameter on a TouchDesigner operator. Common parameter names:
TOPs: colorr, colorg, colorb, colora, resolutionw, resolutionh, brightness, contrast, opacity
SOPs: radx, rady, radz (radius), tx, ty, tz (translate), rows, cols
CHOPs: roughness, amp, freq, period
General: display, render, bypass
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| op_path | Yes | Full path to the operator, e.g. /project1/noise1 | |
| param_name | Yes | Parameter name, e.g. colorr, resolutionw | |
| value | Yes | Value to set |
Implementation Reference
- server.js:101-128 (registration)Registers the 'td_set_parameter' tool on the MCP server with name, description, and schema.
server.tool( "td_set_parameter", `Set a parameter on a TouchDesigner operator. Common parameter names: - TOPs: colorr, colorg, colorb, colora, resolutionw, resolutionh, brightness, contrast, opacity - SOPs: radx, rady, radz (radius), tx, ty, tz (translate), rows, cols - CHOPs: roughness, amp, freq, period - General: display, render, bypass`, { op_path: z.string().describe("Full path to the operator, e.g. /project1/noise1"), param_name: z.string().describe("Parameter name, e.g. colorr, resolutionw"), value: z .union([z.string(), z.number(), z.boolean()]) .describe("Value to set"), }, async ({ op_path, param_name, value }) => { const pyValue = typeof value === "string" ? `'${value}'` : String(value); const code = ` op('${op_path}').par.${param_name} = ${pyValue} f"Set {op('${op_path}').path}.par.${param_name} = ${pyValue}" `.trim(); const result = await tdExecute(code); return { content: [{ type: "text", text: result }], }; } ); - server.js:109-115 (schema)Defines the input schema: op_path (string), param_name (string), value (union of string/number/boolean).
{ op_path: z.string().describe("Full path to the operator, e.g. /project1/noise1"), param_name: z.string().describe("Parameter name, e.g. colorr, resolutionw"), value: z .union([z.string(), z.number(), z.boolean()]) .describe("Value to set"), }, - server.js:116-127 (handler)Handler function that takes op_path, param_name, value, formats a Python expression, sends it to TouchDesigner via tdExecute, and returns the result text.
async ({ op_path, param_name, value }) => { const pyValue = typeof value === "string" ? `'${value}'` : String(value); const code = ` op('${op_path}').par.${param_name} = ${pyValue} f"Set {op('${op_path}').path}.par.${param_name} = ${pyValue}" `.trim(); const result = await tdExecute(code); return { content: [{ type: "text", text: result }], }; } - server.js:14-26 (helper)tdExecute helper function that sends Python code to TouchDesigner's Web Server DAT via HTTP POST.
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}?`; } }