mcpClient

Connects to a named MCP server declared in .cfconfig.json under mcpServers, using the same shape an editor's client config uses so a block can be pasted across without translation. Returns a client handle identical to the one from mcpConnect(). Resolving a name requires serve mode with a loaded configuration; in a CLI run with no configuration loaded, use mcpConnect() with an explicit command or url instead.

mcpClient( name ) → returns any

This function requires RustCFML.  Not supported on Lucee, Adobe ColdFusion, etc.

Argument Reference

name string
Required

The name of a server declared under mcpServers in .cfconfig.json.

Links more information about mcpClient

Examples
Sample code invoking the mcpClient function

Declare servers once in .cfconfig.json and reference them by name.

// .cfconfig.json
// {
//   "mcpServers": {
//     "files":  { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"] },
//     "remote": { "url": "https://example.com/mcp" }
//   }
// }

client = mcpClient( "files" );
tools  = client.tools();
client.close();

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub