{"record":{"id":"b4dc99205ae59acd","repo":"mastra-ai/mastra","slug":"prompt-name-not-found","errorCode":null,"errorMessage":"Prompt \"${name}\" not found","messagePattern":"Prompt \"(.+?)\" not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/mcp/src/server/server.ts","lineNumber":1444,"sourceCode":"      });\n    }\n\n    // Get prompt handler\n    if (capturedPromptOptions.getPromptMessages) {\n      serverInstance.setRequestHandler(\n        'prompts/get',\n        async (request: { params: { name: string; arguments?: any } }, ctx) => {\n          const startTime = Date.now();\n          const { name, arguments: args } = request.params;\n          const extra = toMCPRequestHandlerExtra(ctx);\n          const prompts = await capturedPromptOptions.listPrompts?.({ extra });\n          if (!prompts) throw new Error('Failed to load prompts');\n          for (const definedPrompt of prompts) {\n            PromptSchema.parse(definedPrompt);\n          }\n          // Select prompt by name\n          const prompt = prompts.find(p => p.name === name);\n          if (!prompt) throw new Error(`Prompt \"${name}\" not found`);\n          // Validate required arguments\n          if (prompt.arguments) {\n            for (const arg of prompt.arguments) {\n              if (arg.required && (args?.[arg.name] === undefined || args?.[arg.name] === null)) {\n                throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Missing required argument: ${arg.name}`);\n              }\n            }\n          }\n          try {\n            let messages: any[] = [];\n            if (capturedPromptOptions.getPromptMessages) {\n              messages = await capturedPromptOptions.getPromptMessages({\n                name,\n                version: prompt.version,\n                args,\n                extra,\n              });\n            }","sourceCodeStart":1426,"sourceCodeEnd":1462,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/mcp/src/server/server.ts#L1426-L1462","documentation":"MCPServer.getPrompt() looks up a registered prompt by exact name match from the prompt definitions loaded by the server's getPrompts callback. This plain Error is thrown when no prompt whose `name` property equals the requested `name` exists. The library throws it early so the request fails before argument validation or prompt rendering is attempted.","triggerScenarios":"Calling server.getPrompt(name, args) (or handling an MCP prompts/get request) with a prompt name that is not among the names returned by the getPrompts callback; typos or casing differences (matching is exact ===) between the requested name and the defined prompt name.","commonSituations":"Client requests a prompt that was renamed or removed; prompt names are generated dynamically (e.g. prefixed) while the client caches an old list; case mismatch like 'CodeReview' vs 'codereview'; a listPrompts response was stale after the server restarted with different prompt definitions.","solutions":["Call the prompts/list (or getPrompts result) and verify the exact prompt name before requesting it","Fix the name spelling/casing to match the prompt's `name` field exactly","If you own the server, confirm the getPrompts callback still returns the prompt and that PromptSchema.parse succeeded for it (a malformed sibling prompt throws earlier with 'Failed to load prompts' or schema errors)","If the client caches prompt lists, refresh the list after server restarts or deploys"],"exampleFix":"// before\nconst { messages } = await server.getPrompt('code_review', { file: 'a.ts' });\n// after\nconst prompts = await server.listPrompts(); // or handle prompts/list first\nif (!prompts.some(p => p.name === 'code_review')) {\n  throw new Error('code_review prompt is not registered on this server');\n}\nconst { messages } = await server.getPrompt('code_review', { file: 'a.ts' });","handlingStrategy":"validation","validationCode":"const prompts = await getPrompts(); // same source the server uses\nif (!prompts?.some(p => p.name === requestedName)) {\n  throw new Error(`Prompt '${requestedName}' is not available. Available: ${prompts?.map(p => p.name).join(', ')}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const result = await server.getPrompt(name, args);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('not found')) {\n    // fall back to refreshed prompt list / user-facing 'prompt unavailable'\n  } else throw e;\n}","preventionTips":["Always list prompts (prompts/list) before invoking and drive the UI from that list","Treat prompt names as case-sensitive exact identifiers; copy them from the list response","Refresh cached prompt lists after server restarts or deployments"],"tags":["mcp","prompt-not-found","invalid-params","lookup"],"backgroundTag":"resource-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}