Skip to main content
Glama
TouchDesigner MCP

TouchDesigner MCP

by 8beeeaaat

TouchDesigner MCP

这是 TouchDesigner 的 MCP(模型上下文协议)服务器的实现。目标是使 AI 代理能够控制和操作 TouchDesigner 项目。

英语/日本语

概述

演示片段

TouchDesigner MCP 充当 AI 模型和 TouchDesigner WebServer DAT 之间的桥梁,使 AI 代理能够:

  • 创建、修改和删除节点

  • 查询节点属性和项目结构

  • 通过 Python 脚本以编程方式控制 TouchDesigner

Related MCP server: td-mcp

用法

需要安装 Docker 或 Node.js

教程

1.克隆存储库:

git clone https://github.com/8beeeaaat/touchdesigner-mcp.git
cd touchdesigner-mcp

2.设置环境文件并构建:

在构建 Docker 镜像之前,复制模板文件并根据需要调整 TD_WEB_SERVER_HOST 和 TD_WEB_SERVER_PORT。

cp dotenv .env
make build

3. 在您的 TouchDesigner 项目中安装 API 服务器:

启动 TouchDesigner,并将td/mcp_webserver_base.tox组件直接导入到您想要控制的 TouchDesigner 项目下。例如:将其放置为/project1/mcp_webserver_base

导入 tox 将触发td/import_modules.py脚本,该脚本加载 API 服务器控制器等模块。

进口

您可以通过从 TouchDesigner 菜单打开 Textport 来检查启动日志。

进口

4. 启动 MCP 服务器容器

docker-compose up -d

5. 配置您的 AI 代理以使用 Docker 容器:

Claude Desktop 示例

{
  "mcpServers": {
    "touchdesigner": {
      "command": "docker",
      "args": [
        "compose",
        "-f",
        "/path/to/your/touchdesigner-mcp/docker-compose.yml",
        "exec",
        "-i",
        "touchdesigner-mcp-server",
        "node",
        "dist/index.js",
        "--stdio"
      ]
    }
  }
}

在 Windows 系统上,包括驱动器号,如 C:,例如C:\\path\\to\\your\\touchdesigner-mcp\\docker-compose.yml

要直接从 Node.js 使用预构建的 JS:

教程

1. 安装软件包

mkdir some && cd ./some  # If you need a new directory
npm install touchdesigner-mcp-server

2. 在您的 TouchDesigner 项目中安装 API 服务器:

启动 TouchDesigner,并将some/node_modules/touchdesigner-mcp-server/td/mcp_webserver_base.tox组件直接导入到您想要控制的 TouchDesigner 项目下。例如:将其放置为/project1/mcp_webserver_base

导入 tox 将触发some/node_modules/touchdesigner-mcp-server/td/import_modules.py脚本,该脚本加载 API 服务器控制器等模块。

进口

您可以通过从 TouchDesigner 菜单打开 Textport 来检查启动日志。

进口

3.配置您的AI代理:

Claude Desktop 示例

{
  "mcpServers": {
    "touchdesigner": {
      "args": [
        "/path/to/your/node_modules/touchdesigner-mcp-server/dist/index.js", // <-- Replace with the absolute path to node_modules/touchdesigner-mcp-server/dist/index.js
        "--stdio"
      ],
      "command": "node"
    }
  }
}

在 Windows 系统上,包括驱动器号,如 C: 例如C:\\path\\to\\your\\node_modules\\touchdesigner-mcp-server\\dist\\index.js

3.验证连接

如果 MCP 服务器被识别,则设置完成。如果无法识别,请尝试重新启动 AI 代理。如果启动时出现错误,请先启动 TouchDesigner,然后再尝试重新启动代理。当 API 服务器在 TouchDesigner 中正常运行时,代理可以使用提供的工具来操作 TouchDesigner。

演示

MCP 服务器功能

该服务器通过模型上下文协议(MCP)实现对TouchDesigner的操作,并提供各种实现文档的参考。

工具

工具允许 AI 代理在 TouchDesigner 中执行操作。

工具名称

描述

create_td_node

创建一个新节点。

delete_td_node

删除现有节点。

exec_node_method

在节点上调用 Python 方法。

execute_python_script

在 TD 中执行任意 Python 脚本。

get_td_class_details

获取 TD Python 类/模块的详细信息。

get_td_classes

获取 TouchDesigner Python 类的列表。

get_td_info

获取有关 TD 服务器环境的信息。

get_td_node_parameters

获取特定节点的参数。

get_td_nodes

获取父路径下的节点(可选过滤)。

update_td_node_parameters

更新特定节点的参数。

提示

提示为 AI 代理提供在 TouchDesigner 中执行特定操作的指令。

提示名称

描述

Search node

模糊搜索节点并根据名称、家族、类型检索信息。

Node connection

提供在 TouchDesigner 内连接节点的说明。

Check node errors

检查指定节点的错误,如果有子节点则递归检查。

资源

未实施

对于开发人员

构建客户端和 API 服务器代码

  1. cp dotenv .env

  2. 调整.env文件中的TD_WEB_SERVER_HOST和TD_WEB_SERVER_PORT以匹配您的开发环境

  3. 运行make build或npm run build重新生成代码

当您需要反映构建的代码时,请重新启动 MCP 服务器和 TouchDesigner。

验证 API 服务器

  • npm run test运行 MCP 服务器代码的单元测试,并与 TouchDesigner 进行集成测试。您可以通过从 TouchDesigner 菜单打开 Textport 来查看通信日志。

  • npm run dev启动@modelcontextprotocol/inspector 来调试各种功能。

项目结构概述

├── src/                       # MCP server source code
│   ├── api/                  # OpenAPI spec for TD WebServer
│   ├── core/                 # Core utilities (logger, error handling)
│   ├── features/             # MCP feature implementations
│   │   ├── prompts/         # Prompt handlers
│   │   ├── resources/       # Resource handlers
│   │   └── tools/           # Tool handlers (e.g., tdTools.ts)
│   ├── gen/                  # Code generated from OpenAPI schema for MCP server
│   ├── server/               # MCP server logic (connections, main server class)
│   ├── tdClient/             # TD connection API client
│   ├── index.ts              # Main entry point for Node.js server
│   └── ...
├── td/                        # TouchDesigner related files
│   ├── modules/              # Python modules for TouchDesigner
│   │   ├── mcp/              # Core logic for handling MCP requests in TD
│   │   │   ├── controllers/ # API request controllers (api_controller.py, generated_handlers.py)
│   │   │   └── services/    # Business logic (api_service.py)
│   │   ├── td_server/        # Python model code generated from OpenAPI schema
│   │   └── utils/            # Shared Python utilities
│   ├── templates/             # Mustache templates for Python code generation
│   ├── genHandlers.js         # Node.js script for generating generated_handlers.py
│   ├── import_modules.py      # Helper script to import API server modules into TD
│   └── mcp_webserver_base.tox # Main TouchDesigner component
├── tests/                      # Test code
│   ├── integration/
│   └── unit/
├── .env                        # Local environment variables (git ignored)
├── dotenv                      # Template for .env
└── orval.config.ts             # Orval config (TS client generation)

API 代码生成工作流程

本项目使用基于OpenAPI的代码生成工具(Orval/openapi-generator-cli):

API 定义: Node.js MCP 服务器和 TouchDesigner 内部运行的 Python 服务器之间的 API 契约在src/api/index.yml中定义。

  1. Python 服务器生成( npm run gen:webserver ):

    • 通过 Docker 使用openapi-generator-cli 。

    • 读取src/api/index.yml 。

    • 根据 API 定义生成 Python 服务器框架 ( td/modules/td_server/ )。此代码通过 WebServer DAT 在 TouchDesigner 内部运行。

    • 需要安装并运行 Docker。

  2. Python 处理程序生成( npm run gen:handlers ):

    • 使用自定义 Node.js 脚本( td/genHandlers.js )和 Mustache 模板( td/templates/ )。

    • 读取生成的 Python 服务器代码或 OpenAPI 规范。

    • 生成连接到td/modules/mcp/controllers/generated_handlers.py中的业务逻辑的处理程序实现( td/modules/mcp/services/api_service.py )。

  3. TypeScript 客户端生成( npm run gen:mcp ):

    • 使用Orval从openapi-generator-cli捆绑的模式 YAML 生成 API 客户端代码和 Zod 模式以进行工具验证。

    • 生成 Node.js 服务器使用的类型化 TypeScript 客户端( src/tdClient/ )向 WebServer DAT 发出请求。

构建过程( npm run build )运行所有必要的生成步骤( npm run gen ),然后进行 TypeScript 编译( tsc )。

贡献

欢迎您投稿!

  1. 分叉存储库

  2. 创建功能分支( git checkout -b feature/amazing-feature )

  3. 进行更改

  4. 添加测试并确保一切正常( npm test )

  5. 提交您的更改( git commit -m 'Add some amazing feature' )

  6. 推送到你的分支( git push origin feature/amazing-feature )

  7. 打开拉取请求

在进行实施变更时,请始终包含适当的测试。

执照

麻省理工学院

Available Tools

14 tools
create_td_nodeC

Create a new node in TouchDesigner

Inputs: nodeType (required), parentPath (required), nodeName, detailLevel, +1 more.

delete_td_nodeB

Delete an existing node in TouchDesigner

Inputs: nodePath (required), detailLevel, responseFormat.

describe_td_toolsB

Generate a filesystem-oriented manifest of available TouchDesigner tools

Inputs: filter, detailLevel, responseFormat.

exec_node_methodC

Execute a method on a specific node in TouchDesigner

Inputs: method (required), nodePath (required), args, kwargs, +2 more.

execute_python_scriptC

Execute a Python script in TouchDesigner (detailLevel=minimal|summary|detailed, responseFormat=json|yaml|markdown)

Inputs: script (required), detailLevel, responseFormat.

get_td_class_detailsB

Get information about a TouchDesigner class/module (detailLevel+limit supported)

Inputs: className (required), limit, detailLevel, responseFormat.

get_td_classesB

List TouchDesigner Python classes/modules (detailLevel+limit supported)

Inputs: limit, detailLevel, responseFormat.

get_td_infoC

Get server information from TouchDesigner

Inputs: detailLevel, responseFormat.

get_td_module_helpB

Retrieve Python help() text for a TouchDesigner module or class

Inputs: moduleName (required), detailLevel, responseFormat.

get_td_node_errorsA

Check errors and warnings on a node and its descendants. TouchDesigner reports missing files, dangling operator references and shader compile failures as warnings, so do not treat hasErrors=false as a healthy node. Reads the operator errors and warnings streams only: an exception raised inside a Script OP callback, a scriptCHOP onCook for example, lands on neither and is reported nowhere here, so an empty report is not evidence the node cooked

Inputs: nodePath (required), limit, detailLevel, responseFormat.

get_td_node_parametersB

Get node parameters with concise/detailed formatting (detailLevel+limit supported)

Inputs: nodePath (required), limit, detailLevel, responseFormat.

get_td_nodesB

List nodes under a path with token-optimized output (detailLevel+limit supported)

Inputs: parentPath (required), limit, pattern, detailLevel, +2 more.

get_top_imageA

Capture the current output of a TOP node as an image so it can be viewed directly (maxSize optionally downscales the longer side)

Inputs: nodePath (required), maxSize.

update_td_node_parametersC

Update parameters of a specific node in TouchDesigner

Inputs: nodePath (required), properties (required), detailLevel, responseFormat.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 14 tools

    Disambiguation4/5

    Each tool targets a distinct concern: server info, script execution, node listing/parameters/errors, CRUD, method execution, class/module introspection, image capture, and a tool manifest. get_td_class_details and get_td_module_help are the only close pair, but the descriptions clearly separate detailed info from raw help() text.

    Naming Consistency3/5

    Most tools follow a get/create/update/delete/execute verb prefix, but the TD marker placement is inconsistent (get_td_nodes vs create_td_node vs exec_node_method), and names like get_top_image and describe_td_tools break the pattern. The naming is readable and mostly snake_case, but not fully systematic.

    Tool Count5/5

    14 tools is well within the ideal range for a domain-specific server. Each tool earns its place by covering a meaningful part of the TouchDesigner workflow, with no obvious redundancy or bloat.

    Completeness5/5

    The set provides full node lifecycle coverage (create, read/list, update, delete), parameter access, error checking, arbitrary script execution, node method calls, class/help introspection, and image output capture. The generic execute_python_script tool also acts as a powerful fallback for any uncovered operations.

    Maintenance

    ActivityNo data
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      MCP server for controlling TouchDesigner from AI coding agents like Claude Code and Codex CLI, enabling operator manipulation, parameter control, and screenshot capture.
      12
      MIT
    • A
      license
      B
      quality
      B
      maintenance
      An MCP server for TouchDesigner that lets AI agents inspect, build, wire, optimize, and stabilize live TD networks with 106 tools, plus a technique memory system for reusable patterns.
      114
      17
      MIT