CherryHQ/cherry-studio · error · Error

Failed to start in-memory server: ${error.message}

Error message

Failed to start in-memory server: ${error.message}

What it means

Thrown when an in-memory builtin MCP server fails to connect via `InMemoryTransport`. The runtime creates a linked pair of in-memory transports, instantiates the server via `createInMemoryMcpServer(name, args, env)`, and attempts `.connect(serverTransport)`. If connect throws, the error is wrapped with context. This applies to builtin in-memory servers except mcpAutoInstall.

Source

Thrown at src/main/ai/mcp/McpRuntimeService.ts:503

                }
              },
              authProvider
            }
            getServerLogger(server).debug(`Using StreamableHTTPClientTransport for ${server.name}`)
            return new StreamableHTTPClientTransport(new URL(httpUrl), options)
          }

          if (isInMemoryBuiltinMcpServer(server) && server.name !== BuiltinMcpServerNames.mcpAutoInstall) {
            getServerLogger(server).debug(`Using in-memory transport`)
            const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair()
            // start the in-memory server with the given name and environment variables
            const inMemoryServer = createInMemoryMcpServer(server.name, args, server.env || {})
            try {
              await inMemoryServer.connect(serverTransport)
              getServerLogger(server).debug(`In-memory server started`)
            } catch (error: any) {
              getServerLogger(server).error(`Error starting in-memory server`, error as Error)
              throw new Error(`Failed to start in-memory server: ${error.message}`)
            }
            // set the client transport to the client
            return clientTransport
          } else if (server.baseUrl) {
            const urlBasedType: McpServerType = typeOverride ?? server.type ?? 'sse'
            if (urlBasedType === 'streamableHttp') {
              const options: StreamableHTTPClientTransportOptions = {
                fetch: async (url, init) => {
                  return net.fetch(typeof url === 'string' ? url : url.toString(), init)
                },
                requestInit: {
                  headers: prepareHeaders()
                },
                authProvider
              }
              // redact headers before logging
              getServerLogger(server).debug(`StreamableHTTPClientTransport options`, {
                options: redactSensitive(options)

View on GitHub (pinned to 726446b54c)

Solutions

  1. Check the detailed server logs (emitted via getServerLogger just before the throw) for the original error.message
  2. Verify the in-memory server's constructor and connect handler don't throw on the given args/env
  3. Update the MCP SDK to a compatible version if there's a protocol mismatch
  4. If the server is a custom builtin, debug its setup logic in isolation using InMemoryTransport.createLinkedPair()
Defensive patterns

Strategy: try-catch

Type guard

function isInMemoryServer(server: McpServer): boolean {
  return isInMemoryBuiltinMcpServer(server) && server.name !== BuiltinMcpServerNames.mcpAutoInstall
}

Try / catch

try {
  await runtime.withClient(serverId, async (client, server) => {
    // operation
  })
} catch (e) {
  if (e instanceof Error && e.message.startsWith('Failed to start in-memory server')) {
    // Check server logs for the original error, likely a server implementation bug
    logger.error('In-memory server startup failed', e)
  }
  throw e
}

Prevention

When it happens

Trigger: An in-memory server's `connect()` method throws due to an initialization failure — invalid arguments, a runtime error in the server's setup handler, SDK version incompatibility, or the server module failing to register its tools/resources.

Common situations: Builtin in-memory MCP server has a bug in its initialization; the server's args/env are invalid for the current platform; SDK version mismatch between the server implementation and the client; the server requires external resources that are unavailable.

Related errors


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