TsgcWSAPIClient_MCP › Events › OnMCPInitialize
Fires when the server replies to the initialize handshake; inspect capabilities and set Accept := False to abort.
property OnMCPInitialize: TsgcAI_MCP_Client_OnInitializeEvent;
// TsgcAI_MCP_Client_OnInitializeEvent = procedure(Sender: TObject; const aRequest: TsgcAI_MCP_Request_Initialize; const aResponse: TsgcAI_MCP_Response_Initialize; var Accept: Boolean) of object
—
Raised by Initialize as soon as the server returns the initialize result but before the client posts the notifications/initialized notification. Inspect aResponse.Result.Capabilities to discover which MCP features the server offers (prompts, resources, tools, sampling, elicitation, logging) and aResponse.Result.ServerInfo for its Name, Title and Version. Set Accept := False to reject the session; Initialize will then return False and the component will leave Session at aimcpstUnknown.
procedure TMainForm.MCPInitialize(Sender: TObject;
const aRequest: TsgcAI_MCP_Request_Initialize;
const aResponse: TsgcAI_MCP_Response_Initialize;
var Accept: Boolean);
begin
Log('Server: ' + aResponse.Result.ServerInfo.Name + ' ' +
aResponse.Result.ServerInfo.Version);
Accept := aResponse.Result.Capabilities.Tools.Listed;
end;