td_connect
Connect a source operator's output to a destination operator's input in TouchDesigner, specifying output and input indices.
Instructions
Connect the output of one operator to the input of another operator in TouchDesigner.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"from_path": "<from_path>",
"to_path": "<to_path>"
},
"name": "td_connect"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| from_path | Yes | Path of the source operator | |
| to_path | Yes | Path of the destination operator | |
| from_output | No | Output index (default 0) | |
| to_input | No | Input index (default 0) |
Implementation Reference
- server.js:133-151 (registration)Registration of the 'td_connect' tool via server.tool(), defining its name, description, Zod schema for params (from_path, to_path, from_output, to_input), and the async handler that builds TouchDesigner Python code to connect two operators.
server.tool( "td_connect", "Connect the output of one operator to the input of another operator in TouchDesigner.", { from_path: z.string().describe("Path of the source operator"), to_path: z.string().describe("Path of the destination operator"), from_output: z.number().default(0).describe("Output index (default 0)"), to_input: z.number().default(0).describe("Input index (default 0)"), }, async ({ from_path, to_path, from_output, to_input }) => { const code = ` op('${to_path}').inputConnectors[${to_input}].connect(op('${from_path}').outputConnectors[${from_output}]) f"Connected {op('${from_path}').path} -> {op('${to_path}').path}" `.trim(); const result = await tdExecute(code); return { content: [{ type: "text", text: result }], }; } - server.js:142-151 (handler)The async handler function that receives from_path, to_path, from_output, to_input, constructs a Python script to connect operator outputs to inputs via TouchDesigner's connector API, executes it via tdExecute(), and returns the result as text content.
async ({ from_path, to_path, from_output, to_input }) => { const code = ` op('${to_path}').inputConnectors[${to_input}].connect(op('${from_path}').outputConnectors[${from_output}]) f"Connected {op('${from_path}').path} -> {op('${to_path}').path}" `.trim(); const result = await tdExecute(code); return { content: [{ type: "text", text: result }], }; } - server.js:136-141 (schema)Zod schema for td_connect tool inputs: from_path (string), to_path (string), from_output (number, default 0), to_input (number, default 0).
{ from_path: z.string().describe("Path of the source operator"), to_path: z.string().describe("Path of the destination operator"), from_output: z.number().default(0).describe("Output index (default 0)"), to_input: z.number().default(0).describe("Input index (default 0)"), }, - server.js:14-26 (helper)The tdExecute helper function that sends Python code to TouchDesigner's Web Server DAT via HTTP POST and returns the response text.
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}?`; } }