TsgcWSAPIServer_MCP › Events › OnMCPResponseSamplingCreateMessage
Receives the client’s reply to RequestSamplingCreateMessage with the generated message.
property OnMCPResponseSamplingCreateMessage: TsgcAI_MCP_Server_OnResponseSamplingCreateMessageEvent;
// TsgcAI_MCP_Server_OnResponseSamplingCreateMessageEvent = procedure(Sender: TObject; const aSession: TsgcAI_MCP_Session; const aRequest: TsgcAI_MCP_Request_SamplingCreateMessage; const aResponse: TsgcAI_MCP_Response_SamplingCreateMessage) of object
—
Raised when the client finishes handling a previous RequestSamplingCreateMessage call. aResponse.Result.Role and aResponse.Result.Content carry the generated turn, aResponse.Result.Model reports the LLM selected by the client and aResponse.Result.StopReason explains why generation ended (endTurn, maxTokens, stopSequence, etc.). Merge the result into the ongoing workflow — clients may refuse the request, in which case the response contains an error payload.
procedure TMainForm.MCPServerMCPResponseSamplingCreateMessage(Sender: TObject;
const aSession: TsgcAI_MCP_Session; const aRequest: TsgcAI_MCP_Request_SamplingCreateMessage;
const aResponse: TsgcAI_MCP_Response_SamplingCreateMessage);
begin
MemoLog.Lines.Add('sampling reply (' + aResponse.Result.Model + '): ' +
aResponse.Result.Content.AsText);
end;