TsgcWSAPIClient_MCP › Events › OnMCPResponseResource
Delivers the payload returned by resources/read, including streamed chunks.
property OnMCPResponseResource: TsgcAI_MCP_Client_OnResponseResourceEvent;
// TsgcAI_MCP_Client_OnResponseResourceEvent = procedure(Sender: TObject; const aRequest: TsgcAI_MCP_Request_ResourcesRead; const aResponse: TsgcAI_MCP_Response_ResourcesRead) of object
—
Triggered when the server replies to RequestResource. aResponse.Result.Contents carries one or more entries; each exposes either a text body (Text) or Base64-encoded binary data (Blob) together with the MIME type. When MCPOptions.Transport is aimcptrHttpStreamable this event fires once per assembled resource, while individual chunks continue to flow through OnMCPStreamMessage.
procedure TMainForm.MCPResponseResource(Sender: TObject;
const aRequest: TsgcAI_MCP_Request_ResourcesRead;
const aResponse: TsgcAI_MCP_Response_ResourcesRead);
begin
if aResponse.Result.Contents.Count > 0 then
SaveToFile(aResponse.Result.Contents[0].Text, 'payload.bin');
end;