Version 2025.10.0 of sgcWebSockets expands the AI integration toolkit with a commercial-grade MCP Client implementation that keeps your Delphi applications in lockstep with the Model Context Protocol 2025-06-18 specification. Deliver curated context, orchestrate tool calls and serve resource-aware assistants, all from a single component.
The Model Context Protocol (MCP) standardizes how assistants negotiate capabilities and exchange structured context. By adding MCP Client support, sgcWebSockets enables:
- Enterprise-grade interoperability with any MCP-compliant assistant, ensuring consistent initialization and capability discovery workflows.
- Faster time to market for AI-augmented experiences in existing VCL, FMX or WebBroker projects thanks to a drop-in Delphi component.
- Operational visibility across every JSON-RPC exchange through built-in HTTP logging and TLS 1.3 transport hardening.
Highlights of TsgcAI_MCP_Client
Turnkey MCP Handshake
Execute the protocol negotiation from a single Initialize call. The client advertises your product name, title and semantic version while honoring the session identifier returned by the server.
Rich Capability Surface
Issue ready-made method calls including Ping, ToolsList, ToolsCall, PromptsList, PromptsGet, ResourcesList and ResourcesRead. Every response type is strongly typed, making downstream processing effortless.
Event-driven Customization
Hook into granular events—initialization, ping, tool discovery, prompt retrieval and resource streaming—to trace and personalize every exchange before it reaches your business layer.
The component automatically increments JSON-RPC request identifiers, persists MCP session identifiers between calls, and raises typed exceptions when a remote error is returned. HTTP connectivity is encapsulated inside the specialized client that logs traffic and negotiates TLS 1.3 with OpenSSL 3.0 APIs.
Configuration Overview
- Client Profile: Configure
MCPOptions.ClientInfoto present your assistant-integrated solution with name, title and version metadata. - Server Endpoint: Set
MCPOptions.ServerOptions.URLto the MCP-compatible HTTPS endpoint you want to reach. - HTTP Stack: Built on
TsgcAI_MCP_HTTP_Client, the transport layer is tuned for JSON content types, automatic session headers and secure TLS defaults. - Observability Hooks: Subscribe to event handlers such as
OnMCPToolsCallorOnMCPResourcesReadto audit and enrich every protocol transition.
Delphi Integration Example
The snippet below illustrates how to drop the MCP Client onto a data module, initialize it during startup and serve a tool call response as soon as the remote assistant requests it.
uses
sgcAI_MCP_Client, sgcJSON;
procedure TdmMCP.StartMCP;
begin
sgcMCP := TsgcAI_MCP_Client.Create(Self);
sgcMCP.MCPOptions.ClientInfo.Name := 'sgc-demo-pos';
sgcMCP.MCPOptions.ClientInfo.Title := 'Smart POS Assistant';
sgcMCP.MCPOptions.ClientInfo.Version := '2025.10.0';
sgcMCP.MCPOptions.ServerOptions.URL := 'https://mcp.partnercloud.com';
sgcMCP.OnMCPInitialize := DoMCPInitialize;
sgcMCP.OnMCPToolsCall := DoMCPToolsCall;
sgcMCP.Initialize;
end;
procedure TdmMCP.DoMCPInitialize(Sender: TObject;
const Request: TsgcAI_MCP_Request_Initialize;
const Response: TsgcAI_MCP_Response_Initialize;
var Accept: Boolean);
begin
Accept := Response.ServerInfo.SupportsTools('inventory.lookup');
end;
procedure TdmMCP.DoMCPToolsCall(Sender: TObject;
const Request: TsgcAI_MCP_Request_ToolsCall;
const Response: TsgcAI_MCP_Response_ToolsCall);
var
ResultPayload: IsgcJSON;
begin
if Request.Params.Name = 'inventory.lookup' then
begin
ResultPayload := TsgcJSON.CreateObject;
ResultPayload['sku'] := Request.Params.Arguments['sku'];
ResultPayload['availability'] := 'in-stock';
Response.Result := ResultPayload;
end;
end;