CherryHQ/cherry-studio · error · Error

Unknown tool: ${name}

Error message

Unknown tool: ${name}

What it means

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.

Source

Thrown at src/main/ai/mcp/servers/difyKnowledge.ts:123

          case 'list_knowledges': {
            return await this.performListKnowledges(this.config.difyKey, this.config.apiHost)
          }
          case 'search_knowledge': {
            const parsed = SearchKnowledgeArgsSchema.safeParse(args)
            if (!parsed.success) {
              const errorDetails = JSON.stringify(parsed.error.format(), null, 2)
              throw new Error(`Invalid arguments:\n${errorDetails}`)
            }
            return await this.performSearchKnowledge(
              parsed.data.id,
              parsed.data.query,
              parsed.data.topK || 6,
              this.config.difyKey,
              this.config.apiHost
            )
          }
          default:
            throw new Error(`Unknown tool: ${name}`)
        }
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : String(error)
        return {
          content: [{ type: 'text', text: `Error: ${errorMessage}` }],
          isError: true
        }
      }
    })
  }

  private async performListKnowledges(difyKey: string, apiHost: string): Promise<McpResponse> {
    try {
      const url = `${apiHost.replace(/\/$/, '')}/datasets`
      const response = await net.fetch(url, {
        method: 'GET',
        headers: {
          Authorization: `Bearer ${difyKey}`

View on GitHub (pinned to 726446b54c)

Solutions

  1. Call ListTools first and only invoke tool names from the returned list.
  2. Check exact spelling and casing against 'list_knowledges' and 'search_knowledge'.
  3. Update the server or switch to the correct tool name.

Example fix

// before
await server.callTool('search_kb', args) // wrong name

// after
const valid = ['list_knowledges', 'search_knowledge']
if (!valid.includes(name)) throw new Error(`Unknown tool '${name}'. Use one of: ${valid.join(', ')}`)
await server.callTool(name, args)
Defensive patterns

Strategy: validation

Validate before calling

const knownDifyTools = ['list_knowledges', 'search_knowledge']
if (!knownDifyTools.includes(toolName)) {
  throw new Error(`Tool '${toolName}' not available. Use one of: ${knownDifyTools.join(', ')}`)
}

Type guard

function isKnownDifyTool(name: string): boolean {
  return ['list_knowledges', 'search_knowledge'].includes(name)
}

Prevention

When it happens

Trigger: The MCP client calls a tool name not in the server's ListTools response — a typo, a hallucinated name, or a version mismatch.

Common situations: Model hallucination of a tool name; casing or spelling mismatch; the tool was removed in a DifyKnowledgeServer update.

Related errors


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