TsgcWSAPIClient_MCPEvents › OnMCPInitialize

OnMCPInitialize Event

Fires when the server replies to the initialize handshake; inspect capabilities and set Accept := False to abort.

Syntax

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

Default Value

Remarks

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.

Example

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;

Back to Events