MCP Server Framework - v1.0.0
    Preparing search index...

    Interface PromptDefinition<TInput>

    Prompt definition - the canonical type for MCP prompts.

    Prompts generate pre-defined message sequences that guide LLM behavior. Use Zod schemas for type-safe argument handling.

    // With typed arguments
    const explainPrompt = definePrompt({
    name: 'explain-concept',
    description: 'Explain a technical concept',
    input: z.object({
    topic: z.string().describe('Topic to explain'),
    level: z.enum(['beginner', 'expert']).default('beginner'),
    }),
    generate: async ({ topic, level }) => [
    { role: 'user', content: `Explain ${topic} at ${level} level.` },
    ],
    });

    // Without arguments
    const greetingPrompt = definePrompt({
    name: 'greeting',
    description: 'Standard greeting',
    generate: async () => [
    { role: 'user', content: 'Hello!' },
    ],
    });
    interface PromptDefinition<TInput extends AnyZodObject = AnyZodObject> {
        complete?: CompletionCallback;
        description: string;
        generate: (args: TypeOf<TInput>) => Promise<readonly PromptMessage[]>;
        input?: TInput;
        name: string;
        requiredScopes?: readonly string[];
    }

    Type Parameters

    Index

    Properties

    Optional callback for argument autocompletion.

    When provided, enables clients to request autocompletion suggestions for prompt arguments. The callback receives the argument name and current partial value, and returns matching suggestions.

    Requires input schema to be defined — prompt arguments are derived from the Zod schema fields. The SDK wraps each schema field with completable() internally.

    The prompt argument name being completed

    The current partial value typed by the user

    Completion suggestions

    definePrompt({
    name: 'summarize',
    input: z.object({ style: z.string() }),
    generate: async ({ style }) => [{ role: 'user', content: `Summarize in ${style}` }],
    complete: async (argName, argValue) => ({
    values: ['bullet-points', 'paragraph', 'tldr'].filter(s => s.startsWith(argValue)),
    }),
    });
    description: string

    Human-readable description shown to LLM

    generate: (args: TypeOf<TInput>) => Promise<readonly PromptMessage[]>

    Generate prompt messages.

    Type Declaration

    input?: TInput

    Zod object schema for argument validation.

    The SDK automatically extracts argument names, descriptions, and required status from the Zod schema. Use .describe() on fields to provide human-readable descriptions.

    input: z.object({
    topic: z.string().describe('The topic to explain'),
    depth: z.enum(['brief', 'detailed']).optional().describe('Level of detail'),
    })
    name: string

    Unique prompt name

    requiredScopes?: readonly string[]

    Scopes required to get this prompt (RBAC).

    When set, the framework checks authInfo.scopes BEFORE the generate handler executes. All listed scopes must be present (AND logic). If the check fails, a 403 Forbidden error is returned.

    Omit or set to undefined for prompts accessible to any authenticated user.