UNPKG

touchdesigner-mcp-server

Version:
55 lines (54 loc) 1.41 kB
import { z } from "zod"; /** * Zod schema for StdioTransportConfig validation */ const StdioTransportConfigSchema = z .object({ type: z.literal("stdio"), }) .strict(); /** * Zod schema for StreamableHttpTransportConfig validation */ const StreamableHttpTransportConfigSchema = z .object({ endpoint: z .string() .min(1, "Endpoint cannot be empty") .regex(/^\//, "Endpoint must start with /"), host: z.string().min(1, "Host cannot be empty"), port: z .number() .int() .positive() .min(1) .max(65535, "Port must be between 1 and 65535"), type: z.literal("streamable-http"), }) .strict(); /** * Zod schema for TransportConfig validation (discriminated union) */ export const TransportConfigSchema = z.discriminatedUnion("type", [ StdioTransportConfigSchema, StreamableHttpTransportConfigSchema, ]); /** * Type guard to check if config is StdioTransportConfig */ export function isStdioTransportConfig(config) { return config.type === "stdio"; } /** * Type guard to check if config is StreamableHttpTransportConfig */ export function isStreamableHttpTransportConfig(config) { return config.type === "streamable-http"; } /** * Default values for StreamableHttpTransportConfig (excluding required fields) */ export const DEFAULT_HTTP_CONFIG = { endpoint: "/mcp", host: "127.0.0.1", };