A prompt is a reusable, argument-driven conversation opener that an MCP
server publishes and a user picks — a slash command, an entry in a prompt
palette, a "summarize this" button. Unlike a tool, which the model chooses, a
prompt is chosen by a person, who fills in its declared arguments; the handler
then returns a short conversation that the client inserts into the chat.
TTMSMCPPrompt covers the whole surface: named and described prompts, required
and optional arguments, a fluent builder, display titles and icons, multi-turn
user/assistant message collections, runtime list changes with client
notifications, and argument-value completion.
Fluent builder for one argument, returned by AddArgument.
Minimal example
Register a prompt with the convenience methodPascalC++
procedure TForm1.RegisterSummarizePrompt;
var
Arg: TTMSMCPPromptArgument;
begin
{ Server is a TTMSMCPServer dropped on the form. }
Server.Prompts.RegisterPrompt('summarize_ticket',
'Asks the model to summarize a support ticket in three sentences',
function(const Args: array of TValue): TTMSMCPPromptMessages
begin
Result := TTMSMCPPromptMessages.Create(nil);
Result.AddUserMessage(Format(
'Summarize support ticket %s in three sentences.', [Args[0].AsString]));
end);
{ RegisterPrompt declares no arguments, so declare them separately -
the client needs them to build the prompts/get call. }
Arg := Server.Prompts.FindByName('summarize_ticket').Arguments.Add;
Arg.Name := 'ticket_id';
Arg.Description := 'Identifier of the ticket to summarize';
Arg.Required := True;
end;
// The anonymous method of the Delphi API is an interface in C++Builder.
class TSummarizeTicketHandler : public TCppInterfacedObject<TTMSMCPPromptMethod>
{
public:
TTMSMCPPromptMessages* __fastcall Invoke(const TValue *Args, const NativeInt Args_High)
{
TTMSMCPPromptMessages *Result = new TTMSMCPPromptMessages(nullptr);
Result->AddUserMessage(Format(
"Summarize support ticket %s in three sentences.", ARRAYOFCONST((TValue(Args[0]).AsString()))));
return Result;
}
};
void __fastcall TForm1::RegisterSummarizePrompt()
{
TTMSMCPPromptArgument *Arg;
// Server is a TTMSMCPServer dropped on the form.
Server->Prompts->RegisterPrompt("summarize_ticket",
"Asks the model to summarize a support ticket in three sentences",
_di_TTMSMCPPromptMethod(new TSummarizeTicketHandler()));
// RegisterPrompt declares no arguments, so declare them separately -
// the client needs them to build the prompts/get call.
Arg = Server->Prompts->FindByName("summarize_ticket")->Arguments->Add();
Arg->Name = "ticket_id";
Arg->Description = "Identifier of the ticket to summarize";
Arg->Required = true;
}