{"record":{"id":"65249139652bcf38","repo":"ruvnet/ruflo","slug":"http-transport-requires-host-and-port-configuratio-652491","errorCode":null,"errorMessage":"HTTP transport requires host and port configuration","messagePattern":"HTTP 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":60,"sourceCode":"  | { type: 'http' } & HttpTransportConfig\n  | { type: 'websocket' } & WebSocketTransportConfig\n  | { type: 'in-process' };\n\n/**\n * Create a transport instance based on type\n */\nexport function createTransport(\n  type: TransportType,\n  logger: ILogger,\n  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':","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/shared/src/mcp/transport/index.ts#L42-L78","documentation":"createTransport('http', logger, config) requires a config object containing host and port keys. The factory does a key-presence check (!('host' in config) || !('port' in config)) before constructing the HTTP transport, because a network listener has no usable defaults (unlike stdio, which falls back to process.stdin/stdout). Missing config or a config lacking either key throws immediately. Note the guard checks key presence, not values: { host: undefined, port: undefined } passes here but fails later at bind time.","triggerScenarios":"createTransport('http', logger) with the third argument omitted; reusing a Partial<TransportConfig> built for stdio when switching type to 'http'; a helper that builds config via conditional spread that drops the keys; env-driven config where MCP_HOST/MCP_PORT are unset so keys never get assigned.","commonSituations":"Switching the default transport from stdio to http without adding config plumbing; config assembled from optional env vars; refactors that destructure/spread config through layers and lose fields; TypeScript silence because the arg is typed Partial<TransportConfig>.","solutions":["Pass an explicit literal config: createTransport('http', logger, { host: '127.0.0.1', port: 8080 })","Type the call site with HttpTransportConfig (not Partial<TransportConfig>) so missing keys become a compile error","Parse and validate env/config once at boot with named-variable error messages before any transport is created","Also validate values (non-empty host, numeric port in range), since presence alone is not enough"],"exampleFix":"// before\nconst cfg: Partial<TransportConfig> = loadOptionalConfig(); // may lack port\nconst t = createTransport('http', logger, cfg); // throws\n\n// after\nconst host = requireEnv('MCP_HOST');\nconst port = requirePort('MCP_PORT');\nconst t = createTransport('http', logger, { host, port });","handlingStrategy":"type-guard","validationCode":"if (!hasHostPort(config)) {\n  throw new Error('HTTP transport config must provide MCP_HOST and MCP_PORT');\n}\nreturn createTransport('http', 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('http', logger, cfg);\n} catch (e) {\n  if (e instanceof Error && /host and port/.test(e.message)) {\n    throw new ConfigError('MCP_HOST / MCP_PORT missing or unset');\n  }\n  throw e;\n}","preventionTips":["Type call sites as HttpTransportConfig, never Partial<TransportConfig>","Parse env into a typed config object once at boot and fail fast naming the missing vars","Check values, not just key presence - undefined values pass the factory guard but fail at listen()"],"tags":["mcp","transport","http","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"}