光标n8n MCP服务器
 ](https://nodejs.org/)
模型上下文协议(MCP)服务器,使Cursor IDE中的AI助手能够通过n8n REST API管理n8n工作流。
特性
- 工作流管理:创建、更新、删除和列出工作流
- 工作流激活:激活和停用工作流
- 执行管理:查看执行历史和详细信息
- Webhook触发:通过webhook URL触发工作流
- 自我记录:内置AI助手帮助系统
- 节点信息:常见的n8n节点类型和配置
- 错误处理:使用指数回退自动重试
快速开始
安装
git clone https://github.com/alicankiraz1/cursor-n8n-mcp.git
cd cursor-n8n-mcp
npm install
npm run build
node dist/index.js setup或者使用安装脚本:
./install.sh手动配置
创建或编辑 ~/.cursor/mcp.json 对于全局配置:
{
"mcpServers": {
"cursor-n8n-mcp": {
"command": "node",
"args": ["/path/to/cursor-n8n-mcp/dist/index.js"],
"env": {
"MCP_MODE": "stdio",
"LOG_LEVEL": "error",
"N8N_API_URL": "https://your-n8n-instance.com",
"N8N_API_KEY": "your-api-key"
}
}
}
}获取n8n API密钥
- 登录您的n8n实例
- 首选 设置 > API
- 点击 创建API密钥
- 复制生成的密钥
可用工具
文档和帮助
| 工具 | 说明 |
|---|---|
n8n_tools_help | 获取使用指南和文档 |
n8n_get_node_info | 获取有关常见n8n节点的信息 |
工作流管理
| 工具 | 说明 |
|---|---|
n8n_list_workflows | 列出所有工作流 |
n8n_get_workflow | 按ID获取工作流详细信息 |
n8n_create_workflow | 创建新工作流 |
n8n_update_workflow | 更新现有工作流 |
n8n_delete_workflow | 删除工作流 |
n8n_activate_workflow | 激活工作流 |
n8n_deactivate_workflow | 停用工作流 |
执行管理
| 工具 | 说明 |
|---|---|
n8n_list_executions | 列出执行历史记录 |
n8n_get_execution | 获取执行详细信息 |
n8n_delete_execution | 删除执行记录 |
n8n_trigger_webhook | 通过webhook触发工作流 |
系统
| 工具 | 说明 |
|---|---|
n8n_health_check | 检查n8n API连接 |
使用示例
检查连接
"Check the n8n connection"列出工作流
"List all workflows in n8n"创建工作流
"Create a webhook workflow that responds with the received data"获取节点信息
"Show me how to configure a webhook node"CLI命令
node dist/index.js --help # Show help
node dist/index.js setup # Interactive setup
node dist/index.js config # Show configuration template项目结构
cursor-n8n-mcp/
├── src/
│ ├── index.ts # Entry point with CLI
│ ├── server.ts # MCP Server implementation
│ ├── tools/
│ │ ├── index.ts # Tool exports
│ │ ├── workflow-tools.ts # Workflow CRUD operations
│ │ ├── execution-tools.ts# Execution management
│ │ └── documentation-tools.ts # Help and node info
│ ├── services/
│ │ └── n8n-api-client.ts # n8n REST API client
│ ├── types/
│ │ └── index.ts # TypeScript definitions
│ └── utils/
│ ├── logger.ts # Logging utility
│ └── errors.ts # Error handling
├── package.json
├── tsconfig.json
├── LICENSE
└── README.md支持的节点类型
这 n8n_get_node_info 工具提供有关这些常见节点的信息:
- 触发器:webhook、scheduleTrigger、手动触发器
- 行动:httpRequest、code、set、if、merge
- 公用事业:splitInBatches,响应Webhook
错误处理
服务器包括强大的错误处理功能:
- 自动重试:失败的请求最多重试3次
- 指数退避:重试之间的延迟增加
- 详细错误:错误消息包括解决提示
- 超时管理:API请求超时30秒
环境变量
| 变量 | 描述 | 必填 |
|---|---|---|
N8N_API_URL | 您的n8n实例URL | 是 |
N8N_API_KEY | n8n API密钥 | 是 |
LOG_LEVEL | 日志级别(调试、信息、警告、错误) | 否 |
MCP_MODE | MCP传输模式(stdio) | 否 |
贡献
欢迎投稿!请随时提交拉取请求。
- 复刻仓库
- 创建功能分支(
git checkout -b feature/amazing-feature) - 提交您的更改(
git commit -m 'Add some amazing feature') - 推到分支(
git push origin feature/amazing-feature) - 打开拉取请求
许可证
此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。
