import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import type { GetPromptResult } from "@modelcontextprotocol/sdk/types.js"; import type { z } from "zod"; import type { Logger } from "./types/Logger.js"; /** * Prompt configuration metadata */ export interface PromptConfig { /** Unique prompt identifier (e.g., "modyo-alias-config") */ name: string; /** Human-readable description of what the prompt does */ description: string; /** If true, catches errors and returns them in messages instead of throwing */ catchErrors?: boolean; } /** * Abstract base class for MCP prompts * * Provides a structured, class-based approach to creating prompts with: * - Type-safe parameter validation via Zod schemas * - Consistent error handling patterns * - Logging integration * - Organization access helpers * * @example * ```typescript * class GreetingPrompt extends PromptBase<{ name: string }> { * protected config: PromptConfig = { * name: "modyo-greeting", * description: "Generate a greeting message", * }; * * protected getParamsSchema() { * return z.object({ * name: z.string().min(2).max(100).describe("User name"), * }); * } * * async generate(params: { name: string }): Promise { * return this.success(`Hello ${params.name}, welcome to Modyo!`); * } * } * ``` */ export declare abstract class PromptBase { protected server: McpServer; protected logger: Logger; /** * Prompt configuration - must be defined by subclasses */ protected abstract config: PromptConfig; /** * Returns the Zod schema for validating prompt arguments * Override to provide custom validation */ protected abstract getParamsSchema(): z.ZodType; /** * Generates the prompt messages * @param params - Validated parameters * @returns MCP GetPromptResult with messages array */ protected abstract generate(params: TParams): Promise; /** * Initializes the prompt with MCP server context * Called automatically during registration */ private initialize; /** * Registers this prompt with the MCP server * Called by McpServerBase during setup */ registerPrompt(server: McpServer, logger: Logger): void; /** * Helper: Creates a success response with a simple text message */ protected success(text: string, role?: "user" | "assistant"): GetPromptResult; /** * Helper: Creates a multi-message response */ protected messages(messages: Array<{ role: "user" | "assistant"; text: string; }>): GetPromptResult; /** * Helper: Formats error response as prompt messages * Returns a properly formatted error response without throwing */ protected errorResponse(error: unknown, context?: Record): GetPromptResult; /** * Helper: Logs debug information */ protected debug(message: string, data?: unknown): void; /** * Helper: Logs info */ protected info(message: string, data?: unknown): void; /** * Helper: Logs error */ protected logError(message: string, data?: unknown): void; /** * Extracts raw schema shape for MCP registration * Handles Zod object schemas */ private extractRawSchema; } //# sourceMappingURL=PromptBase.d.ts.map