touchdesigner-mcp-server
Version:
MCP server for TouchDesigner
60 lines (59 loc) • 2.38 kB
TypeScript
import { z } from "zod";
import type { ILogger } from "../../core/logger.js";
import type { TouchDesignerClient } from "../../tdClient/touchDesignerClient.js";
import type { ToolNames } from "./index.js";
export type ToolCategory = "system" | "python" | "nodes" | "classes" | "state";
/** MCP text content block. */
export interface ToolTextContent {
type: "text";
text: string;
}
/** MCP image content block (base64-encoded). */
export interface ToolImageContent {
type: "image";
data: string;
mimeType: string;
}
export type ToolContent = ToolTextContent | ToolImageContent;
/**
* A tool's `run` normally returns formatter-ready text, which is wrapped in a
* single text content block. Tools that need to return non-text content
* (e.g. an image) return `{ content }` with the full content block list
* instead.
*/
export type ToolRunResult = string | {
content: ToolContent[];
};
/**
* Single source of truth for a TouchDesigner MCP tool.
*
* Both the MCP registration loop (`registerTdTools`) and the
* `describe_td_tools` manifest (`buildToolMetadata`) are derived from this
* table, so a tool's description and input parameters can never drift between
* what is registered and what is documented. Parameter metadata is introspected
* directly from `schema`, which itself originates from the OpenAPI spec.
*/
export interface ToolDefinition {
/** Registered MCP tool name (also the source for functionName/modulePath). */
name: ToolNames;
/** Agent-facing description, used for both registration and the manifest. */
description: string;
category: ToolCategory;
/** Composed Zod schema: OpenAPI-derived params extended with formatting flags. */
schema: z.ZodObject<z.ZodRawShape>;
/** Human summary of the return payload (manifest only). */
returns: string;
/** Usage example shown in the detailed manifest view (manifest only). */
example: string;
notes?: string;
/** Optional reference comment appended to error output. */
errorComment?: string;
/** Executes the tool and returns formatter-ready text (or explicit content blocks). */
run: (ctx: ToolRunContext) => Promise<ToolRunResult>;
}
export interface ToolRunContext {
params: Record<string, unknown>;
tdClient: TouchDesignerClient;
logger: ILogger;
}
export declare const TOOL_DEFINITIONS: ToolDefinition[];