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

  1. 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
  2. Add an entry to weatherPromptContents for the new prompt name being requested
  3. 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

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


AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30). Data as JSON: /api/errors/36d605d7e48aaf70. Report an issue: GitHub.