TouchDesigner MCP Server
The `touchdesigner-mcp-server` package provides an implementation of a Model Context Protocol (MCP) server designed to enable AI agents to control and operate TouchDesigner projects programmatically. Functioning as a bridge between AI models and the TouchDesigner WebServer DAT, it allows agents to create, modify, and delete nodes, query project structures, and execute Python scripts within TouchDesigner. The current stable version is 1.4.7, with frequent minor releases as indicated by the recent version history. Key differentiators include its focus on AI agent integration via MCP, semantic versioning for compatibility with the TouchDesigner API server, and a comprehensive set of tools for granular control over TouchDesigner's visual programming environment, making it a powerful tool for generative art, interactive installations, and automated content creation. It ships with TypeScript types, facilitating robust development.
Common errors
-
Error: connect ECONNREFUSED 127.0.0.1:9981
cause The MCP server failed to establish a connection with the TouchDesigner WebServer DAT.fixEnsure TouchDesigner is running, the `mcp_webserver_base.tox` component is imported and active, and the specified host/port (e.g., 127.0.0.1:9981) are correct and not blocked by a firewall. -
Module not found: Can't resolve 'touchdesigner-mcp-server'
cause The package `touchdesigner-mcp-server` is not installed or the import path is incorrect.fixRun `npm install touchdesigner-mcp-server` or `yarn add touchdesigner-mcp-server`. If using global installation for CLI usage, ensure your PATH is configured correctly or use `npx touchdesigner-mcp-server`. -
Error: API below minimum compatible version
cause The `touchdesigner-mcp-server` is attempting to connect to a TouchDesigner API server component (`mcp_webserver_base.tox`) that is older than the minimum required version for the current MCP server.fixUpdate the `mcp_webserver_base.tox` component within your TouchDesigner project to the latest version by downloading `touchdesigner-mcp-td.zip` from the latest release and replacing the old component.
Warnings
- breaking Major version mismatches between the MCP Server and the TouchDesigner API Server are not compatible and will cause the server to stop execution. For example, MCP Server 2.0.0 will not work with a 1.x.x API Server.
- gotcha Correct installation requires importing the `mcp_webserver_base.tox` component into your TouchDesigner project. Failing to do so, or placing it incorrectly, will prevent the MCP server from connecting to and controlling TouchDesigner.
- gotcha Minor version differences between the MCP Server and the TouchDesigner API Server can lead to warnings or missing features, even if basic compatibility is maintained. For instance, an older MCP minor version with a newer API might not expose all new features.
- gotcha The server relies on a live connection to TouchDesigner's WebServer DAT. Connection issues (e.g., `ECONNREFUSED`, `ETIMEDOUT`, `ENOTFOUND`) are common if TouchDesigner is not running, the `WebServer DAT` is not active, or port/host configurations are incorrect.
Install
-
npm install touchdesigner-mcp-server -
yarn add touchdesigner-mcp-server -
pnpm add touchdesigner-mcp-server
Imports
- startMCPServer
const startMCPServer = require('touchdesigner-mcp-server').startMCPServer;import { startMCPServer } from 'touchdesigner-mcp-server'; - MCPServerOptions
import { MCPServerOptions } from 'touchdesigner-mcp-server';import type { MCPServerOptions } from 'touchdesigner-mcp-server'; - TDTool
import { TDTool } from 'touchdesigner-mcp-server';import type { TDTool } from 'touchdesigner-mcp-server/dist/types/tools';
Quickstart
import { startMCPServer } from 'touchdesigner-mcp-server';
import type { MCPServerOptions } from 'touchdesigner-mcp-server';
const serverOptions: MCPServerOptions = {
port: process.env.MCP_SERVER_PORT ? parseInt(process.env.MCP_SERVER_PORT) : 8080,
tdWebServerHost: process.env.TD_WEB_SERVER_HOST ?? '127.0.0.1',
tdWebServerPort: process.env.TD_WEB_SERVER_PORT ? parseInt(process.env.TD_WEB_SERVER_PORT) : 9981,
logLevel: process.env.NODE_ENV === 'production' ? 'info' : 'debug',
// Add any other necessary configuration as per your environment
};
async function main() {
try {
console.log('Starting TouchDesigner MCP Server...');
const server = await startMCPServer(serverOptions);
console.log(`MCP Server running on port ${server.port}, connected to TouchDesigner at ${server.tdWebServerHost}:${server.tdWebServerPort}`);
// Keep the server running
process.on('SIGINT', () => {
console.log('Shutting down MCP Server...');
server.close();
process.exit(0);
});
process.on('SIGTERM', () => {
console.log('Shutting down MCP Server...');
server.close();
process.exit(0);
});
} catch (error) {
console.error('Failed to start MCP Server:', error);
process.exit(1);
}
}
main();