Skip to main content
Glama
base.ts1.02 kB
import { z } from "zod"; import { IServiceContainer } from "../container.js"; import { GetPromptResult } from "@modelcontextprotocol/sdk/types.js"; export abstract class BasePrompt< T extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>, > { constructor(protected container: IServiceContainer) {} abstract name: string; abstract description: string; abstract schema: T; protected abstract getImpl(params: z.infer<T>): Promise<GetPromptResult>; public async get(params: unknown): Promise<GetPromptResult> { try { const validatedParams = await this.schema.parseAsync(params); return await this.getImpl(validatedParams); } catch (err) { const errorMessage = err instanceof Error ? err.message : String(err); console.error(`Prompt generation failed: ${this.name}`, { error: errorMessage, }); throw err; } } public getDefinition() { return { description: this.description, argsSchema: this.schema.shape, }; } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kirbah/mcp-youtube'

If you have feedback or need assistance with the MCP directory API, please join our Discord server