TsgcWSAPIClient_MCPEvents › OnMCPElicitationCreate

OnMCPElicitationCreate Event

Fires when the server asks the user for additional input (elicitation/create).

Syntax

property OnMCPElicitationCreate: TsgcAI_MCP_Client_OnElicitationCreateEvent;
// TsgcAI_MCP_Client_OnElicitationCreateEvent = procedure(Sender: TObject; const aRequest: TsgcAI_MCP_Request_ElicitationCreate; const aResponse: TsgcAI_MCP_Response_ElicitationCreate) of object

Default Value

Remarks

Server-initiated event: the server wants the host to collect structured information from the end user. aRequest.Params.Message is the prompt to display and aRequest.Params.RequestedSchema is the JSON Schema describing the expected answer shape. Present a form or dialog to the user, then fill aResponse.Result.Action (accept, decline, or cancel) and the matching aResponse.Result.Content payload before the handler returns. The component posts the reply to the server automatically.

Example

procedure TMainForm.MCPElicitationCreate(Sender: TObject;
  const aRequest: TsgcAI_MCP_Request_ElicitationCreate;
  const aResponse: TsgcAI_MCP_Response_ElicitationCreate);
var
  vInput: string;
begin
  if InputQuery('MCP server', aRequest.Params.Message, vInput) then
  begin
    aResponse.Result.Action := 'accept';
    aResponse.Result.Content.AddPair('value', vInput);
  end
  else
    aResponse.Result.Action := 'cancel';
end;

Back to Events