三句话,让 AI 为我生成工作流
安装
n8n-mcp-server
安装 n8n MCP Server
# Clone the repository
git clone https://github.com/leonardsellem/n8n-mcp-server.git
cd n8n-mcp-server
# Install dependencies
npm install
# Build the project
npm run build
# Optional: Install globally
npm install -g .
配置
获取 N8N_API_KEY
访问 n8n API 设置界面 http://localhost:5678/settings/api
创建 .env 文件
启动 server 时需要这个文件,使用支持 MCP 的客户端工具时不需要在要运行 n8n MCP Server 的目录下创建 .env 文件,替换其中的 N8N_API_KEY
# n8n MCP Server Environment Variables
# Required: URL of the n8n API (e.g., http://localhost:5678/api/v1)
N8N_API_URL=http://localhost:5678/api/v1
# Required: API key for authenticating with n8n
# Generate this in the n8n UI under Settings > API > API Keys
N8N_API_KEY=your_n8n_api_key_here
# Optional: Set to 'true' to enable debug logging
DEBUG=false
准备 JSON 文件
替换其中的 index.js
还有 API_URL
和 API KEY
{
"mcpServers": {
// Give your server a unique name
"n8n-local": {
// Use 'node' to execute the built JavaScript file
"command": "node",
// Provide the *absolute path* to the built index.js file
"args": [
"/path/to/your/cloned/n8n-mcp-server/build/index.js"
// On Windows, use double backslashes:
// "C:\\path\\to\\your\\cloned\\n8n-mcp-server\\build\\index.js"
],
// Environment variables needed by the server
"env": {
"N8N_API_URL": "http://your-n8n-instance:5678/api/v1", // Replace with your n8n URL
"N8N_API_KEY": "YOUR_N8N_API_KEY" // Replace with your key
// Add webhook credentials only if you plan to use webhook tools
// "N8N_WEBHOOK_USERNAME": "your_webhook_user",
// "N8N_WEBHOOK_PASSWORD": "your_webhook_password"
},
// Ensure the server is enabled
"disabled": false,
// Default autoApprove settings
"autoApprove": []
}
// ... other servers might be configured here
}
}
使用
添加 MCP 服务器
Cheery Studio 和 Trae 都可以很方便的从 JSON 文件添加 MCP
成功案例
Trae 提供了免费的 Claude 模型,将智能体切换到 Builder with MCP
,可以直接在聊天框中下达指令让 AI 执行
可以看到,Trae 成功地创建了工作流,美中不足的是最近使用 Trae 的人很多,迫于压力,总是需要排队等待
失败案例
在 Cherry Studio 中,我使用 deepseek 模型来配合执行,但在创建工作流时发生了错误。原因可能是生成的工作流 JSON 文件并不真实符合 n8n 的命名规范。如大家说的那样,目前最适合生成 n8n 工作流的大模型是 Claude。但是由于我暂时无法获得 Claude API 的额度,因此不知道 Cheery Studio 执行工作流生成任务具体的结果如何。但从使用场景以及频率上来说,Cheery Studio 确实比 Trae 更加方便。
References
[1] AI学长小林, 一键生成AI工作流:全自动N8N MCP,告别手动搭建 | N8N新手必备!
[2] 陶渊小明, [n8n走捷径! ] 3种方法!用AI快速生成n8n工作流,再也不用从0开始搭建!提效50%!
三句话,让 AI 为我生成工作流
http://guoguo.host/blog/p/b5e06517.html