MCPCFC——世界上第一台ColdFusion MCP服务器
你的ColdFusion应用程序现在可以与人工智能对话。人工智能可以使用你的CF工具。
MCPCFC将Adobe ColdFusion连接到Claude、ChatGPT、Cursor、VS Code和任何其他支持 模型上下文协议。它将您现有的CFML代码转换为AI可调用工具,无需重写。
有生成发票的ColdFusion功能吗?现在这是一个MCP工具。一个查询你专有数据库的人?工具。启动内部工作流程?工具。如果ColdFusion可以做到这一点,AI可以调用它。
┌─────────────┐ ┌──────────────┐ ┌──────────────────┐
│ Claude / │─────▶│ MCPCFC │─────▶│ Your CF App │
│ ChatGPT / │◀─────│ MCP Server │◀─────│ & Business Logic│
│ Cursor │ └──────────────┘ └──────────────────┘
└─────────────┘ JSON-RPC 2.0 PDF, Email, DB,
+ Stdio Bridge Files, HTTP, ...为什么这很重要
数以百万计的ColdFusion产品线仍在生产中,遍布全球的政府机构、金融机构、医疗保健系统和企业。该代码有效。但它越来越与重塑人们工作方式的人工智能工具隔离开来。
MCPCFC弥合了这一差距。与其用Python或TypeScript重写CF业务逻辑,不如将其包装为MCP工具,让AI助手直接调用它。你的遗留代码库一夜之间就变成了与人工智能相关的资产。
这是给谁的:
- 企业团队 坐在多年的CF业务逻辑上,他们希望在不重写的情况下实现人工智能功能
- 政府机构 逐步实现传统CF系统的现代化
- CF开发人员 谁想在现有的基础上构建下一代智能应用程序
- 数字化转型领导者 寻找从传统到尖端的低风险路径
包含什么
MCPCFC附带了六个概念验证工具,用于演示该模式:
| 工具 | 它做什么 |
|---|---|
hello | 简单的问候语——可用于验证连接 |
fileOperations | 沙盒文件I/O(read, write, list, delete, exists, info) |
httpRequest | 出站HTTP请求(阻止私有/内部IP) |
pdf | 使用ColdFusion的内置PDF引擎生成、提取文本和合并PDF |
queryDatabase | 已验证的只读SQL查询(SELECT 仅) |
sendEmail | 通过SendGrid发送电子邮件(需要 SENDGRID_API_KEY) |
这些都是故意简单的。真正的力量在于添加自己的工具——参见 添加自定义工具 在......下面
测试环境
- ✅ macOS+Adobe ColdFusion 2025
- ⚠️ 尚未在Windows/Linux或其他CFML引擎(Lucee、BoxLang等)上进行测试
快速开始
选项1:浏览器测试客户端
- 将此仓库克隆到您的ColdFusion web根目录中(或将其符号链接)。
- 访问:
http://localhost:8500/mcpcfc/client-examples/test-client.cfm - 点击 连接 → 列出工具 → 呼叫问候工具.
选项2:克劳德桌面(本地stdio)
Claude Desktop通过stdio与本地MCP服务器进行通信。MCPCFC是基于HTTP的,因此它附带了一个在两者之间进行转换的桥接脚本。
编辑 ~/Library/Application Support/Claude/claude_desktop_config.json (macOS):
{
"mcpServers": {
"coldfusion-mcp": {
"command": "/absolute/path/to/mcpcfc/bridge/cf-mcp-bridge.sh",
"env": {
"MCPCFC_URL": "http://localhost:8500/mcpcfc"
}
}
}
}然后 完全退出并重新启动 克劳德桌面。
选项3:远程/流式HTTP
MCPCFC还支持来自以下任何MCP客户端的直接HTTP连接:
BASE_URL/endpoints/mcp.cfm有关Claude Code、ChatGPT、Codex、Cursor、VS Code、Zed、Kimi和Antigravity的复制粘贴配置,请参阅 CLIENTS.md.
添加自定义工具
这就是MCPCFC成为你的地方。每个工具都是ColdFusion组件(.cfc)延伸 AbstractTool基类为您提供输入验证、结构化结果帮助程序和MCP协议的自动注册。你编写业务逻辑;MCPCFC负责管道。
图案
每个工具都遵循三个步骤:
- 创建
.cfc文件 在core/tools/延伸AbstractTool - 定义工具 在
init()--名称、描述和输入模式 - 注册它 通过添加一行
MCPServer.cfc
就是这样。让我们来看一个完整的例子。
示例:构建a WeatherTool
说你想让你的人工智能助手能够通过外部API检查天气。以下是完整的工具:
第一步——创建 core/tools/WeatherTool.cfc:
/**
* WeatherTool.cfc
* Returns current weather for a given city
*/
component extends="AbstractTool" output="false" {
public function init() {
// 1. Identity — how the tool appears in MCP
setName("getWeather");
setTitle("Get Weather");
setDescription("Returns current weather conditions for a given city name.");
// 2. Input schema — tells the AI what parameters to send
var inputSchema = structNew("ordered");
inputSchema["type"] = "object";
inputSchema["properties"] = structNew("ordered");
var citySchema = structNew("ordered");
citySchema["type"] = "string";
citySchema["description"] = "City name (e.g., 'Pittsburgh', 'New York')";
inputSchema.properties["city"] = citySchema;
inputSchema["required"] = ["city"];
setInputSchema(inputSchema);
return this;
}
public struct function execute(required struct toolArgs) {
// Validate the required parameter exists
validateRequired(arguments.toolArgs, ["city"]);
var city = trim(arguments.toolArgs.city);
logExecution("Weather requested", { city: city });
try {
// Call an external weather API
var apiUrl = "https://wttr.in/#encodeForURL(city)#?format=j1";
var httpService = new http(method="GET", url=apiUrl, timeout=10);
var response = httpService.send().getPrefix();
if (response.statusCode contains "200") {
var data = deserializeJson(response.fileContent);
var current = data.current_condition[1];
var result = {
"city": city,
"temperature_f": current.temp_F,
"temperature_c": current.temp_C,
"condition": current.weatherDesc[1].value,
"humidity": current.humidity & "%",
"wind_mph": current.windspeedMiles
};
// Return structured JSON — the AI will interpret it
return jsonResult(result);
} else {
return errorResult("Weather API returned status: #response.statusCode#");
}
} catch (any e) {
return errorResult("Failed to fetch weather: #e.message#");
}
}
}步骤2--在中注册 core/MCPServer.cfc:
打开 core/MCPServer.cfc 并将您的工具类添加到 toolClasses 数组中 registerDefaultTools() 方法:
var toolClasses = [
"core.tools.HelloTool",
"core.tools.PDFTool",
"core.tools.SendGridEmailTool",
"core.tools.DatabaseTool",
"core.tools.FileTool",
"core.tools.HttpClientTool",
"core.tools.WeatherTool" // <-- add your tool here
];步骤3——重启并测试:
重新启动ColdFusion应用程序(请访问 restart-app.cfm 或重新启动CF服务),然后重新启动MCP客户端。您的新工具将出现在工具列表中,AI可以立即调用它。
基类给你什么
AbstractTool.cfc 提供辅助方法,以便您可以专注于业务逻辑:
| 方法 | 目的 |
|---|---|
textResult(string) | 返回纯文本响应 |
jsonResult(data) | 返回结构化JSON数据 |
errorResult(message) | 返回错误 isError 旗帜 |
imageResult(base64Data, mimeType) | 返回base64编码的图像 |
resourceResult(uri, text, mimeType) | 返回嵌入式MCP资源 |
validateRequired(args, paramArray) | 如果缺少必需的参数,则抛出 |
validateTypes(args, typeMap) | 验证参数类型(字符串、数字、布尔值、数组、结构) |
getParam(args, name, default) | 获取具有回退默认值的参数 |
logExecution(message, data) | 记录工具活动(如果配置了记录器) |
现实世界的工具创意
一旦你理解了这种模式,想想ColdFusion在你的组织中已经做得很好的地方:
- 发票生成器 --包装你现有的
cfpdf报告逻辑 - 客户查找 --查询您的CRM数据库并将结果返回给AI
- 文档转换器 --利用CF内置的Word/Excel/PDF功能
- 电子邮件起草人 --通过现有的邮件基础架构进行撰写和发送
- 报告运行程序 --执行存储过程并返回格式化结果
- 文件处理器 --解析上传的CSV,转换数据,写入输出
- 传统API包装 --将SOAP服务或内部REST端点暴露给AI
每一个都是一个 .cfc 文件和一行注册。
冒烟测试
Stdio(建议用于Claude Desktop)
MCPCFC_URL="http://localhost:8500/mcpcfc" ./scripts/verify-stdio.sh流式HTTP(用于远程客户端)
MCPCFC_URL="http://localhost:8500/mcpcfc" ./scripts/verify-http.sh配置
编辑 config/settings.cfm 自定义:
protocolVersion(默认值:2025-06-18)defaultDatasource(默认值:mcpcfc_ds)- 文件沙盒路径和大小限制
- CORS设置
数据库设置(可选)
这 queryDatabase 工具需要一个名为的ColdFusion数据源 mcpcfc_ds:
- 在ColdFusion Administrator中配置数据源
- 通过访问加载示例架构
database-setup.cfm在浏览器中,或导入mcpcfc_db.sqlMySQL/MariaDB
调试
- Claude Desktop MCP日志(macOS):
~/Library/Logs/Claude/mcp-server-coldfusion-mcp.log - 网桥调试模式: 集
MCPCFC_DEBUG=1在env配置块 - 自签名HTTPS: 集
MCPCFC_INSECURE=1如果使用不受信任的本地证书
安全警告
MCPCFC是一个强大的远程控制界面——它可以访问文件系统、发出HTTP请求、查询数据库、发送电子邮件和生成文档。 在没有以下条件的情况下,不要公开披露:
- 认证
- 严格的CORS/原产地限制
- 速率限制
- 逐个工具授权和沙盒
项目布局
Application.cfc
bridge/
cf-mcp-bridge.sh # Stdio ⇄ HTTP bridge for Claude Desktop
client-examples/
test-client.cfm # Browser-based test interface
config/
routes.cfm
settings.cfm # Server configuration
core/
CapabilityManager.cfc
JSONRPCHandler.cfc
MCPServer.cfc # Tool registration happens here
TransportManager.cfc
tools/
AbstractTool.cfc # Base class — extend this for custom tools
DatabaseTool.cfc
FileTool.cfc
HelloTool.cfc # Good reference for new tools
HttpClientTool.cfc
PDFTool.cfc
SendGridEmailTool.cfc
endpoints/
mcp.cfm # Unified MCP endpoint (JSON-RPC 2.0)
logging/
registry/
session/
scripts/
verify-stdio.sh
verify-http.sh贡献
看 贡献.md 作为指导方针。
许可证
MIT。看 许可证.
______________________________________________________________________
由ColdFusion 2025制造 @旋转烟雾.欢迎捐款。
