{"record":{"id":"0eac5fd958f8fe7b","repo":"ruvnet/ruflo","slug":"websocket-transport-requires-host-and-port-configu-0eac5f","errorCode":null,"errorMessage":"WebSocket transport requires host and port configuration","messagePattern":"WebSocket transport requires host and port configuration","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/shared/src/mcp/transport/index.ts","lineNumber":70,"sourceCode":"  config?: Partial<TransportConfig>\n): ITransport {\n  switch (type) {\n    case 'stdio':\n      return createStdioTransport(logger, config as StdioTransportConfig);\n\n    case 'http':\n      if (!config || !('host' in config) || !('port' in config)) {\n        throw new Error('HTTP transport requires host and port configuration');\n      }\n      return createHttpTransport(logger, {\n        host: config.host as string,\n        port: config.port as number,\n        ...config,\n      } as HttpTransportConfig);\n\n    case 'websocket':\n      if (!config || !('host' in config) || !('port' in config)) {\n        throw new Error('WebSocket transport requires host and port configuration');\n      }\n      return createWebSocketTransport(logger, {\n        host: config.host as string,\n        port: config.port as number,\n        ...config,\n      } as WebSocketTransportConfig);\n\n    case 'in-process':\n      // In-process transport is handled directly by the server\n      // Return a no-op transport wrapper\n      return createInProcessTransport(logger);\n\n    default:\n      throw new Error(`Unknown transport type: ${type}`);\n  }\n}\n\n/**","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/shared/src/mcp/transport/index.ts#L52-L88","documentation":"createTransport('websocket', logger, config) requires a config object containing host and port keys - the same key-presence check as the http case. The WebSocket transport later binds host, port and an optional path (default '/ws'), so without a host/port pair there is nothing sensible to construct. Missing config or a config without both keys throws from the factory before any socket is created.","triggerScenarios":"createTransport('websocket', logger) with no config; a config object typed Partial<TransportConfig> that only carries stdio-ish fields; conditional spread building config that omits host/port when a flag is off; env vars for host/port unset so keys are never written.","commonSituations":"Migrating a stdio-based CLI to a websocket listener without adding network config; YAML/JSON config written for http then reused for websocket minus one field; default-path assumption ('path only') while host/port were never supplied.","solutions":["Pass explicit config: createTransport('websocket', logger, { host: '0.0.0.0', port: 8081, path: '/ws' })","Type the config as WebSocketTransportConfig at the call site so TypeScript enforces host/port","Validate config once at startup (presence AND value checks) and fail fast naming the missing field"],"exampleFix":"// before\nconst t = createTransport('websocket', logger, { path: '/ws' }); // no host/port\n\n// after\nconst t = createTransport('websocket', logger, {\n  host: process.env.MCP_WS_HOST ?? '127.0.0.1',\n  port: Number(process.env.MCP_WS_PORT ?? 8081),\n  path: '/ws',\n});","handlingStrategy":"type-guard","validationCode":"if (!hasHostPort(config)) {\n  throw new Error('WebSocket transport config must provide host and port (path defaults to /ws)');\n}\nreturn createTransport('websocket', logger, config);","typeGuard":"function hasHostPort(c?: Partial<TransportConfig>): c is { host: string; port: number } {\n  return !!c\n    && typeof (c as { host?: unknown }).host === 'string'\n    && (c as { host?: unknown }).host.length > 0\n    && typeof (c as { port?: unknown }).port === 'number';\n}","tryCatchPattern":"try {\n  return createTransport('websocket', logger, cfg);\n} catch (e) {\n  if (e instanceof Error && /host and port/.test(e.message)) {\n    throw new ConfigError('WebSocket host/port missing in config');\n  }\n  throw e;\n}","preventionTips":["Use WebSocketTransportConfig at the type level so host/port are compile-required","Validate config once at startup and report the exact missing field","Remember path is optional (default '/ws') but host and port are not"],"tags":["mcp","transport","websocket","configuration","factory","validation"],"backgroundTag":"missing-host-port-config","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}