Whatever message this page gives is out now! Go check it out!
transport = mcpTransportBuilder("http")
.url("https://remote.mcpservers.org/fetch/mcp")
.header("Authorization", "Bearer #application.mcpAuthToken#")
.build();
transport = mcpTransportBuilder("stdio")
.command("/usr/local/bin/node")
.args(["/path/to/server.js"])
.environment({ apiKey: "sk-xxx" })
.build();
mcpClient = mcpClientBuilder()
.transport(transport)
.capabilities({
tools : true,
prompts : true,
resources : true
})
.build();
public any function getMcpClient() {
// Could be per-request, per-session, or cached with a timeout
var transport = mcpTransportBuilder("http")
.url(application.mcpEndpointUrl)
.header("Authorization", "Bearer #application.mcpAuthToken#")
.build();
var client = mcpClientBuilder()
.transport(transport)
.capabilities({ tools: true, prompts: true, resources: true })
.build();
client.initialize({
protocolVersion: "2025-03-26",
clientInfo: {
name : "cf-app",
version : "1.0.0"
}
});
return client;
}
initialize) is usually handled under the hood by the client builder; if not, make sure you call it exactly once per client before listing or calling tools. application.mcpServer is your server instance.
function getLocalMcpClient() {
if (!structKeyExists(application, "mcpServer")) {
throw(type="MCP.NotInitialized", message="MCP server not initialized.");
}
var transport = mcpTransportBuilder("local")
.server(application.mcpServer)
.build();
var client = mcpClientBuilder()
.transport(transport)
.capabilities({ tools: true, prompts: true, resources: true })
.build();
client.initialize({
protocolVersion: "2025-03-26",
clientInfo: {
name : "cf-local-client",
version : "1.0.0"
}
});
return client;
}
getMcpClient(), calling tools becomes straightforward:
function getWeatherForCity(required string city) {
var client = getMcpClient();
var response = client.tools.call(
name = "getWeather",
arguments = { city = city }
);
if (response.isError) {
// Handle tool-level error
writeLog(file="mcp", type="error", text="getWeather error: #response.errorMessage#");
throw(type="MCP.ToolError", message=response.errorMessage);
}
return response.content[1].text;
}