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 MCP Server Composition

From Leeroopedia
Knowledge Sources
Domains MCP_Server, Dependency_Injection
Last Updated 2026-10-28 00:00 GMT

Overview

A server composition pattern where a single class assembles the SDK McpServer with all TouchDesigner features (tools, prompts), a logger, an HTTP client, and a connection manager via constructor injection, exposing a factory that returns the ready-to-connect McpServer.

Description

An MCP server needs to register a coherent set of tools, prompts, and a backend client, then hand the assembled McpServer to a transport. The MCP server composition pattern encapsulates this in one class: the constructor instantiates McpServer with name/version/capabilities, creates a ConsoleLogger and TouchDesignerClient (both injectable), wires a ConnectionManager, then calls registerAllFeatures to register prompts and tools against the server. The static create factory returns the inner McpServer so transports can connect to it without knowing about the composition class. This separation means the transport layer deals only with McpServer instances, while the composition class owns the wiring.

Usage

Use this principle when you need multiple server instances (one per stdio connection or per HTTP request) with identical feature registration but optionally different injected clients.

Theoretical Basis

// Abstract algorithm (NOT real implementation)
class ServerComposition {
  constructor(params?: { client?: Client }) {
    this.server = new McpServer({ name, version }, { capabilities });
    this.logger = new Logger();
    this.client = params?.client ?? createClient({ logger });
    this.connection = new ConnectionManager(this.server, this.logger);
    this.registerFeatures();   // prompts + tools
  }
  static create(params?) { return new ServerComposition(params).server; }
}

Key properties:

  • Factory method: create returns the McpServer, hiding the composition.
  • Dependency injection: logger and client are injectable for testing.
  • Feature registration at construction: the server is fully wired before return.

Related Pages

Page Connections

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