{"record":{"id":"ee10dc79b9b2575b","repo":"rohitg00/agentmemory","slug":"unknown-tool-v-tool","errorCode":null,"errorMessage":"Unknown tool: ${v.tool}","messagePattern":"Unknown tool: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/mcp/standalone.ts","lineNumber":255,"sourceCode":"      const result = await handle.call(\"/agentmemory/governance/memories\", {\n        method: \"DELETE\",\n        body: JSON.stringify({ memoryIds: v.memoryIds, reason: v.reason }),\n      });\n      return textResponse(result);\n    }\n    case \"memory_export\": {\n      const result = await handle.call(\"/agentmemory/export\", { method: \"GET\" });\n      return textResponse(result, true);\n    }\n    case \"memory_audit\": {\n      const result = await handle.call(\n        `/agentmemory/audit?limit=${v.limit}`,\n        { method: \"GET\" },\n      );\n      return textResponse(result, true);\n    }\n    default:\n      throw new Error(`Unknown tool: ${v.tool}`);\n  }\n}\n\nasync function handleLocal(\n  v: Validated,\n  kvInstance: InMemoryKV,\n): Promise<{ content: Array<{ type: string; text: string }> }> {\n  switch (v.tool) {\n    case \"memory_save\": {\n      const id = generateId(\"mem\");\n      const isoNow = new Date().toISOString();\n      await kvInstance.set(\"mem:memories\", id, {\n        id,\n        type: v.type,\n        title: (v.content || \"\").slice(0, 80),\n        content: v.content,\n        concepts: v.concepts,\n        files: v.files,","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/rohitg00/agentmemory/blob/e04ba88819c365c9acf9d6661ea802143e728bd6/src/mcp/standalone.ts#L237-L273","documentation":"The standalone MCP server's proxy handler `handleProxy` dispatches a validated tool call through a switch on the tool name and throws this error when no case matches. It means the MCP client requested a tool that is neither one of the proxy-backed tools nor handled locally. It guards against invoking tool names that were never registered, including typos and tools removed in newer versions.","triggerScenarios":"Calling an MCP tool via `mcp::tools::call` (or tools/call over the MCP transport) whose name is in the validated set but has no `case` in handleProxy's switch — e.g. a typo like `memory_retrive`, a tool from a newer agentmemory release than the server, or a custom tool name invented by the caller.","commonSituations":"An LLM agent hallucinates a plausible tool name; a client hardcodes tool names after an upgrade where tools were renamed; calling the proxy path with a tool that only exists in the full server, while the standalone bundle only wired a subset into handleProxy.","solutions":["Call `tools/list` (or inspect handleProxy's switch in src/mcp/standalone.ts) to get the exact supported tool names and correct the caller.","Fix typos in the tool name — names are exact-match, case-sensitive strings like `memory_save`.","Update the @agentmemory MCP server to a version matching your client's tool list, or downgrade the client.","If you need a tool that genuinely doesn't exist, implement it in handleProxy or run the full agentmemory server instead of the standalone bundle."],"exampleFix":"// before\nawait callTool(\"memory_search_all\", { query: \"x\" });\n// after\n// use a real tool name from tools/list, e.g.:\nawait callTool(\"memory_recall\", { query: \"x\" });","handlingStrategy":"validation","validationCode":"const SUPPORTED = new Set([\"memory_save\", \"memory_recall\", \"memory_search\" /* ...from tools/list */]);\nfunction assertKnownTool(tool: string) {\n  if (!SUPPORTED.has(tool)) throw new Error(`Tool \"${tool}\" not supported by this server; call tools/list`);\n}","typeGuard":"function isKnownTool(tool: string, known: readonly string[]): tool is typeof known[number] {\n  return (known as readonly string[]).includes(tool);\n}","tryCatchPattern":"try {\n  return await callTool(toolName, args);\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith(\"Unknown tool:\")) {\n    const list = await callTool(\"tools/list\"); // or handle tools/list request\n    throw new Error(`Unknown tool \"${toolName}\". Available: ${JSON.stringify(list)}`);\n  }\n  throw e;\n}","preventionTips":["Always discover tool names via tools/list instead of hardcoding them.","Keep the MCP client package version in lockstep with the server version.","Constrain LLM agents to the advertised tool list in their system prompt.","Add an integration test that calls every tool name you rely on."],"tags":["mcp","unknown-tool","tool-dispatch"],"backgroundTag":"unknown-tool-name","analyzedSha":"e04ba88819c365c9acf9d6661ea802143e728bd6","analyzedAt":"2026-08-30T01:07:40.754Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}