TsgcWSAPIClient_MCP › Methods › Initialize
Performs the MCP handshake and establishes the JSON-RPC session with the server.
function Initialize: Boolean;
True when the server accepts the handshake and the session has been fully negotiated; False when the request is refused or the OnMCPInitialize handler sets Accept := False. (Boolean)
Sends the JSON-RPC initialize request using the identity declared in MCPOptions.ClientInfo and the protocol version supported by the component. The OnMCPInitialize event is fired so the application can inspect server capabilities and optionally abort the handshake. When accepted, the client posts the notifications/initialized notification, stores the server session id, and transitions the Session property to aimcpstInitialized. Calling Initialize on an already initialised session re-uses it, which makes the call idempotent and safe to invoke before any catalogue or execution request.
MCP.MCPOptions.HttpOptions.URL := 'https://localhost:5001/mcp';
MCP.MCPOptions.ClientInfo.Name := 'DemoClient';
MCP.MCPOptions.ClientInfo.Version := '1.0.0';
if MCP.Initialize then
MCP.ListTools;