mastra-ai/mastra · error · Error
Mock prompt not found for ${name}
Error message
Mock prompt not found for ${name} What it means
The mock MCP weather server fixture only defines a fixed set of prompt contents in its weatherPromptContents map. When getPrompt is called with a prompt name that is not a key of that map, the fixture throws this error instead of returning PromptMessage[]. It exists to fail fast in tests when a client requests a prompt the mock server never registered.
Source
Thrown at packages/mcp/src/__fixtures__/weather.ts:168
return weatherResourceContents[uri];
}
throw new Error(`Mock resource content not found for ${uri}`);
},
resourceTemplates: async () => weatherResourceTemplatesDefinitions,
};
const mcpServerPrompts: MCPServerPrompts = {
listPrompts: async () => weatherPrompts,
getPromptMessages: async ({
name,
version: _version,
}: {
name: string;
version?: string;
}): Promise<PromptMessage[]> => {
const content = weatherPromptContents[name];
if (!content) {
throw new Error(`Mock prompt not found for ${name}`);
}
return [
{
role: 'user',
content: {
type: 'text',
text: content,
},
},
];
},
};
const mcpServer = new MCPServer({
name: serverId,
version: '1.0.0',
tools: {
getWeather: weatherToolDefinition,View on GitHub (pinned to 75dd419e61)
Solutions
- Check the exact prompt name passed to getPrompt against the keys defined in weatherPromptContents in packages/mcp/src/__fixtures__/weather.ts and fix the typo
- Add an entry to weatherPromptContents for the new prompt name being requested
- Verify the mock server registers the prompt in its listPrompts handler so clients only request listed prompts
Example fix
// before
await server.getPrompt({ name: 'weather-forecat', arguments: {...} });
// after
await server.getPrompt({ name: 'weather-forecast', arguments: {...} }); Defensive patterns
Strategy: validation
Validate before calling
const available = Object.keys(weatherPromptContents);
if (!available.includes(name)) {
throw new Error(`Unknown prompt '${name}'. Available: ${available.join(', ')}`);
}
await server.getPrompt({ name }); Type guard
function isKnownPrompt(name: string): name is keyof typeof weatherPromptContents {
return name in weatherPromptContents;
} Prevention
- Derive requested prompt names from the fixture's listPrompts output instead of hardcoding strings
- Keep prompt names in a shared const/enum used by both the fixture list and tests
- When adding a new prompt to the fixture, add its contents in the same commit
When it happens
Trigger: Calling getPrompt() on the mock weather server with a name that is not present in weatherPromptContents — e.g. a typo in the prompt name, a prompt added to the server's prompt list but not to the contents map, or a test asserting a prompt the fixture does not implement.
Common situations: Test authors extending the weather fixture with a new prompt but forgetting to add its content; renaming a prompt in one place but not the other; copy-pasted test code referencing prompt names from a different fixture.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Cancelled
- Saw text content for input CoreMessage, but the role is ${co
- Saw incompatible message content part type ${part.type} for
- Encountered unknown role ${role} when converting V4 CoreMess
- Saw text content for input ModelMessage, but the role is ${m
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/36d605d7e48aaf70.
Report an issue: GitHub.