touchdesigner-mcp-server 1.4.9 → 1.4.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/customInstance.d.ts +5 -0
- package/dist/cli.d.ts +50 -0
- package/dist/core/compatibility.d.ts +102 -0
- package/dist/core/constants.d.ts +29 -0
- package/dist/core/errorHandling.d.ts +18 -0
- package/dist/core/logger.d.ts +24 -0
- package/dist/core/result.d.ts +25 -0
- package/dist/core/version.d.ts +21 -0
- package/dist/features/prompts/handlers/td_prompts.d.ts +6 -0
- package/dist/features/prompts/index.d.ts +1 -0
- package/dist/features/prompts/register.d.ts +6 -0
- package/dist/features/tools/handlers/tdTools.d.ts +4 -0
- package/dist/features/tools/index.d.ts +3 -0
- package/dist/features/tools/metadata/touchDesignerToolMetadata.d.ts +29 -0
- package/dist/features/tools/presenter/classListFormatter.d.ts +29 -0
- package/dist/features/tools/presenter/index.d.ts +18 -0
- package/dist/features/tools/presenter/markdownRenderer.d.ts +3 -0
- package/dist/features/tools/presenter/moduleHelpFormatter.d.ts +12 -0
- package/dist/features/tools/presenter/nodeDetailsFormatter.d.ts +16 -0
- package/dist/features/tools/presenter/nodeErrorsFormatter.d.ts +4 -0
- package/dist/features/tools/presenter/nodeListFormatter.d.ts +22 -0
- package/dist/features/tools/presenter/operationFormatter.d.ts +16 -0
- package/dist/features/tools/presenter/presenter.d.ts +10 -0
- package/dist/features/tools/presenter/responseFormatter.d.ts +83 -0
- package/dist/features/tools/presenter/scriptResultFormatter.d.ts +23 -0
- package/dist/features/tools/presenter/toolMetadataFormatter.d.ts +7 -0
- package/dist/features/tools/register.d.ts +7 -0
- package/dist/features/tools/toolDefinitions.d.ts +38 -0
- package/dist/features/tools/types.d.ts +43 -0
- package/dist/features/tools/utils/toolUtils.d.ts +0 -0
- package/dist/gen/endpoints/TouchDesignerAPI.d.ts +510 -0
- package/dist/gen/mcp/touchDesignerAPI.zod.d.ts +253 -0
- package/dist/index.d.ts +3 -0
- package/dist/server/connectionManager.d.ts +25 -0
- package/dist/server/touchDesignerServer.d.ts +59 -0
- package/dist/tdClient/index.d.ts +7 -0
- package/dist/tdClient/touchDesignerClient.d.ts +167 -0
- package/dist/transport/config.d.ts +96 -0
- package/dist/transport/expressHttpManager.d.ts +86 -0
- package/dist/transport/factory.d.ts +81 -0
- package/dist/transport/index.d.ts +15 -0
- package/dist/transport/sessionManager.d.ts +180 -0
- package/dist/transport/transportRegistry.d.ts +92 -0
- package/dist/transport/validator.d.ts +43 -0
- package/package.json +1 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type AxiosError, type AxiosRequestConfig } from "axios";
|
|
2
|
+
export declare const AXIOS_INSTANCE: import("axios").AxiosInstance;
|
|
3
|
+
export declare const customInstance: <T>(config: AxiosRequestConfig, options?: AxiosRequestConfig) => Promise<T>;
|
|
4
|
+
export type ErrorType<E> = AxiosError<E>;
|
|
5
|
+
export type BodyType<BodyData> = BodyData;
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import type { TransportConfig } from "./transport/config.js";
|
|
3
|
+
/**
|
|
4
|
+
* Parse command line arguments for TouchDesigner connection
|
|
5
|
+
*/
|
|
6
|
+
export declare function parseArgs(args?: string[]): {
|
|
7
|
+
host: string;
|
|
8
|
+
port: number;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Parse transport configuration from command line arguments
|
|
12
|
+
*
|
|
13
|
+
* Detects if HTTP mode is requested via --mcp-http-port flag.
|
|
14
|
+
* If not specified, defaults to stdio mode.
|
|
15
|
+
*
|
|
16
|
+
* @param args - Command line arguments (defaults to process.argv.slice(2))
|
|
17
|
+
* @returns Transport configuration (stdio or streamable-http)
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```bash
|
|
21
|
+
* # Stdio mode (default)
|
|
22
|
+
* touchdesigner-mcp-server --host=http://localhost --port=9981
|
|
23
|
+
*
|
|
24
|
+
* # HTTP mode
|
|
25
|
+
* touchdesigner-mcp-server --mcp-http-port=6280 --mcp-http-host=127.0.0.1
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function parseTransportConfig(args?: string[]): TransportConfig;
|
|
29
|
+
/**
|
|
30
|
+
* Start TouchDesigner MCP server
|
|
31
|
+
*
|
|
32
|
+
* Supports both stdio and HTTP transport modes based on command line arguments.
|
|
33
|
+
*
|
|
34
|
+
* @param params - Server startup parameters
|
|
35
|
+
* @param params.argv - Command line arguments
|
|
36
|
+
* @param params.nodeEnv - Node environment
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```bash
|
|
40
|
+
* # Stdio mode (default)
|
|
41
|
+
* touchdesigner-mcp-server --host=http://localhost --port=9981
|
|
42
|
+
*
|
|
43
|
+
* # HTTP mode
|
|
44
|
+
* touchdesigner-mcp-server --mcp-http-port=6280 --host=http://localhost --port=9981
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function startServer(params?: {
|
|
48
|
+
nodeEnv?: string;
|
|
49
|
+
argv?: string[];
|
|
50
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
export declare const COMPATIBILITY_POLICY_TYPES: {
|
|
2
|
+
readonly BELOW_MIN_VERSION: "belowMinVersion";
|
|
3
|
+
readonly COMPATIBLE: "compatible";
|
|
4
|
+
readonly MAJOR_MISMATCH: "majorMismatch";
|
|
5
|
+
readonly NEWER_MINOR: "newerMinor";
|
|
6
|
+
readonly NO_VERSION: "noVersion";
|
|
7
|
+
readonly OLDER_MINOR: "olderMinor";
|
|
8
|
+
readonly PATCH_DIFF: "patchDiff";
|
|
9
|
+
};
|
|
10
|
+
export declare const COMPATIBILITY_POLICY_ERROR_LEVELS: {
|
|
11
|
+
readonly ALLOW: "info";
|
|
12
|
+
readonly ERROR: "error";
|
|
13
|
+
readonly WARNING: "warning";
|
|
14
|
+
};
|
|
15
|
+
export type CompatibilityPolicyType = (typeof COMPATIBILITY_POLICY_TYPES)[keyof typeof COMPATIBILITY_POLICY_TYPES];
|
|
16
|
+
export type CompatibilityPolicyErrorLevel = (typeof COMPATIBILITY_POLICY_ERROR_LEVELS)[keyof typeof COMPATIBILITY_POLICY_ERROR_LEVELS];
|
|
17
|
+
export declare const getCompatibilityPolicyType: (params: {
|
|
18
|
+
mcpVersion: string;
|
|
19
|
+
apiVersion: string;
|
|
20
|
+
}) => CompatibilityPolicyType;
|
|
21
|
+
export declare const getCompatibilityPolicy: (type: CompatibilityPolicyType) => {
|
|
22
|
+
readonly compatible: false;
|
|
23
|
+
readonly level: "error";
|
|
24
|
+
readonly message: typeof generateNoVersionMessage;
|
|
25
|
+
} | {
|
|
26
|
+
readonly compatible: false;
|
|
27
|
+
readonly level: "error";
|
|
28
|
+
readonly message: typeof generateMinVersionMessage;
|
|
29
|
+
} | {
|
|
30
|
+
readonly compatible: false;
|
|
31
|
+
readonly level: "error";
|
|
32
|
+
readonly message: typeof generateMajorMismatchMessage;
|
|
33
|
+
} | {
|
|
34
|
+
readonly compatible: true;
|
|
35
|
+
readonly level: "warning";
|
|
36
|
+
readonly message: typeof generateNewerMinorMessage;
|
|
37
|
+
} | {
|
|
38
|
+
readonly compatible: true;
|
|
39
|
+
readonly level: "warning";
|
|
40
|
+
readonly message: typeof generateOlderMinorMessage;
|
|
41
|
+
} | {
|
|
42
|
+
readonly compatible: true;
|
|
43
|
+
readonly level: "info";
|
|
44
|
+
readonly message: typeof generatePatchDiffMessage;
|
|
45
|
+
} | {
|
|
46
|
+
readonly compatible: true;
|
|
47
|
+
readonly level: "info";
|
|
48
|
+
readonly message: typeof generateFullyCompatibleMessage;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Generate error message for unknown version information
|
|
52
|
+
*/
|
|
53
|
+
export declare function generateNoVersionMessage(args: {
|
|
54
|
+
apiVersion: string;
|
|
55
|
+
mcpVersion: string;
|
|
56
|
+
}): string;
|
|
57
|
+
/**
|
|
58
|
+
* Generate error message for MAJOR version mismatch
|
|
59
|
+
*/
|
|
60
|
+
export declare function generateMajorMismatchMessage(args: {
|
|
61
|
+
apiVersion: string;
|
|
62
|
+
mcpVersion: string;
|
|
63
|
+
}): string;
|
|
64
|
+
/**
|
|
65
|
+
* Generate error message when API version is below minimum compatible version
|
|
66
|
+
*/
|
|
67
|
+
export declare function generateMinVersionMessage(args: {
|
|
68
|
+
apiVersion: string;
|
|
69
|
+
minRequired: string;
|
|
70
|
+
}): string;
|
|
71
|
+
/**
|
|
72
|
+
* Generate warning message when MCP server has newer MINOR version
|
|
73
|
+
*/
|
|
74
|
+
export declare function generateNewerMinorMessage(args: {
|
|
75
|
+
apiVersion: string;
|
|
76
|
+
mcpVersion: string;
|
|
77
|
+
}): string;
|
|
78
|
+
/**
|
|
79
|
+
* Generate warning message when API server has newer MINOR version
|
|
80
|
+
*/
|
|
81
|
+
export declare function generateOlderMinorMessage(args: {
|
|
82
|
+
apiVersion: string;
|
|
83
|
+
mcpVersion: string;
|
|
84
|
+
}): string;
|
|
85
|
+
/**
|
|
86
|
+
* Generate warning message when PATCH versions differ
|
|
87
|
+
*/
|
|
88
|
+
export declare function generatePatchDiffMessage(args: {
|
|
89
|
+
apiVersion: string;
|
|
90
|
+
mcpVersion: string;
|
|
91
|
+
}): string;
|
|
92
|
+
/**
|
|
93
|
+
* Generate info message when versions are fully compatible
|
|
94
|
+
*
|
|
95
|
+
* @param mcpVersion MCP server version
|
|
96
|
+
* @param apiVersion TouchDesigner API server version
|
|
97
|
+
* @returns Info message
|
|
98
|
+
*/
|
|
99
|
+
export declare function generateFullyCompatibleMessage(args: {
|
|
100
|
+
apiVersion: string;
|
|
101
|
+
mcpVersion: string;
|
|
102
|
+
}): string;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reference URLs for TouchDesigner Python documentation
|
|
3
|
+
*/
|
|
4
|
+
export declare const TD_PYTHON_CLASS_REFERENCE_BASE_URL = "https://docs.derivative.ca";
|
|
5
|
+
export declare const TD_PYTHON_CLASS_REFERENCE_INDEX_URL = "https://docs.derivative.ca/Python_Classes_and_Modules";
|
|
6
|
+
/**
|
|
7
|
+
* Reference Tool Names for TouchDesigner MCP
|
|
8
|
+
*/
|
|
9
|
+
export declare const TOOL_NAMES: {
|
|
10
|
+
readonly CREATE_TD_NODE: "create_td_node";
|
|
11
|
+
readonly DELETE_TD_NODE: "delete_td_node";
|
|
12
|
+
readonly DESCRIBE_TD_TOOLS: "describe_td_tools";
|
|
13
|
+
readonly EXECUTE_NODE_METHOD: "exec_node_method";
|
|
14
|
+
readonly EXECUTE_PYTHON_SCRIPT: "execute_python_script";
|
|
15
|
+
readonly GET_TD_CLASS_DETAILS: "get_td_class_details";
|
|
16
|
+
readonly GET_TD_CLASSES: "get_td_classes";
|
|
17
|
+
readonly GET_TD_INFO: "get_td_info";
|
|
18
|
+
readonly GET_TD_MODULE_HELP: "get_td_module_help";
|
|
19
|
+
readonly GET_TD_NODE_ERRORS: "get_td_node_errors";
|
|
20
|
+
readonly GET_TD_NODE_PARAMETERS: "get_td_node_parameters";
|
|
21
|
+
readonly GET_TD_NODES: "get_td_nodes";
|
|
22
|
+
readonly UPDATE_TD_NODE_PARAMETERS: "update_td_node_parameters";
|
|
23
|
+
};
|
|
24
|
+
export declare const REFERENCE_COMMENT = "Check reference resources: https://docs.derivative.ca/Python_Classes_and_Modules";
|
|
25
|
+
export declare const PROMPT_NAMES: {
|
|
26
|
+
readonly CHECK_NODE_ERRORS: "Check node errors";
|
|
27
|
+
readonly NODE_CONNECTION: "Node connection";
|
|
28
|
+
readonly SEARCH_NODE: "Search node";
|
|
29
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ToolNames } from "../features/tools/index.js";
|
|
2
|
+
import type { ILogger } from "./logger.js";
|
|
3
|
+
/**
|
|
4
|
+
* Standard API error response structure compatible with MCP SDK
|
|
5
|
+
*/
|
|
6
|
+
interface ErrorResponse {
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
isError: true;
|
|
9
|
+
content: Array<{
|
|
10
|
+
type: "text";
|
|
11
|
+
text: string;
|
|
12
|
+
}>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Handles API errors consistently across the application
|
|
16
|
+
*/
|
|
17
|
+
export declare function handleToolError(error: unknown, logger: ILogger, toolName: ToolNames, referenceComment?: string): ErrorResponse;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import type { LoggingMessageNotification } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Logger interface definition
|
|
5
|
+
*/
|
|
6
|
+
export interface ILogger {
|
|
7
|
+
sendLog(args: LoggingMessageNotification["params"]): void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* MCP compatible logger implementation
|
|
11
|
+
* Handles "Not connected" errors gracefully
|
|
12
|
+
*/
|
|
13
|
+
export declare class McpLogger implements ILogger {
|
|
14
|
+
private server;
|
|
15
|
+
constructor(server: McpServer);
|
|
16
|
+
sendLog(args: LoggingMessageNotification["params"]): void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Console Logger implementation for standalone use (e.g., HTTP mode setup)
|
|
20
|
+
* Outputs to stderr to avoid interfering with stdio transport
|
|
21
|
+
*/
|
|
22
|
+
export declare class ConsoleLogger implements ILogger {
|
|
23
|
+
sendLog(args: LoggingMessageNotification["params"]): void;
|
|
24
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result type pattern for handling operation results
|
|
3
|
+
* Success case contains data, failure case contains error
|
|
4
|
+
*/
|
|
5
|
+
export type Result<T, E = Error> = {
|
|
6
|
+
success: true;
|
|
7
|
+
data: T;
|
|
8
|
+
} | {
|
|
9
|
+
success: false;
|
|
10
|
+
error: E;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Creates a success result with the provided data
|
|
14
|
+
*/
|
|
15
|
+
export declare function createSuccessResult<T>(data: T): {
|
|
16
|
+
success: true;
|
|
17
|
+
data: T;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Creates an error result with the provided error
|
|
21
|
+
*/
|
|
22
|
+
export declare function createErrorResult<E = Error>(error: E): {
|
|
23
|
+
success: false;
|
|
24
|
+
error: E;
|
|
25
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Current MCP server version
|
|
3
|
+
*/
|
|
4
|
+
export declare const getMcpServerVersion: () => string;
|
|
5
|
+
export declare const MCP_SERVER_VERSION: string;
|
|
6
|
+
/**
|
|
7
|
+
* Minimum compatible TouchDesigner API Server version required by the MCP server
|
|
8
|
+
*
|
|
9
|
+
* Loaded from package.json's mcpCompatibility.minApiVersion field.
|
|
10
|
+
* Falls back to the current package version if undefined.
|
|
11
|
+
*
|
|
12
|
+
* API Server must be at or above this version.
|
|
13
|
+
* - MAJOR mismatch: Error
|
|
14
|
+
* - MINOR/PATCH differences: Warning or allow
|
|
15
|
+
*
|
|
16
|
+
* Update when:
|
|
17
|
+
* - Introducing breaking API changes
|
|
18
|
+
* - Making incompatible changes to OpenAPI schema
|
|
19
|
+
*/
|
|
20
|
+
export declare const getMinCompatibleApiVersion: () => string;
|
|
21
|
+
export declare const MIN_COMPATIBLE_API_VERSION: string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import type { ILogger } from "../../../core/logger.js";
|
|
3
|
+
/**
|
|
4
|
+
* Register prompt handlers with MCP server
|
|
5
|
+
*/
|
|
6
|
+
export declare function registerTdPrompts(server: McpServer, logger: ILogger): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./register.js";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import type { ILogger } from "../../../core/logger.js";
|
|
3
|
+
import type { TouchDesignerClient } from "../../../tdClient/touchDesignerClient.js";
|
|
4
|
+
export declare function registerTdTools(server: McpServer, logger: ILogger, tdClient: TouchDesignerClient): void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import type { ToolNames } from "../index.js";
|
|
3
|
+
import { type ToolCategory, type ToolDefinition } from "../toolDefinitions.js";
|
|
4
|
+
export type { ToolCategory };
|
|
5
|
+
export interface ToolParameterMetadata {
|
|
6
|
+
name: string;
|
|
7
|
+
type: string;
|
|
8
|
+
required: boolean;
|
|
9
|
+
description?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ToolMetadata {
|
|
12
|
+
tool: ToolNames;
|
|
13
|
+
modulePath: string;
|
|
14
|
+
functionName: string;
|
|
15
|
+
description: string;
|
|
16
|
+
category: ToolCategory;
|
|
17
|
+
parameters: ToolParameterMetadata[];
|
|
18
|
+
returns: string;
|
|
19
|
+
example: string;
|
|
20
|
+
notes?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Builds the `describe_td_tools` manifest from the tool table. Parameter
|
|
24
|
+
* metadata is introspected from each tool's Zod schema, so it always reflects
|
|
25
|
+
* the schema that is actually registered (sourced from the OpenAPI spec).
|
|
26
|
+
*/
|
|
27
|
+
export declare function buildToolMetadata(definitions?: readonly ToolDefinition[]): ToolMetadata[];
|
|
28
|
+
/** Introspects a Zod object schema into flat parameter metadata. */
|
|
29
|
+
export declare function deriveParameters(schema: z.ZodObject<z.ZodRawShape>): ToolParameterMetadata[];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class List Formatter
|
|
3
|
+
*
|
|
4
|
+
* Formats TouchDesigner Python class/module lists with token optimization.
|
|
5
|
+
* Used by GET_TD_CLASSES and GET_TD_CLASS_DETAILS tools.
|
|
6
|
+
*/
|
|
7
|
+
import type { TdPythonClassDetails, TdPythonClassInfo } from "../../../gen/endpoints/TouchDesignerAPI.js";
|
|
8
|
+
import type { FormatterOptions } from "./responseFormatter.js";
|
|
9
|
+
/**
|
|
10
|
+
* Class list data structure (matches API response)
|
|
11
|
+
*/
|
|
12
|
+
export interface ClassListData {
|
|
13
|
+
classes?: TdPythonClassInfo[];
|
|
14
|
+
modules?: string[];
|
|
15
|
+
totalCount?: number;
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Class details data structure (matches API response)
|
|
20
|
+
*/
|
|
21
|
+
export type ClassDetailsData = TdPythonClassDetails;
|
|
22
|
+
/**
|
|
23
|
+
* Format class/module list
|
|
24
|
+
*/
|
|
25
|
+
export declare function formatClassList(data: ClassListData | undefined, options?: FormatterOptions): string;
|
|
26
|
+
/**
|
|
27
|
+
* Format class details
|
|
28
|
+
*/
|
|
29
|
+
export declare function formatClassDetails(data: ClassDetailsData | undefined, options?: FormatterOptions): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Response Formatters Index
|
|
3
|
+
*
|
|
4
|
+
* Central export point for all response formatters
|
|
5
|
+
*/
|
|
6
|
+
export type { ClassDetailsData, ClassListData } from "./classListFormatter.js";
|
|
7
|
+
export { formatClassDetails, formatClassList } from "./classListFormatter.js";
|
|
8
|
+
export { formatModuleHelp } from "./moduleHelpFormatter.js";
|
|
9
|
+
export type { NodeDetailsData } from "./nodeDetailsFormatter.js";
|
|
10
|
+
export { formatNodeDetails } from "./nodeDetailsFormatter.js";
|
|
11
|
+
export type { NodeErrorReportData } from "./nodeErrorsFormatter.js";
|
|
12
|
+
export { formatNodeErrors } from "./nodeErrorsFormatter.js";
|
|
13
|
+
export type { NodeListData } from "./nodeListFormatter.js";
|
|
14
|
+
export { formatNodeList } from "./nodeListFormatter.js";
|
|
15
|
+
export { formatCreateNodeResult, formatDeleteNodeResult, formatExecNodeMethodResult, formatTdInfo, formatUpdateNodeResult, } from "./operationFormatter.js";
|
|
16
|
+
export type { ScriptResultData } from "./scriptResultFormatter.js";
|
|
17
|
+
export { formatScriptResult } from "./scriptResultFormatter.js";
|
|
18
|
+
export { formatToolMetadata } from "./toolMetadataFormatter.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Module Help Formatter
|
|
3
|
+
*
|
|
4
|
+
* Formats TouchDesigner module help information with token optimization.
|
|
5
|
+
* Used by GET_MODULE_HELP tool.
|
|
6
|
+
*/
|
|
7
|
+
import type { ModuleHelp } from "../../../gen/endpoints/TouchDesignerAPI.js";
|
|
8
|
+
import type { FormatterOptions } from "./responseFormatter.js";
|
|
9
|
+
/**
|
|
10
|
+
* Format module help result
|
|
11
|
+
*/
|
|
12
|
+
export declare function formatModuleHelp(data: ModuleHelp | undefined, options?: FormatterOptions): string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node Details Formatter
|
|
3
|
+
*
|
|
4
|
+
* Formats TouchDesigner node parameter details with token optimization.
|
|
5
|
+
* Used by GET_TD_NODE_PARAMETERS tool.
|
|
6
|
+
*/
|
|
7
|
+
import type { TdNode } from "../../../gen/endpoints/TouchDesignerAPI.js";
|
|
8
|
+
import type { FormatterOptions } from "./responseFormatter.js";
|
|
9
|
+
/**
|
|
10
|
+
* Node details data structure (matches API response)
|
|
11
|
+
*/
|
|
12
|
+
export type NodeDetailsData = TdNode;
|
|
13
|
+
/**
|
|
14
|
+
* Format node parameter details
|
|
15
|
+
*/
|
|
16
|
+
export declare function formatNodeDetails(data: NodeDetailsData | undefined, options?: FormatterOptions): string;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { TdNodeErrorReport } from "../../../gen/endpoints/TouchDesignerAPI.js";
|
|
2
|
+
import type { FormatterOptions } from "./responseFormatter.js";
|
|
3
|
+
export type NodeErrorReportData = TdNodeErrorReport;
|
|
4
|
+
export declare function formatNodeErrors(data: NodeErrorReportData | undefined, options?: FormatterOptions): string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node List Formatter
|
|
3
|
+
*
|
|
4
|
+
* Formats TouchDesigner node lists with token-optimized output.
|
|
5
|
+
* Used by GET_TD_NODES tool.
|
|
6
|
+
*/
|
|
7
|
+
import type { TdNode } from "../../../gen/endpoints/TouchDesignerAPI.js";
|
|
8
|
+
import type { FormatterOptions } from "./responseFormatter.js";
|
|
9
|
+
/**
|
|
10
|
+
* Node list data structure (matches API response)
|
|
11
|
+
*/
|
|
12
|
+
export interface NodeListData {
|
|
13
|
+
nodes?: TdNode[];
|
|
14
|
+
parentPath?: string;
|
|
15
|
+
pattern?: string;
|
|
16
|
+
includeProperties?: boolean;
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Format node list based on detail level
|
|
21
|
+
*/
|
|
22
|
+
export declare function formatNodeList(data: NodeListData | undefined, options?: FormatterOptions): string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CreateNode200Data, DeleteNode200Data, ExecNodeMethod200Data, GetTdInfo200Data, UpdateNode200Data } from "../../../gen/endpoints/TouchDesignerAPI.js";
|
|
2
|
+
import type { FormatterOptions } from "./responseFormatter.js";
|
|
3
|
+
type FormatterOpts = Pick<FormatterOptions, "detailLevel" | "responseFormat">;
|
|
4
|
+
export declare function formatTdInfo(data: GetTdInfo200Data, options?: FormatterOpts): string;
|
|
5
|
+
export declare function formatCreateNodeResult(data: CreateNode200Data, options?: FormatterOpts): string;
|
|
6
|
+
export declare function formatUpdateNodeResult(data: UpdateNode200Data, options?: FormatterOpts): string;
|
|
7
|
+
export declare function formatDeleteNodeResult(data: DeleteNode200Data, options?: FormatterOpts): string;
|
|
8
|
+
export declare function formatExecNodeMethodResult(data: ExecNodeMethod200Data | {
|
|
9
|
+
result?: unknown;
|
|
10
|
+
} | null | undefined, context: {
|
|
11
|
+
nodePath: string;
|
|
12
|
+
method: string;
|
|
13
|
+
args?: unknown[];
|
|
14
|
+
kwargs?: Record<string, unknown>;
|
|
15
|
+
}, options?: FormatterOpts): string;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type PresenterFormat = "json" | "yaml" | "markdown";
|
|
2
|
+
export declare const DEFAULT_PRESENTER_FORMAT: PresenterFormat;
|
|
3
|
+
export interface PresenterPayload {
|
|
4
|
+
text: string;
|
|
5
|
+
detailLevel?: string;
|
|
6
|
+
structured?: unknown;
|
|
7
|
+
context?: Record<string, unknown>;
|
|
8
|
+
template?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function presentStructuredData(payload: PresenterPayload, format?: PresenterFormat): string;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Response Formatter Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides token-optimized formatting for MCP tool responses.
|
|
5
|
+
* Based on the design document: docs/context-optimization-design.md
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Detail level for response formatting
|
|
9
|
+
* - minimal: Only essential information (lowest tokens)
|
|
10
|
+
* - summary: Key information with counts and hints (balanced)
|
|
11
|
+
* - detailed: Full information (original behavior)
|
|
12
|
+
*/
|
|
13
|
+
export type DetailLevel = "minimal" | "summary" | "detailed";
|
|
14
|
+
/**
|
|
15
|
+
* Common formatting options
|
|
16
|
+
*/
|
|
17
|
+
import { type PresenterFormat } from "./presenter.js";
|
|
18
|
+
export interface FormatterOptions {
|
|
19
|
+
/**
|
|
20
|
+
* Backwards-compatible alias for detailLevel
|
|
21
|
+
* @deprecated Use detailLevel instead
|
|
22
|
+
*/
|
|
23
|
+
mode?: DetailLevel;
|
|
24
|
+
/**
|
|
25
|
+
* Level of detail in the response
|
|
26
|
+
* @default "summary"
|
|
27
|
+
*/
|
|
28
|
+
detailLevel?: DetailLevel;
|
|
29
|
+
/**
|
|
30
|
+
* Maximum number of items to include in lists
|
|
31
|
+
* @default undefined (no limit)
|
|
32
|
+
*/
|
|
33
|
+
limit?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Include hints about omitted content
|
|
36
|
+
* @default true
|
|
37
|
+
*/
|
|
38
|
+
includeHints?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Structured output format for detailed mode
|
|
41
|
+
* @default "yaml"
|
|
42
|
+
*/
|
|
43
|
+
responseFormat?: PresenterFormat;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Default formatter options
|
|
47
|
+
*/
|
|
48
|
+
export declare const DEFAULT_FORMATTER_OPTIONS: {
|
|
49
|
+
detailLevel: "summary";
|
|
50
|
+
includeHints: true;
|
|
51
|
+
limit: number | undefined;
|
|
52
|
+
responseFormat: PresenterFormat | undefined;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Merge user options with defaults
|
|
56
|
+
*/
|
|
57
|
+
export declare function mergeFormatterOptions(options?: FormatterOptions): {
|
|
58
|
+
detailLevel: DetailLevel;
|
|
59
|
+
limit: number | undefined;
|
|
60
|
+
includeHints: boolean;
|
|
61
|
+
responseFormat?: PresenterFormat;
|
|
62
|
+
};
|
|
63
|
+
interface FormatterMetadata {
|
|
64
|
+
template?: string;
|
|
65
|
+
context?: Record<string, unknown>;
|
|
66
|
+
structured?: unknown;
|
|
67
|
+
}
|
|
68
|
+
export declare function finalizeFormattedText(text: string, opts: {
|
|
69
|
+
responseFormat?: PresenterFormat;
|
|
70
|
+
detailLevel: DetailLevel;
|
|
71
|
+
}, metadata?: FormatterMetadata): string;
|
|
72
|
+
/**
|
|
73
|
+
* Format a hint message for omitted content
|
|
74
|
+
*/
|
|
75
|
+
export declare function formatOmissionHint(totalCount: number, shownCount: number, itemType: string): string;
|
|
76
|
+
/**
|
|
77
|
+
* Truncate array based on limit option
|
|
78
|
+
*/
|
|
79
|
+
export declare function limitArray<T>(items: T[], limit: number | undefined): {
|
|
80
|
+
items: T[];
|
|
81
|
+
truncated: boolean;
|
|
82
|
+
};
|
|
83
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Script Result Formatter
|
|
3
|
+
*
|
|
4
|
+
* Formats Python script execution results with token optimization.
|
|
5
|
+
* Used by EXECUTE_PYTHON_SCRIPT tool.
|
|
6
|
+
*/
|
|
7
|
+
import type { FormatterOptions } from "./responseFormatter.js";
|
|
8
|
+
/**
|
|
9
|
+
* Script execution result structure
|
|
10
|
+
*/
|
|
11
|
+
export interface ScriptResultData {
|
|
12
|
+
success?: boolean;
|
|
13
|
+
data?: {
|
|
14
|
+
result?: unknown;
|
|
15
|
+
output?: string;
|
|
16
|
+
error?: string;
|
|
17
|
+
};
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Format script execution result
|
|
22
|
+
*/
|
|
23
|
+
export declare function formatScriptResult(data: ScriptResultData | undefined, scriptSnippet?: string, options?: FormatterOptions): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ToolMetadata } from "../metadata/touchDesignerToolMetadata.js";
|
|
2
|
+
import { type FormatterOptions } from "./responseFormatter.js";
|
|
3
|
+
interface ToolMetadataFormatterOptions extends Partial<FormatterOptions> {
|
|
4
|
+
filter?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function formatToolMetadata(entries: ToolMetadata[], options?: ToolMetadataFormatterOptions): string;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import type { ILogger } from "../../core/logger.js";
|
|
3
|
+
import type { TouchDesignerClient } from "../../tdClient/index.js";
|
|
4
|
+
/**
|
|
5
|
+
* Register resource handlers with MCP server
|
|
6
|
+
*/
|
|
7
|
+
export declare function registerTools(server: McpServer, logger: ILogger, tdClient: TouchDesignerClient): void;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import type { ILogger } from "../../core/logger.js";
|
|
3
|
+
import type { TouchDesignerClient } from "../../tdClient/touchDesignerClient.js";
|
|
4
|
+
import type { ToolNames } from "./index.js";
|
|
5
|
+
export type ToolCategory = "system" | "python" | "nodes" | "classes" | "state";
|
|
6
|
+
/**
|
|
7
|
+
* Single source of truth for a TouchDesigner MCP tool.
|
|
8
|
+
*
|
|
9
|
+
* Both the MCP registration loop (`registerTdTools`) and the
|
|
10
|
+
* `describe_td_tools` manifest (`buildToolMetadata`) are derived from this
|
|
11
|
+
* table, so a tool's description and input parameters can never drift between
|
|
12
|
+
* what is registered and what is documented. Parameter metadata is introspected
|
|
13
|
+
* directly from `schema`, which itself originates from the OpenAPI spec.
|
|
14
|
+
*/
|
|
15
|
+
export interface ToolDefinition {
|
|
16
|
+
/** Registered MCP tool name (also the source for functionName/modulePath). */
|
|
17
|
+
name: ToolNames;
|
|
18
|
+
/** Agent-facing description, used for both registration and the manifest. */
|
|
19
|
+
description: string;
|
|
20
|
+
category: ToolCategory;
|
|
21
|
+
/** Composed Zod schema: OpenAPI-derived params extended with formatting flags. */
|
|
22
|
+
schema: z.ZodObject<z.ZodRawShape>;
|
|
23
|
+
/** Human summary of the return payload (manifest only). */
|
|
24
|
+
returns: string;
|
|
25
|
+
/** Usage example shown in the detailed manifest view (manifest only). */
|
|
26
|
+
example: string;
|
|
27
|
+
notes?: string;
|
|
28
|
+
/** Optional reference comment appended to error output. */
|
|
29
|
+
errorComment?: string;
|
|
30
|
+
/** Executes the tool and returns formatter-ready text. */
|
|
31
|
+
run: (ctx: ToolRunContext) => Promise<string>;
|
|
32
|
+
}
|
|
33
|
+
export interface ToolRunContext {
|
|
34
|
+
params: Record<string, unknown>;
|
|
35
|
+
tdClient: TouchDesignerClient;
|
|
36
|
+
logger: ILogger;
|
|
37
|
+
}
|
|
38
|
+
export declare const TOOL_DEFINITIONS: ToolDefinition[];
|