{"record":{"id":"8ca229c7f6639ed8","repo":"can1357/oh-my-pi","slug":"unknown-server-type-servertype","errorCode":null,"errorMessage":"Unknown server type: ${serverType}","messagePattern":"Unknown server type: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/mcp/client.ts","lineNumber":84,"sourceCode":"\t\t\tthrow Object.assign(new Error(`Unsupported server request: ${method}`), { code: -32601 });\n\t}\n}\n\n/**\n * Create a transport for the given server config.\n */\nasync function createTransport(config: MCPServerConfig): Promise<MCPTransport> {\n\tconst serverType = config.type ?? \"stdio\";\n\n\tswitch (serverType) {\n\t\tcase \"stdio\":\n\t\t\treturn createStdioTransport(config as MCPStdioServerConfig);\n\t\tcase \"http\":\n\t\t\treturn createHttpTransport(config as MCPHttpServerConfig);\n\t\tcase \"sse\":\n\t\t\treturn createSseTransport(config as MCPSseServerConfig);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown server type: ${serverType}`);\n\t}\n}\n\n/**\n * Initialize connection with MCP server.\n */\nasync function initializeConnection(\n\ttransport: MCPTransport,\n\toptions?: {\n\t\tsignal?: AbortSignal;\n\t\t/** Called after notifications/initialized succeeds. */\n\t\tonInitialized?: () => void | Promise<void>;\n\t},\n): Promise<MCPInitializeResult> {\n\tconst params: MCPInitializeParams = {\n\t\tprotocolVersion: MCP_PROTOCOL_VERSION,\n\t\tcapabilities: {\n\t\t\troots: { listChanged: false },","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/mcp/client.ts#L66-L102","documentation":"createTransport dispatches on the MCP server config's type field ('stdio' | 'http' | 'sse'); any other value reaches the default branch and throws 'Unknown server type: <type>'. It guards the transport factory against misconfigured or future-unknown server type strings.","triggerScenarios":"connect() → createTransport() with a config whose type is misspelled (e.g. 'websocket', 'http2', or with stray whitespace) or from a newer config schema the client doesn't recognize.","commonSituations":"Hand-edited MCP config with a wrong 'type' value; config copied from another tool using different transport names; config written by a newer client version introducing an unsupported type.","solutions":["Fix the server's 'type' in the MCP config to one of: stdio, http, or sse.","Check for typos/whitespace in the type string and validate the JSON config.","Update the CLI if the config was authored by a newer tool using a new transport type.","Use the /mcp add wizard, which writes valid types instead of hand-editing."],"exampleFix":"// before (MCP config JSON)\n{ \"myserver\": { \"type\": \"websocket\", \"url\": \"http://localhost:3000\" } }\n// after\n{ \"myserver\": { \"type\": \"http\", \"url\": \"http://localhost:3000\" } }","handlingStrategy":"validation","validationCode":"const TRANSPORT_TYPES = new Set([\"stdio\", \"http\", \"sse\"]);\nfunction assertValidTransportType(cfg: { type: string }): void {\n  if (!TRANSPORT_TYPES.has(cfg.type)) {\n    throw new Error(`Config pre-check: unknown MCP server type '${cfg.type}' (expected stdio|http|sse)`);\n  }\n}","typeGuard":"function isKnownServerType(t: string): t is \"stdio\" | \"http\" | \"sse\" {\n  return t === \"stdio\" || t === \"http\" || t === \"sse\";\n}","tryCatchPattern":"try {\n  await connectToServer(name, config);\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith(\"Unknown server type:\")) {\n    console.error(`${err.message} — fix 'type' in the MCP config (stdio|http|sse)`);\n    return;\n  }\n  throw err;\n}","preventionTips":["Validate MCP config JSON against a schema before loading.","Use the /mcp add wizard instead of hand-editing type fields.","Trim/normalize the type string when reading third-party configs.","Keep the client updated for newly introduced transport types."],"tags":["mcp","configuration","transport"],"backgroundTag":"unknown-server-type","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}