TsgcWSAPIClient_MCP › Events › OnMCPInputRequired

OnMCPInputRequired Event

Fires when the server answers with input_required and the client must provide the requested inputs.

Syntax

property OnMCPInputRequired: TsgcAI_MCP_Client_OnInputRequiredEvent;
// TsgcAI_MCP_Client_OnInputRequiredEvent = procedure(Sender: TObject; const aMethod: string; const aInputRequests: TsgcAI_MCP_Client_InputRequests; var Accept: Boolean) of object

Default Value

—

Remarks

aMethod is the original method (tools/call, prompts/get or resources/read) or tasks/update for a task. Inputs of type roots, sampling and elicitation are first passed to OnMCPListRoots, OnMCPSamplingCreateMessage and OnMCPElicitationCreate when assigned. Accept is True when every input already has an answer. Fill the missing answers with SetResponse, SetElicitationAccept, SetElicitationDecline or SetRoots, and set Accept to False to stop the loop (the caller then receives the input_required response).

See Multi Round-Trip Requests.

Example

procedure TMainForm.MCPInputRequired(Sender: TObject; const aMethod: string;
  const aInputRequests: TsgcAI_MCP_Client_InputRequests; var Accept: Boolean);
var
  i: Integer;
begin
  for i := 0 to aInputRequests.Count - 1 do
    if aInputRequests.Methods[i] = 'elicitation/create' then
      aInputRequests.SetElicitationDecline(aInputRequests.Keys[i]);
  Accept := aInputRequests.IsCompleted;
end;

Back to Events