Implementation:8beeeaaat Touchdesigner mcp exec node method
| Knowledge Sources | |
|---|---|
| Domains | Code_Execution, Remote_Procedure_Call |
| Last Updated | 2026-10-28 22:13 GMT |
Overview
Concrete tool for invoking a named method on a TouchDesigner node by path, with validation that the attribute exists and is callable before executing.
Description
The exec_node_method method on `TouchDesignerApiService` resolves a node via `td.op(node_path)`, checks that the named method attribute exists (`hasattr`) and is callable, invokes it with the supplied positional and keyword arguments, and JSON-serializes the return value. It is the structured execution mode — safer than free-form scripts because the caller names a specific attribute and the runtime validates it.
Usage
Call this method when you need to:
- Apply a fix by calling a specific method on a node (e.g. `pulse` on a parameter, `destroy` on a node).
- Wire connections by calling `inputConnectors[0].connect(target)`.
- Call any known method on a node where the method name and arguments are already determined.
This method is exposed as the `execute_node_method` MCP tool. It is shared by the Node Error Investigation workflow (Step 3: Apply the Fix) and the Node Creation workflow (Step 4: Wire Connections).
Code Reference
Source Location
- Repository: touchdesigner-mcp
- File: td/modules/mcp/services/api_service.py
- Lines: L441-470 (public method); helper `_process_method_result` in the same file
Signature
class TouchDesignerApiService:
def exec_node_method(
self, node_path: str, method: str, args: list, kwargs: dict
) -> Result:
"""Call method on the specified node.
Args:
node_path: Absolute TD operator path.
method: Attribute name on the OP (e.g. "inputConnectors[0].connect"
is not valid here — method is a single attribute name).
args: Positional arguments for the method call.
kwargs: Keyword arguments for the method call.
Returns:
Result: success_result with {"result": processed_result},
or error_result if node/method not found or not callable.
"""
Import
from mcp.services.api_service import TouchDesignerApiService
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| node_path | str | Yes | Absolute TD operator path |
| method | str | Yes | Attribute name on the OP (must be callable) |
| args | list | Yes | Positional arguments (can be empty) |
| kwargs | dict | Yes | Keyword arguments (can be empty) |
Outputs
| Name | Type | Description |
|---|---|---|
| result | Any | JSON-serialized return value of the method call |
Usage Examples
Pulse a Parameter
from mcp.services.api_service import TouchDesignerApiService
service = TouchDesignerApiService()
result = service.exec_node_method(
node_path="/project1/text1",
method="pulse",
args=[],
kwargs={"frames": 1}, # pulse for 1 frame
)
if result["success"]:
print(f"Method returned: {result['data']['result']}")
Wire a Connection
# Connect input 0 of a node to a source node
result = service.exec_node_method(
node_path="/project1/noise1",
method="inputConnectors",
args=[0], # index into inputConnectors list — returns a connector object
kwargs={},
)
# Note: for chained attribute access like inputConnectors[0].connect(target),
# use exec_python_script instead, since exec_node_method resolves a single
# attribute name, not a subscripted expression.