Whatever message this page gives is out now! Go check it out!

Using MCP from ColdFusion

Last update:
May 18, 2026
Learn how to create and use an MCP client and server in ColdFusion.

Create your first MCP client

In ColdFusion, an MCP client is created using a configuration struct that defines how the client connects to a server and what capabilities it supports.

<cfscript>

configData = {

    transport: {
        type: "http",
        url: "http://localhost:8500/mcp/server.cfm"
    },

    clientInfo: {
        name: "quickstart-client",
        version: "1.0.0"
    },

    capabilities: {
        tools: true,
        prompts: true,
        resources: true
    },

    initializationTimeout: 10,
    requestTimeout: 30
};

mcpClient = MCPClient(configData);

</cfscript>
            
This creates a client instance that can discover and call MCP-exposed features.

Connecting to an MCP server over HTTP

HTTP is the most common transport for MCP in ColdFusion. It is used when:
  • The MCP server is remote or shared.
  • You want standard network controls and observability.
  • The server is exposed as a ColdFusion HTTP endpoint.
The MCP client automatically performs the MCP initialization handshake when created, exchanging server information and capabilities over HTTP.

Listing and calling a tool

List available tools

tools = mcpClient.listTools();
writeDump(tools);
                
Each tool includes its name, description, and input schema.
Call a tool

result = mcpClient.callTool(
    "get_weather",
    { location: "New York" }
);

writeDump(result);
                
Tool calls return structured results and include an isError flag when execution fails.

Creating a basic MCP server

An MCP server wraps ColdFusion components (CFCs), prompts, and resources so they can be consumed by MCP clients.
Servers are typically created once during application startup and stored in application scope.

configData = {

  serverInfo: {
    name: "My MCP Server",
    version: "1.0.0"
  },

  capabilities: {
    tools: true,
    prompts: true,
    resources: true
  }

};

application.mcpServer = MCPServer(configData);
            

Exposing a CFC as a tool

MCP tools are defined by exposing remote methods in CFCs.

component displayname="weatherTools" {

  remote struct function getWeather(required string city) {

    return {
      city: city,
      forecast: "Sunny"
    };

  }

}
            
Register the CFC with the MCP server:

configData.tools = [
  { cfc: "weatherTools" }
];

application.mcpServer = MCPServer(configData);
            
Rules enforced by MCP:
  • Only remote methods are exposed.
  • Function parameters become tool arguments.
  • Return values must be structs or simple types.
  • Tool names follow componentName.functionName.

Handling MCP requests over HTTP

To receive MCP requests, the server must expose an HTTP entry point that delegates to the MCP server.

application.mcpServer.handleRequest();
            

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page