Skip to content

Prompts

A prompt is a message template a connected client invokes by name. Clients surface prompts directly to people — slash commands, menu entries — where tools are picked by the model.

definePrompt takes a name, title, description, a schema and a handler. input is a Zod Schema.

src/mcp.ts
import { definePrompt } from "@mcpexpress/core";
import { z } from "zod";
export const greet = definePrompt({
name: "greet",
title: "Greet someone",
description: "Have the assistant greet someone by name and welcome them.",
args: z.object({
name: z.string().min(1).describe("Who to greet, e.g. 'Ada'"),
}),
render: ({ name }) => `Use the say_hello tool to greet ${name}, then add one friendly sentence welcoming them.`,
});

Based on the above definition, MCP Express takes the prompt and advertises a prompt greet with one argument, name.