Connects to a remote MCP server over stdio or HTTP and returns a client handle. The handshake runs at the connect call, so a bad command or URL fails where the developer is looking, rather than at the first tools() call somewhere else. The client declares no capabilities of its own, so it declines a server's sampling or elicitation request rather than leaving the server parked. A tool that reports failure throws an exception (type = "MCPToolError"); a tool with structured output returns that data directly.
mcpConnect( transport [, options] )
→ returns any
stdiohttpConnect to a filesystem server over stdio and call one of its tools.
client = mcpConnect(
transport = "stdio"
, command = "npx -y @modelcontextprotocol/server-filesystem /tmp"
);
tools = client.tools();
rows = client.call( "read_file", { path = "/tmp/notes.txt" } );
client.close();
Connect to a remote MCP server over HTTP with an authorization header, then list and call tools.
client = mcpConnect(
transport = "http"
, url = "https://example.com/mcp"
, headers = { Authorization = "Bearer #token#" }
);
tools = client.tools();
result = client.call( "search", { query = "invoices" } );
client.close();
Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.