ruvnet/ruflo · error · Error

HTTP transport requires host and port configuration

Error message

HTTP transport requires host and port configuration

What it means

createTransport('http', logger, config) requires the config object to contain host and port keys; the factory checks key presence ('host' in config / 'port' in config) before delegating to createHttpTransport and throws this error when either is missing. It is a fail-fast guard so the HTTP listener never binds with an undefined address. Note it checks presence, not truthiness — { host: '', port: 0 } passes.

Source

Thrown at v3/@claude-flow/mcp/src/transport/index.ts:42

export type TransportConfig =
  | { type: 'stdio' } & StdioTransportConfig
  | { type: 'http' } & HttpTransportConfig
  | { type: 'websocket' } & WebSocketTransportConfig
  | { type: 'in-process' };

export function createTransport(
  type: TransportType,
  logger: ILogger,
  config?: Partial<TransportConfig>
): ITransport {
  switch (type) {
    case 'stdio':
      return createStdioTransport(logger, config as StdioTransportConfig);

    case 'http':
      if (!config || !('host' in config) || !('port' in config)) {
        throw new Error('HTTP transport requires host and port configuration');
      }
      return createHttpTransport(logger, {
        host: config.host as string,
        port: config.port as number,
        ...config,
      } as HttpTransportConfig);

    case 'websocket':
      if (!config || !('host' in config) || !('port' in config)) {
        throw new Error('WebSocket transport requires host and port configuration');
      }
      return createWebSocketTransport(logger, {
        host: config.host as string,
        port: config.port as number,
        ...config,
      } as WebSocketTransportConfig);

    case 'in-process':

View on GitHub (pinned to fa13ee4ad6)

Solutions

  1. Pass explicit values: createTransport('http', logger, { host: '127.0.0.1', port: 3000 })
  2. Default env-derived values: host: process.env.HOST ?? '127.0.0.1', port: Number(process.env.PORT ?? 3000)
  3. Call createHttpTransport(logger, cfg) directly so TypeScript enforces HttpTransportConfig

Example fix

// before
const t = createTransport('http', logger, { host: process.env.HOST } as any);

// after
const t = createTransport('http', logger, {
  host: process.env.HOST ?? '127.0.0.1',
  port: Number(process.env.PORT ?? 3000),
});
Defensive patterns

Strategy: validation

Validate before calling

const httpCfg = {
  host: process.env.HOST ?? '127.0.0.1',
  port: Number(process.env.PORT ?? 3000),
};
if (!('host' in httpCfg) || !('port' in httpCfg)) {
  throw new Error('HTTP transport config incomplete');
}
const t = createTransport('http', logger, httpCfg);

Type guard

function isHttpConfig(c: unknown): c is { host: string; port: number } {
  return (
    !!c && typeof c === 'object' &&
    'host' in c && typeof (c as { host: unknown }).host === 'string' &&
    'port' in c && typeof (c as { port: unknown }).port === 'number'
  );
}

Prevention

When it happens

Trigger: Calling createTransport('http', logger) with no config; passing a config built from env vars where HOST/PORT are unset so the keys are absent; passing a StdioTransportConfig-shaped object or a Partial<TransportConfig> that lacks host/port into the http branch.

Common situations: Config loaded from .env that is missing in CI; one shared config object reused across transport types; code upgraded from a version where http transport defaulted host/port.

Related errors


AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18). Data as JSON: /api/errors/21d6501d5cdc06c8. Report an issue: GitHub.