Sample code for 30+ languages & platforms
Lua 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 Lua Downloads

Lua
local chilkat = require("chilkat")

local mcp = chilkat.Mcp.new()

-- 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.
local sock = chilkat.Socket.new()
sock.http_proxy_hostname = "proxy.example.com"
sock.http_proxy_port = 8080

local success = mcp:set_connection_settings(sock)
if not success then
    print(mcp.last_error_text)
    return
end

success = mcp:connect("https://learn.microsoft.com/api/mcp")
if not success then
    print(mcp.last_error_text)
    return
end

print("Connected using the configured connection settings.")