React Native Requires Chilkat v11.6.0+
React Native
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 React Native Downloads
import { Mcp, Socket } from '@chilkat/react-native'
async function chilkatExample() {
const mcp = new 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.
const sock = new Socket();
sock.httpProxyHostname = 'proxy.example.com';
sock.httpProxyPort = 8080;
try {
mcp.setConnectionSettings(sock);
} catch {
console.log(mcp.lastErrorText);
return;
}
try {
await mcp.connectAsync('https://learn.microsoft.com/api/mcp');
} catch {
console.log(mcp.lastErrorText);
return;
}
console.log('Connected using the configured connection settings.');
}