Whatever message this page gives is out now! Go check it out!
configFile is passed and the configFile had multiple server configs, the method returns an array.MCPClient(configStruct)| Field | Data type | Required | Description |
|---|---|---|---|
transport | Struct | Yes | Describes how the client reaches one MCP server. HTTP transport: Use this when the MCP server is exposed over HTTP/streamable HTTP. |
transport = {
type = "http",
url = "https://remote.mcpservers.org/fetch/mcp"
}
stdio transport: Use this when the MCP server runs as a local process (Node/Python/Java/CF): |
transport = {
type : "stdio",
command : "/usr/local/bin/node",
args : [ "/path/to/server.js" ],
env = { apiKey : "skxxx" } // optional, server-specific
};
| |||
clientInfo | Struct | No | Identifies your MCP client to the server during initialization. |
clientInfo = {
name = "weather-MCP-Client",
version = "1.0.0"
};
| |||
capabilities | Struct | No | Tells the server which optional MCP features the client supports and intends to use. |
capabilities = {
sampling : true,
roots : true,
elicitation : false
};
| |||
initializationTimeout | Numeric | No | Maximum time to wait for the MCP to initialize handshake. (default: 10, max: 3600). |
initializationTimeout : 10; // secondsrequestTimeout | Numeric | No | Max time to wait for tool/resource/prompts calls. (default: 30, max: 3600). |
requestTimeout : 10; // secondsloggingConsumer | Function | No | Receives structured log events emitted by the MCP server. This is the primary hook for centralized logging of MCP server activity, debugging tool calls and resource reads, and building observability pipelines. |
function loggingConsumer(any messages) { ... }Whenever the server sends logs to the client, for example, on tool calls, errors, or general server events. This is especially useful in production to debug tool behavior without accessing server logs directly. | |||
samplingConsumer | Function | No | Receives events related to sampling, when the MCP client/server interacts with an LLM to generate intermediate completions or sampling-based operations. This is useful when you want to inspect intermediate prompts, log or audit how sampling is used. |
function samplingConsumer(array messages) { ... }messages is typically an array of sampling message objects, often including:
| |||
elicitationConsumer | Function | No | Handles elicitation events, interactive flows where the server requests additional input or clarifications (e.g., the system needs more user info to proceed). This is where you might present follow-up questions in a UI, capture additional form fields or user responses, and decide whether to continue or abort a workflow. |
function elicitationConsumer(array messages) { ... }Like samplingConsumer, messages is an array of elicitation messages (questions, prompts for input, etc.). | |||
toolsChangeConsumer | Function | No | Notified when the available tools change for that MCP client. This can happen if the MCP server hot-loads new tools, some tools are disabled/enabled at runtime, or a multi-tenant configuration changes your client's context. |
function toolsChangeConsumer(array tools) { ... }MCPClient(configData). The key difference from the single-server case is that your configData now references a config file that describes multiple servers, and MCPClient will return one client per server.| Field | Data type | Required | Description |
|---|---|---|---|
configFile | String | Yes | A file path (string) pointing to a JSON configuration file (for example, mcpServers.json). The JSON file describes one or more MCP servers, each with its own transport settings (type, url / command / args / env). |
clientInfo | Struct | No | When you use multiple MCP servers via MCPClient(configData) with a configFile, the clientInfo field in configData is a shared identity that is applied to each MCP client created from that config. |
clientInfo = {
name = "Healthcare-mcpclient",
version = "1.0.0"
};capabilities | Struct | No | When you configure multiple MCP servers via MCPClient(configData) with a configFile, the capabilities field in configData is a shared capabilities descriptor that applies to every MCP client created from that config. |
capabilities = {
sampling : true,
roots : true,
elicitation : false
};
| |||
initializationTimeout | Numeric | No | Same as that of a single MCP server. |
requestTimeout | Numeric | No | Same as that of a single MCP server. |
loggingConsumer | Function | No | Same as that of a single MCP server. |
samplingConsumer | Function | No | Same as that of a single MCP server. |
elicitationConsumer | Function | No | Same as that of a single MCP server. |
<cfscript>
transportConfig = {
"type" = "http",
"url" = "https://remote.mcpservers.org/fetch/mcp"
};
clientInfo = {
"name" : "cf-mcp-client",
"version" : "1.0.0"
};
capabilities = {
"sampling" : true,
"roots" : true,
"elicitation" : true
};
configData = {
"transport": transportConfig,
"clientInfo": clientInfo,
"capabilities": capabilities,
"initializationTimeout": 10,
"requestTimeout": 10,
samplingConsumer: function(messages) {
writeLog(file = "MCP_SAMPLING", text = serializeJSON(messages));
},
elicitationConsumer: function(messages) {
writeLog(file = "MCP_ELICITATION", text = serializeJSON(messages));
},
loggingConsumer: function(logEvent) {
var payload = structKeyExists(logEvent, "data") ? logEvent.data : logEvent;
writeLog(file = "MCP_LOGS", text = serializeJSON(payload));
},
toolsChangeConsumer: function(tools) {
application.mcpToolsCache = tools;
writeLog(file = "MCP_CHANGES", text = "Tools changed: " & arrayLen(tools));
}
};
clients = MCPClient(configData);
mcpClient = clients[1];
</cfscript><cfscript>
var configData = {
// Multi-server JSON descriptor
configFile: getDirectoryFromPath(getCurrentTemplatePath()) & "mcpServers.json",
// Shared client identity for all MCP servers in the file
clientInfo: {
name : "Healthcare-mcp-client",
version : "1.0.0"
},
// Shared capabilities
capabilities: {
sampling : true,
roots : true,
elicitation : false
},
// Shared timeouts
initializationTimeout : 50,
requestTimeout : 50,
// Optional shared consumers
samplingConsumer: function(messages) {
writeLog(file = "MCP_SAMPLING", text = serializeJSON(messages));
},
elicitationConsumer: function(messages) {
application.lastElicitation = messages;
writeLog(file = "MCP_ELICITATION", text = serializeJSON(messages));
},
loggingConsumer: function(logEvent) {
var payload = structKeyExists(logEvent, "data") ? logEvent.data : logEvent;
writeLog(file = "MCP_LOGS", text = "MCP log: " & serializeJSON(payload));
},
toolsChangeConsumer: function(tools) {
writeLog(file = "MCP_CHANGES",
text = "Tools changed. Count: " & arrayLen(tools));
},
resourcesChangeConsumer: function(resources) {
writeLog(file = "MCP_CHANGES",
text = "Resources changed. Count: " & arrayLen(resources));
}
};
// Create one client per server defined in mcpServers.json
var clients = MCPClient(configData);
application.mcpClients = clients; // store for later use
</cfscript>