{"record":{"id":"3e9443ee92326f65","repo":"yikart/AiToEarn","slug":"errorcode-methodnotfound","errorCode":"ErrorCode.MethodNotFound","errorMessage":"Unknown prompt: ${name}","messagePattern":"Unknown prompt: (.+?)","errorType":"error_code","errorClass":"McpError","httpStatus":null,"severity":"warning","filePath":"project/aitoearn-backend/libs/nest-mcp/src/services/handlers/mcp-prompts.handler.ts","lineNumber":65,"sourceCode":"            : [],\n        }))\n\n      return {\n        prompts,\n      }\n    })\n\n    mcpServer.server.setRequestHandler(\n      GetPromptRequestSchema,\n      async (request) => {\n        this.logger.debug('GetPromptRequestSchema is being called')\n\n        try {\n          const name = request.params.name\n          const promptInfo = this.registry.findPrompt(this.mcpModuleId, name)\n\n          if (!promptInfo) {\n            throw new McpError(\n              ErrorCode.MethodNotFound,\n              `Unknown prompt: ${name}`,\n            )\n          }\n\n          const contextId = ContextIdFactory.getByRequest(httpRequest)\n          this.moduleRef.registerRequestByContextId(httpRequest, contextId)\n\n          const promptInstance = await this.moduleRef.resolve(\n            promptInfo.providerClass,\n            contextId,\n            { strict: false },\n          )\n\n          if (!promptInstance) {\n            throw new McpError(\n              ErrorCode.MethodNotFound,\n              `Unknown prompt: ${name}`,","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-backend/libs/nest-mcp/src/services/handlers/mcp-prompts.handler.ts#L47-L83","documentation":"The MCP prompts handler received a GetPrompt request whose params.name is not registered in McpRegistryService for this MCP module. The handler looks up registry.findPrompt(moduleId, name) and, when no prompt with that name exists, returns the MCP-protocol error MethodNotFound with 'Unknown prompt: <name>'. This is the standard MCP response for a nonexistent prompt.","triggerScenarios":"An MCP client calls prompts/get with a name that was never registered via @Prompt (or equivalent) on this module, the name is misspelled or differs in case from the registered metadata.name, the prompt belongs to a different MCP module (moduleId mismatch), or the client used a stale prompt list from before the server was redeployed without that prompt.","commonSituations":"Client caches ListPrompts results from an older server version; a prompt was renamed or removed; multi-module setups where the client connects to the wrong module's endpoint; LLM agents hallucinating prompt names; typos in client config/prompt references.","solutions":["Call prompts/list on the connected MCP endpoint and use an exact name from the response","Check the registered prompt's metadata.name vs the requested name for casing/spelling differences","Verify the client is connected to the MCP module that actually registers this prompt (moduleId/endpoint check)","If the prompt should exist, confirm its provider class is registered in the module and not gated behind a disabled feature flag"],"exampleFix":"// before (client)\nawait client.getPrompt({ name: 'summarize_repo' })\n// after (name matches registered metadata.name)\nawait client.getPrompt({ name: 'summarize-repo' })","handlingStrategy":"try-catch","validationCode":"const { prompts } = await client.listPrompts()\nif (!prompts.some(p => p.name === wantedName))\n  throw new Error(`Prompt ${wantedName} not offered by this MCP server`)","typeGuard":"function promptExists(list: { prompts: { name: string }[] }, name: string): boolean {\n  return list.prompts.some(p => p.name === name)\n}","tryCatchPattern":"try {\n  return await client.getPrompt({ name })\n} catch (e) {\n  if (e instanceof McpError && e.code === ErrorCode.MethodNotFound && e.message.startsWith('Unknown prompt'))\n    return await pickPromptFromList(client) // refresh and retry with a valid name\n  throw e\n}","preventionTips":["Refresh prompts/list after server deploys instead of caching names","Match registered metadata.name exactly (casing/kebab vs snake)","Confirm the client connects to the MCP module that registers the prompt","Guard LLM-generated prompt names against the list before calling"],"tags":["mcp","prompt","not-found","protocol"],"backgroundTag":"mcp-method-not-found","analyzedSha":"d3aa8bea5b146a8675607cf0144d891aad3e9683","analyzedAt":"2026-08-31T14:19:24.185Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}