{"record":{"id":"a2280abd4411ed9f","repo":"farion1231/cc-switch","slug":"mcp-type","errorCode":null,"errorMessage":"不支持的 MCP 服务器类型: ${type}","messagePattern":"不支持的 MCP 服务器类型: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/utils/tomlUtils.ts","lineNumber":180,"sourceCode":"    if (config.headers && typeof config.headers === \"object\") {\n      const headers: Record<string, string> = {};\n      for (const [k, v] of Object.entries(config.headers)) {\n        headers[k] = String(v);\n      }\n      server.headers = headers;\n      knownFields.add(\"headers\");\n    }\n\n    // 保留所有未知字段\n    for (const key of Object.keys(config)) {\n      if (!knownFields.has(key)) {\n        server[key] = config[key];\n      }\n    }\n\n    return server;\n  } else {\n    throw new Error(`不支持的 MCP 服务器类型: ${type}`);\n  }\n}\n\n/**\n * 尝试从 TOML 中提取合理的服务器 ID/标题\n * @param tomlText TOML 文本\n * @returns 建议的 ID，失败返回空字符串\n */\nexport const extractIdFromToml = (tomlText: string): string => {\n  try {\n    const parsed = parseToml(normalizeTomlText(tomlText));\n\n    // 尝试从 [mcp_servers.<id>] 或 [mcp.servers.<id>] 中提取 ID\n    if (parsed.mcp_servers && typeof parsed.mcp_servers === \"object\") {\n      const serverIds = Object.keys(parsed.mcp_servers);\n      if (serverIds.length > 0) {\n        return serverIds[0];\n      }","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/farion1231/cc-switch/blob/0b5da510168914b251481654a568c3ffacd62cf4/src/utils/tomlUtils.ts#L162-L198","documentation":"normalizeServerConfig only knows three types — stdio, http, sse — and any other value for type falls into the final throw '不支持的 MCP 服务器类型: <type>'. The comparison is exact and case-sensitive, and type defaults to stdio when absent, so this fires only when an explicit unrecognized value is present.","triggerScenarios":"type = \"websocket\", type = \"WebSocket\" (case mismatch), type = \"streamable-http\", or any string outside {stdio, http, sse}.","commonSituations":"Newer MCP transport names pasted from other tools' configs; capitalized type values; typos like 'ss3' or 'http2'.","solutions":["Use one of stdio | http | sse, lowercase, as the type value","For streamable-http servers, try type = \"http\" if the endpoint is compatible","Omit the type key entirely for local-process servers to get the stdio default"],"exampleFix":"# before\ntype = \"streamable-http\"\n\n# after\ntype = \"http\"\nurl = \"https://example.com/mcp\"","handlingStrategy":"type-guard","validationCode":"const SUPPORTED = new Set(['stdio', 'http', 'sse']);\nconst type = (first?.type as string) || 'stdio';\nif (!SUPPORTED.has(type)) {\n  // show \"type must be stdio | http | sse\" before importing\n}","typeGuard":"const SUPPORTED_MCP_TYPES: ReadonlySet<string> = new Set(['stdio', 'http', 'sse']);\nfunction isSupportedMcpServerType(value: unknown): value is 'stdio' | 'http' | 'sse' {\n  return typeof value === 'string' && SUPPORTED_MCP_TYPES.has(value);\n}","tryCatchPattern":"try {\n  const server = tomlToMcpServer(tomlText);\n} catch (error) {\n  if (error instanceof Error && error.message.startsWith('不支持的 MCP 服务器类型')) {\n    // hint the supported set and lowercase requirement\n  } else {\n    throw error;\n  }\n}","preventionTips":["Write type values lowercase and from the supported set","Map ws://→http transport names before pasting","Omit type for stdio servers to use the default"],"tags":["toml","mcp","unsupported-type","validation"],"backgroundTag":"unsupported-config-type","analyzedSha":"0b5da510168914b251481654a568c3ffacd62cf4","analyzedAt":"2026-08-20T14:29:00.113Z","contentChangedAt":"2026-08-20T14:29:00.113Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}