yikart/AiToEarn · warning · McpError
ErrorCode.MethodNotFound
ErrorCode.MethodNotFound
Error message
Unknown prompt: ${name} What it means
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.
Source
Thrown at project/aitoearn-backend/libs/nest-mcp/src/services/handlers/mcp-prompts.handler.ts:65
: [],
}))
return {
prompts,
}
})
mcpServer.server.setRequestHandler(
GetPromptRequestSchema,
async (request) => {
this.logger.debug('GetPromptRequestSchema is being called')
try {
const name = request.params.name
const promptInfo = this.registry.findPrompt(this.mcpModuleId, name)
if (!promptInfo) {
throw new McpError(
ErrorCode.MethodNotFound,
`Unknown prompt: ${name}`,
)
}
const contextId = ContextIdFactory.getByRequest(httpRequest)
this.moduleRef.registerRequestByContextId(httpRequest, contextId)
const promptInstance = await this.moduleRef.resolve(
promptInfo.providerClass,
contextId,
{ strict: false },
)
if (!promptInstance) {
throw new McpError(
ErrorCode.MethodNotFound,
`Unknown prompt: ${name}`,View on GitHub (pinned to d3aa8bea5b)
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
Example fix
// before (client)
await client.getPrompt({ name: 'summarize_repo' })
// after (name matches registered metadata.name)
await client.getPrompt({ name: 'summarize-repo' }) Defensive patterns
Strategy: try-catch
Validate before calling
const { prompts } = await client.listPrompts()
if (!prompts.some(p => p.name === wantedName))
throw new Error(`Prompt ${wantedName} not offered by this MCP server`) Type guard
function promptExists(list: { prompts: { name: string }[] }, name: string): boolean {
return list.prompts.some(p => p.name === name)
} Try / catch
try {
return await client.getPrompt({ name })
} catch (e) {
if (e instanceof McpError && e.code === ErrorCode.MethodNotFound && e.message.startsWith('Unknown prompt'))
return await pickPromptFromList(client) // refresh and retry with a valid name
throw e
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31).
Data as JSON: /api/errors/3e9443ee92326f65.
Report an issue: GitHub.