{"record":{"id":"f9877ce905eb341c","repo":"CherryHQ/cherry-studio","slug":"mcp-server-server-name-is-disabled","errorCode":null,"errorMessage":"MCP server ${server.name} is disabled","messagePattern":"MCP server (.+?) is disabled","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"src/main/ai/mcp/McpRuntimeService.ts","lineNumber":401,"sourceCode":"  }\n\n  public async withClient<T>(\n    serverId: string,\n    operation: (client: Client, server: McpServer) => Promise<T>\n  ): Promise<T> {\n    const server = this.getServerById(serverId)\n    const client = await this.getOrCreateClient(server)\n    return operation(client, server)\n  }\n\n  private async getOrCreateClient(server: McpServer): Promise<Client> {\n    if (this.stopping || this.isStopped || this.isDestroyed) {\n      throw new Error('MCP runtime is stopping')\n    }\n\n    if (!server.isActive) {\n      this.setServerStatus(server.id, 'disabled')\n      throw new Error(`MCP server ${server.name} is disabled`)\n    }\n\n    const serverKey = this.getServerKey(server)\n\n    // If there's a pending initialization, wait for it\n    const pendingClient = this.pendingClients.get(serverKey)\n    if (pendingClient) {\n      this.setServerStatus(server.id, 'connecting')\n      getServerLogger(server).silly(`Waiting for pending client initialization`)\n      return pendingClient\n    }\n\n    // Check if we already have a client for this server configuration\n    const existingClient = this.clients.get(serverKey)\n    if (existingClient) {\n      try {\n        // Check if the existing client is still connected\n        const pingResult = await existingClient.ping({","sourceCodeStart":383,"sourceCodeEnd":419,"githubUrl":"https://github.com/CherryHQ/cherry-studio/blob/726446b54cd69ffe51a276638672f6d95ca0768c/src/main/ai/mcp/McpRuntimeService.ts#L383-L419","documentation":"Thrown by `getOrCreateClient` when `server.isActive` is false. The runtime not only throws but also calls `setServerStatus(server.id, 'disabled')` as a side effect, marking the server's status in the cache for UI visibility. This means a disabled server cannot be used for any client operation.","triggerScenarios":"Calling any method that needs a client connection (callTool, listTools, listResources, etc.) on a server whose `isActive` field is false in the database. This can happen if the user toggled the server off, or a previous failure cascade deactivated it.","commonSituations":"User disabled the server in MCP settings UI but a background AI task still references it; server was auto-deactivated after repeated connection failures; the server entity was loaded from DB with isActive=false but caller didn't check.","solutions":["Check `server.isActive` before attempting tool calls or client operations","Re-enable the server in the MCP settings UI (set isActive to true)","In the calling code, handle this error gracefully by skipping the server or prompting the user to enable it","Investigate why the server was deactivated — check server logs for prior connection failures"],"exampleFix":"// before\nconst result = await runtime.callToolByServer({ server, name, args })\n\n// after\nif (!server.isActive) {\n  throw new Error(`Server ${server.name} is not active. Enable it in MCP settings.`)\n}\nconst result = await runtime.callToolByServer({ server, name, args })","handlingStrategy":"validation","validationCode":"if (!server.isActive) {\n  throw new Error(`Server '${server.name}' is disabled. Enable it in MCP settings.`)\n}\n// Only proceed with client operations if active\nconst client = await runtime.getOrCreateClient(server)","typeGuard":"function isActiveServer(server: McpServer): boolean {\n  return server.isActive === true\n}","tryCatchPattern":"try {\n  await runtime.callToolByServer({ server, name, args })\n} catch (e) {\n  if (e instanceof Error && e.message.includes('is disabled')) {\n    // Prompt user to enable the server, or skip it\n    return { error: 'server-disabled', serverName: server.name }\n  }\n  throw e\n}","preventionTips":["Filter to active servers before iterating over available MCP tools in your AI pipeline","Show the active/inactive state clearly in the UI so users know which servers are usable","Avoid referencing disabled servers in saved agent configurations"],"tags":["mcp","server-state","configuration","runtime"],"backgroundTag":null,"analyzedSha":"726446b54cd69ffe51a276638672f6d95ca0768c","analyzedAt":"2026-08-12T17:30:37.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}