{"record":{"id":"94cba36c84eef80c","repo":"CherryHQ/cherry-studio","slug":"unknown-tool-name-94cba3","errorCode":null,"errorMessage":"Unknown tool: ${name}","messagePattern":"Unknown tool: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/main/ai/mcp/servers/difyKnowledge.ts","lineNumber":123,"sourceCode":"          case 'list_knowledges': {\n            return await this.performListKnowledges(this.config.difyKey, this.config.apiHost)\n          }\n          case 'search_knowledge': {\n            const parsed = SearchKnowledgeArgsSchema.safeParse(args)\n            if (!parsed.success) {\n              const errorDetails = JSON.stringify(parsed.error.format(), null, 2)\n              throw new Error(`Invalid arguments:\\n${errorDetails}`)\n            }\n            return await this.performSearchKnowledge(\n              parsed.data.id,\n              parsed.data.query,\n              parsed.data.topK || 6,\n              this.config.difyKey,\n              this.config.apiHost\n            )\n          }\n          default:\n            throw new Error(`Unknown tool: ${name}`)\n        }\n      } catch (error) {\n        const errorMessage = error instanceof Error ? error.message : String(error)\n        return {\n          content: [{ type: 'text', text: `Error: ${errorMessage}` }],\n          isError: true\n        }\n      }\n    })\n  }\n\n  private async performListKnowledges(difyKey: string, apiHost: string): Promise<McpResponse> {\n    try {\n      const url = `${apiHost.replace(/\\/$/, '')}/datasets`\n      const response = await net.fetch(url, {\n        method: 'GET',\n        headers: {\n          Authorization: `Bearer ${difyKey}`","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/CherryHQ/cherry-studio/blob/726446b54cd69ffe51a276638672f6d95ca0768c/src/main/ai/mcp/servers/difyKnowledge.ts#L105-L141","documentation":"Generic Error thrown by the DifyKnowledgeServer CallToolRequest handler default branch when the tool name is not 'list_knowledges' or 'search_knowledge'. The error is caught by the outer try-catch and returned as an MCP isError response. It indicates the client invoked a tool name this server does not register.","triggerScenarios":"The MCP client calls a tool name not in the server's ListTools response — a typo, a hallucinated name, or a version mismatch.","commonSituations":"Model hallucination of a tool name; casing or spelling mismatch; the tool was removed in a DifyKnowledgeServer update.","solutions":["Call ListTools first and only invoke tool names from the returned list.","Check exact spelling and casing against 'list_knowledges' and 'search_knowledge'.","Update the server or switch to the correct tool name."],"exampleFix":"// before\nawait server.callTool('search_kb', args) // wrong name\n\n// after\nconst valid = ['list_knowledges', 'search_knowledge']\nif (!valid.includes(name)) throw new Error(`Unknown tool '${name}'. Use one of: ${valid.join(', ')}`)\nawait server.callTool(name, args)","handlingStrategy":"validation","validationCode":"const knownDifyTools = ['list_knowledges', 'search_knowledge']\nif (!knownDifyTools.includes(toolName)) {\n  throw new Error(`Tool '${toolName}' not available. Use one of: ${knownDifyTools.join(', ')}`)\n}","typeGuard":"function isKnownDifyTool(name: string): boolean {\n  return ['list_knowledges', 'search_knowledge'].includes(name)\n}","tryCatchPattern":null,"preventionTips":["Call ListTools before invoking to get the current valid tool set.","Check exact spelling and casing of tool names.","Handle the isError response that wraps this error rather than relying on exceptions."],"tags":["dify","mcp","unknown-tool","dispatch"],"backgroundTag":null,"analyzedSha":"726446b54cd69ffe51a276638672f6d95ca0768c","analyzedAt":"2026-08-12T17:30:37.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}