Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:8beeeaaat Touchdesigner mcp Transport Selection

From Leeroopedia
Knowledge Sources
Domains CLI, Transport
Last Updated 2026-10-28 00:00 GMT

Overview

A CLI-driven selection between stdio and Streamable HTTP MCP transports, where the presence of a single flag (`--mcp-http-port`) switches the server's entire transport stack while shared connection arguments remain independent.

Description

An MCP server must support multiple transports (stdio for local agents, HTTP for remote/web clients) from a single entry point. The transport selection principle parses CLI arguments into a discriminated TransportConfig union: if `--mcp-http-port` is present, the config is `streamable-http` (with host and endpoint); otherwise it defaults to `stdio`. TouchDesigner connection arguments (`--host`, `--port`) are parsed independently and set as environment variables, so both transports share the same downstream client wiring. Strict validation (decimal-digit ports in 1-65535, preserved flag values, warnings for unrecognized flags) ensures fail-fast before any server starts.

Usage

Use this principle when a single CLI binary must serve both local (stdio) and networked (HTTP) MCP consumers, and the transport choice is a runtime flag rather than a build-time variant.

Theoretical Basis

// Abstract algorithm (NOT real implementation)
function selectTransport(argv: string[]): TransportConfig {
  if (argv.includes("--mcp-http-port=..."))
    return { type: "streamable-http", host, port, endpoint };
  return { type: "stdio" };
}

// Exhaustive dispatch — TypeScript never type enforces all cases.
function startServer(config: TransportConfig) {
  switch (config.type) {
    case "stdio": serveStdio(factory); break;
    case "streamable-http": startHttp(config); break;
    default: assertNever(config); // compile-time exhaustiveness
  }
}

Key properties:

  • Discriminated union: the `type` field enables exhaustive switch dispatch.
  • Independent axes: transport config and TD connection config are parsed separately.
  • Fail-fast validation: invalid ports exit before the server starts.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment