{"record":{"id":"79576ad3c1c947e2","repo":"TencentCloud/TencentDB-Agent-Memory","slug":"unknown-tool-name","errorCode":null,"errorMessage":"Unknown tool: ${name}","messagePattern":"Unknown tool: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"MemoryKnowledge/src/mcp/server.ts","lineNumber":57,"sourceCode":"  server.setRequestHandler(ListToolsRequestSchema, async () => {\n    return {\n      tools: MCP_TOOLS.map((t) => ({\n        name: t.name,\n        description: t.description,\n        inputSchema: t.inputSchema,\n      })),\n    };\n  });\n\n  // Call tool\n  server.setRequestHandler(CallToolRequestSchema, async (request) => {\n    const { name, arguments: args } = request.params;\n    const tool = toolMap.get(name);\n    if (!tool) {\n      log.warn(`Unknown tool requested: \"${name}\"`);\n      return {\n        content: [{ type: \"text\", text: `Unknown tool: ${name}` }],\n        isError: true,\n      };\n    }\n\n    const body = (args ?? {}) as Record<string, unknown>;\n    try {\n      const data = await callApi(httpOpts, tool.endpoint, body);\n\n      // The code-graph query endpoints return {text, isError} — pass through directly\n      if (data && typeof data === \"object\" && \"text\" in data && \"isError\" in data) {\n        const result = data as { text: string; isError: boolean };\n        return {\n          content: [{ type: \"text\", text: result.text || \"(empty result)\" }],\n          isError: result.isError,\n        };\n      }\n\n      // Other endpoints return structured data — serialize as JSON\n      return {","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/3efcd317b84146d6a08518ac0f7ee7c8a8d200ec/MemoryKnowledge/src/mcp/server.ts#L39-L75","documentation":"The MCP server's tool-call handler looks up request.params.name in toolMap, which is built from the registered tool endpoints. If the requested tool name is not registered, the handler logs a warning and returns an isError result with text 'Unknown tool: <name>' instead of throwing — the error text is the tool-call result returned to the MCP client.","triggerScenarios":"A client sends tools/call with a name that is not in toolMap: typo in tool name, client cached a stale tool list after server tool set changed, or the tool was removed/renamed in server.ts while the client still references the old name.","commonSituations":"Client connected to an older server version exposing different tool names; hand-written MCP client calls with a mistyped tool name; multiple MCP servers running and the client sends a tool from one server to another.","solutions":["Call tools/list on the server and use an exact name from the response","Fix the tool name spelling in the client request","Restart/refresh the client so it re-fetches the current tool list","If the tool should exist, register it in createMcpServer so it lands in toolMap"],"exampleFix":"// before\nawait client.callTool({ name: 'searchKnowledgebase', arguments: { q: 'x' } });\n// after\nconst { tools } = await client.listTools();\nawait client.callTool({ name: 'search_knowledge_base', arguments: { q: 'x' } });","handlingStrategy":"validation","validationCode":"const { tools } = await client.listTools();\nif (!tools.some(t => t.name === toolName)) throw new Error(`Tool \"${toolName}\" not registered on this server`);","typeGuard":"function isRegisteredTool(name: string, tools: { name: string }[]): name is string {\n  return tools.some(t => t.name === name);\n}","tryCatchPattern":"const result = await client.callTool({ name, arguments: args });\nif (result.isError && result.content?.[0]?.text?.startsWith('Unknown tool:')) {\n  const { tools } = await client.listTools();\n  console.error(`\"${name}\" not found. Available: ${tools.map(t => t.name).join(', ')}`);\n}","preventionTips":["Fetch tools/list before calling instead of hard-coding names","Invalidate cached tool lists after server restarts/upgrades","Verify tool registration in createMcpServer if a tool goes missing"],"tags":["mcp","tool-call","unknown-tool","api"],"backgroundTag":"unknown-tool-name","analyzedSha":"3efcd317b84146d6a08518ac0f7ee7c8a8d200ec","analyzedAt":"2026-09-01T05:44:22.276Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}