TsgcWSAPIClient_MCP › Events › OnMCPStreamMessage
Fires while streaming responses are being read; inspect the raw JSON fragment and set Cancel := True to abort the stream.
property OnMCPStreamMessage: TsgcAI_MCP_Client_OnStreamMessageEvent;
// TsgcAI_MCP_Client_OnStreamMessageEvent = procedure(Sender: TObject; const aMessage: string; var Cancel: Boolean) of object
—
Raised once per chunk when the streamable HTTP/SSE transport is used (MCPOptions.Transport := aimcptrHttpStreamable). aMessage carries the raw JSON fragment exactly as emitted by the server, so you can display incremental output (for example tokens from a streaming tool call) before the full JSON-RPC response is assembled. Set Cancel to True to stop consuming the stream; the component will close the HTTP reader cleanly.
procedure TMainForm.MCPStreamMessage(Sender: TObject;
const aMessage: string; var aCancel: Boolean);
begin
if aMessage <> '' then
MemoStream.Lines.Add('chunk: ' + aMessage);
aCancel := UserAbortRequested;
end;