{"record":{"id":"45f5d696f1697672","repo":"CherryHQ/cherry-studio","slug":"unknown-in-memory-mcp-server-name","errorCode":null,"errorMessage":"Unknown in-memory MCP server: ${name}","messagePattern":"Unknown in-memory MCP server: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"src/main/ai/mcp/servers/factory.ts","lineNumber":55,"sourceCode":"    case BuiltinMcpServerNames.filesystem: {\n      return new FileSystemServer(resolveFilesystemBaseDir(args, envs)).server\n    }\n    case BuiltinMcpServerNames.difyKnowledge: {\n      const difyKey = envs.DIFY_KEY\n      return new DifyKnowledgeServer(difyKey, args).server\n    }\n    case BuiltinMcpServerNames.python: {\n      return new PythonServer().server\n    }\n    case BuiltinMcpServerNames.didiMcp: {\n      const apiKey = envs.DIDI_API_KEY\n      return new DiDiMcpServer(apiKey).server\n    }\n    case BuiltinMcpServerNames.browser: {\n      return new BrowserServer().server\n    }\n    default:\n      throw new Error(`Unknown in-memory MCP server: ${name}`)\n  }\n}\n","sourceCodeStart":37,"sourceCodeEnd":58,"githubUrl":"https://github.com/CherryHQ/cherry-studio/blob/726446b54cd69ffe51a276638672f6d95ca0768c/src/main/ai/mcp/servers/factory.ts#L37-L58","documentation":"Generic Error thrown by createInMemoryMcpServer when the server name does not match any case in the switch statement. The factory handles a fixed set of builtin names (memory, sequentialThinking, braveSearch, fetch, filesystem, difyKnowledge, python, didiMcp, browser). This is a configuration/startup error indicating an unrecognized builtin server name was requested.","triggerScenarios":"The MCP server configuration references a builtin server name not in BuiltinMcpServerNames, or a name that was removed/renamed in a version update. The TypeScript type system should prevent this at compile time, so at runtime it typically means an untyped config source (JSON, database) supplied an invalid name.","commonSituations":"User manually edited a config file with a typo in the server name; a server was renamed in an update but old configs persist; an external/legacy config supplies the name as an untyped string that bypasses the BuiltinMcpServerName type.","solutions":["Check the server name against BuiltinMcpServerNames enum values.","Correct the typo or update the stale name in the configuration.","If the server is custom/external, use the external MCP server path instead of the builtin factory."],"exampleFix":"// before\ncreateInMemoryMcpServer('dify' as any) // not a valid name\n\n// after\nimport { BuiltinMcpServerNames } from '@shared/utils/mcp'\nconst name: BuiltinMcpServerName = BuiltinMcpServerNames.difyKnowledge\ncreateInMemoryMcpServer(name, args, envs)","handlingStrategy":"validation","validationCode":"import { BuiltinMcpServerNames } from '@shared/utils/mcp'\nconst validNames = Object.values(BuiltinMcpServerNames) as string[]\nif (!validNames.includes(name)) {\n  throw new Error(`'${name}' is not a known builtin MCP server. Valid: ${validNames.join(', ')}`)\n}\ncreateInMemoryMcpServer(name as BuiltinMcpServerName, args, envs)","typeGuard":"import { BuiltinMcpServerNames } from '@shared/utils/mcp'\nfunction isBuiltinMcpServerName(name: string): name is BuiltinMcpServerName {\n  return Object.values(BuiltinMcpServerNames).includes(name as any)\n}","tryCatchPattern":"try {\n  return createInMemoryMcpServer(name, args, envs)\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Unknown in-memory MCP server:')) {\n    // log valid names and fail gracefully with a config error\n  }\n  throw e\n}","preventionTips":["Validate server names against BuiltinMcpServerNames before calling the factory.","For external/custom servers, use the external MCP server path, not the builtin factory.","Keep config files in sync with the current BuiltinMcpServerNames enum after updates."],"tags":["mcp","factory","configuration","unknown-server","startup"],"backgroundTag":null,"analyzedSha":"726446b54cd69ffe51a276638672f6d95ca0768c","analyzedAt":"2026-08-12T17:30:37.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}