Delphi ActiveX Requires Chilkat v11.6.0+
Delphi ActiveX
Configure MCP Connection Settings
See more MCP Client Examples
Demonstrates Mcp.SetConnectionSettings, which copies connection settings -- such as an HTTP proxy, SOCKS proxy, bind IP address, and TLS options -- from a Socket and applies them before connecting.
Background. This is optional; if not used, a direct connection is made. It is useful when the MCP server must be reached through a proxy or with specific TLS settings.
Chilkat Delphi ActiveX Downloads
var
success: Integer;
mcp: TChilkatMcp;
sock: TChilkatSocket;
begin
success := 0;
mcp := TChilkatMcp.Create(Self);
// Configure connection settings on a Socket -- such as an HTTP proxy, SOCKS proxy, bind IP address,
// or TLS options -- and apply them to the MCP client before connecting. This is optional; if not
// used, a direct connection is made.
sock := TChilkatSocket.Create(Self);
sock.HttpProxyHostname := 'proxy.example.com';
sock.HttpProxyPort := 8080;
success := mcp.SetConnectionSettings(sock.ControlInterface);
if (success = 0) then
begin
Memo1.Lines.Add(mcp.LastErrorText);
Exit;
end;
success := mcp.Connect('https://learn.microsoft.com/api/mcp');
if (success = 0) then
begin
Memo1.Lines.Add(mcp.LastErrorText);
Exit;
end;
Memo1.Lines.Add('Connected using the configured connection settings.');