Sample code for 30+ languages & platforms
Xbase++ Requires Chilkat v11.6.0+

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 Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oMcp
LOCAL oSock

nSuccess := 0

oMcp := CreateObject("Chilkat.Mcp")

//  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.
oSock := CreateObject("Chilkat.Socket")
oSock:HttpProxyHostname := "proxy.example.com"
oSock:HttpProxyPort := 8080

nSuccess := oMcp:SetConnectionSettings(oSock)
IF (nSuccess == 0)
    ? oMcp:LastErrorText
    oMcp:destroy()
    oSock:destroy()
    RETURN
ENDIF

nSuccess := oMcp:Connect("https://learn.microsoft.com/api/mcp")
IF (nSuccess == 0)
    ? oMcp:LastErrorText
    oMcp:destroy()
    oSock:destroy()
    RETURN
ENDIF

? "Connected using the configured connection settings."

oMcp:destroy()
oSock:destroy()