CherryHQ/cherry-studio · critical · Error

Unknown in-memory MCP server: ${name}

Error message

Unknown in-memory MCP server: ${name}

What it means

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.

Source

Thrown at src/main/ai/mcp/servers/factory.ts:55

    case BuiltinMcpServerNames.filesystem: {
      return new FileSystemServer(resolveFilesystemBaseDir(args, envs)).server
    }
    case BuiltinMcpServerNames.difyKnowledge: {
      const difyKey = envs.DIFY_KEY
      return new DifyKnowledgeServer(difyKey, args).server
    }
    case BuiltinMcpServerNames.python: {
      return new PythonServer().server
    }
    case BuiltinMcpServerNames.didiMcp: {
      const apiKey = envs.DIDI_API_KEY
      return new DiDiMcpServer(apiKey).server
    }
    case BuiltinMcpServerNames.browser: {
      return new BrowserServer().server
    }
    default:
      throw new Error(`Unknown in-memory MCP server: ${name}`)
  }
}

View on GitHub (pinned to 726446b54c)

Solutions

  1. Check the server name against BuiltinMcpServerNames enum values.
  2. Correct the typo or update the stale name in the configuration.
  3. If the server is custom/external, use the external MCP server path instead of the builtin factory.

Example fix

// before
createInMemoryMcpServer('dify' as any) // not a valid name

// after
import { BuiltinMcpServerNames } from '@shared/utils/mcp'
const name: BuiltinMcpServerName = BuiltinMcpServerNames.difyKnowledge
createInMemoryMcpServer(name, args, envs)
Defensive patterns

Strategy: validation

Validate before calling

import { BuiltinMcpServerNames } from '@shared/utils/mcp'
const validNames = Object.values(BuiltinMcpServerNames) as string[]
if (!validNames.includes(name)) {
  throw new Error(`'${name}' is not a known builtin MCP server. Valid: ${validNames.join(', ')}`)
}
createInMemoryMcpServer(name as BuiltinMcpServerName, args, envs)

Type guard

import { BuiltinMcpServerNames } from '@shared/utils/mcp'
function isBuiltinMcpServerName(name: string): name is BuiltinMcpServerName {
  return Object.values(BuiltinMcpServerNames).includes(name as any)
}

Try / catch

try {
  return createInMemoryMcpServer(name, args, envs)
} catch (e) {
  if (e instanceof Error && e.message.startsWith('Unknown in-memory MCP server:')) {
    // log valid names and fail gracefully with a config error
  }
  throw e
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of CherryHQ/cherry-studio@726446b54c (2026-08-12). Data as JSON: /api/errors/45f5d696f1697672. Report an issue: GitHub.