{"record":{"id":"3ac459ef1aa7ce28","repo":"yikart/AiToEarn","slug":"methodnotfound","errorCode":"MethodNotFound","errorMessage":"Unknown tool: ${request.params.name}","messagePattern":"Unknown tool: (.+?)","errorType":"error_code","errorClass":"McpError","httpStatus":null,"severity":"error","filePath":"project/aitoearn-backend/libs/nest-mcp/src/services/handlers/mcp-tools.handler.ts","lineNumber":121,"sourceCode":"      })\n\n      return {\n        tools,\n      }\n    })\n\n    mcpServer.server.setRequestHandler(\n      CallToolRequestSchema,\n      async (request) => {\n        this.logger.debug('CallToolRequestSchema is being called')\n\n        const toolInfo = this.registry.findTool(\n          this.mcpModuleId,\n          request.params.name,\n        )\n\n        if (!toolInfo) {\n          throw new McpError(\n            ErrorCode.MethodNotFound,\n            `Unknown tool: ${request.params.name}`,\n          )\n        }\n\n        try {\n          // Validate input parameters against the tool's schema\n          if (toolInfo.metadata.parameters) {\n            const validation = toolInfo.metadata.parameters.safeParse(\n              request.params.arguments || {},\n            )\n            if (!validation.success) {\n              throw new McpError(\n                ErrorCode.InvalidParams,\n                `Invalid parameters: ${validation.error.message}`,\n              )\n            }\n            // Use validated arguments to ensure defaults and transformations are applied","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-backend/libs/nest-mcp/src/services/handlers/mcp-tools.handler.ts#L103-L139","documentation":"In the tools/call handler, registry.findTool looks up the tool by name for this mcpModuleId before any execution. If no tool metadata is registered under that name, the handler throws McpError MethodNotFound, matching JSON-RPC -32601 semantics.","triggerScenarios":"Client calls tools/call with a name not registered via @McpTool in this module, a typo'd name, or a tool registered under a different mcpModuleId.","commonSituations":"Stale client-side tool list after server restart/rename; tool defined but its provider never registered in the module; calling a tool on the wrong server (CN vs international) where the module differs.","solutions":["Call tools/list and use the exact returned tool name","Verify the tool's provider class is registered for the correct mcpModuleId","Fix the tool name typo in the client","Restart/redeploy so newly added tools are registered"],"exampleFix":"// before\nawait client.callTool({ name: 'send_post', arguments });\n// after\nconst { tools } = await client.listTools();\nawait client.callTool({ name: tools.find(t => t.name.includes('post'))!.name, arguments });","handlingStrategy":"validation","validationCode":"const { tools } = await client.listTools();\nconst tool = tools.find(t => t.name === name);\nif (!tool) throw new Error(`Tool ${name} not available on this server`);","typeGuard":"function toolExists(name: string, tools: { name: string }[]): boolean {\n  return tools.some(t => t.name === name);\n}","tryCatchPattern":"try {\n  await client.callTool({ name, arguments });\n} catch (e) {\n  if (e.code === ErrorCode.MethodNotFound) {\n    await refreshToolList();\n    if (!toolExists(name, currentTools)) throw new Error(`Tool ${name} removed`);\n  } else throw e;\n}","preventionTips":["Call tools/list before invoking and cache with a short TTL","Use exact tool names from the server, not from memory/docs","Confirm the tool's provider is registered for the target mcpModuleId","Verify you are calling the correct environment's server"],"tags":["mcp","json-rpc","method-not-found","tools"],"backgroundTag":"mcp-method-not-found","analyzedSha":"d3aa8bea5b146a8675607cf0144d891aad3e9683","analyzedAt":"2026-08-31T14:19:24.185Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}