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

Implementation:8beeeaaat Touchdesigner mcp ExpressHttpManager

From Leeroopedia
Knowledge Sources
Domains HTTP_Transport, Server_Lifecycle
Last Updated 2026-10-28 00:00 GMT

Overview

Concrete tool for managing the lifecycle of the Streamable HTTP MCP transport: mounting a stateless per-request handler on the SDK Express app with DNS-rebinding protection and graceful shutdown.

Description

ExpressHttpManager owns the Node.js HttpServer for the Streamable HTTP transport. On start() it creates an MCP handler via createMcpHandler (stateless per-request serving, 2026-07-28 with 2025-era fallback), wraps it with toNodeHandler, and mounts it on the SDK's createMcpExpressApp (which provides DNS-rebinding protection for localhost). It exposes /mcp for MCP traffic and /health for liveness checks. On stop() it closes the MCP handler first (ending open subscription streams) then the HTTP server. There are no protocol-level sessions and no Mcp-Session-Id header (removed by spec revision 2026-07-28).

Usage

Instantiate with a StreamableHttpTransportConfig, a server factory, and a logger. Call start() to begin serving and stop() for graceful shutdown.

Code Reference

Source Location

Signature

export class ExpressHttpManager {
  constructor(
    config: StreamableHttpTransportConfig,
    serverFactory: () => McpServer,
    logger: ILogger,
  );

  async start(): Promise<Result<void, Error>>;
  async stop(): Promise<Result<void, Error>>;
  isRunning(): boolean;
}

Import

import { ExpressHttpManager } from "./transport/expressHttpManager.js";

I/O Contract

Inputs

Name Type Required Description
config StreamableHttpTransportConfig Yes host, port, endpoint
serverFactory () => McpServer Yes Creates a fresh server per request
logger ILogger Yes Stderr logger

Outputs

Name Type Description
start() Result<void, Error> Server listening on host:port
stop() Result<void, Error> Handler + HTTP server closed
isRunning() boolean Whether server is listening

Usage Examples

Start and graceful shutdown

import { ExpressHttpManager } from "./transport/expressHttpManager.js";
import { TouchDesignerServer } from "./server/touchDesignerServer.js";
import { ConsoleLogger } from "./core/logger.js";

const config = {
  type: "streamable-http" as const,
  host: "127.0.0.1",
  port: 6280,
  endpoint: "/mcp",
};

const manager = new ExpressHttpManager(
  config,
  () => TouchDesignerServer.create(),
  new ConsoleLogger(),
);

await manager.start();

// Graceful shutdown on SIGTERM
process.on("SIGTERM", async () => {
  await manager.stop();
  process.exit(0);
});

Related Pages

Page Connections

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