使用说明
N8N的MCP服务器
该项目是N8n的主控制程序(MCP)服务器,为您的N8n自动化项目提供工作流验证工具和最佳实践。
功能
- 验证工作流程 :检查您的工作流是否符合最佳实践
- 治安公约
- 错误管理
- 安全
- 演出
- 文档
- NextJS集成 :为NextJS应用程序中的N8N工作流生成集成
- 自动生成API路由
- 创建OpenAPI/Swagger文档
- 生成TypeScript类型
- API客户端,便于集成
- 工作流管理 :与N8N工作流交互(列表、恢复、创建、更新、删除、导出、导入)
- API n8n :直接访问N8N API进行高级操作
- 工作流模板 :为不同的用例使用现成的模板,包括谷歌日历
Prérequis
- Node.js(v16高级版)
- PNPM(V7或更高版本)
- N8n实例(本地或远程,如n8n.bienquoi.com上的Cloudron实例)
安装
- 克隆此存储库或导航到项目文件夹
- 安装依赖项:
pnpm install
- 配置环境变量:
cp .env.example .env
编辑文件 .env 使用您的N8N API登录信息。
使用
项目施工
pnpm build
启动服务器
pnpm start
MCP服务器将可在以下地址访问:http://localhost:3000(或.env文件中指定的端口)。
与Claude Desktop一起使用
要将此MCP服务器与Claude Desktop一起使用,您需要配置文件 claude_desktop_config.json 在文件中 %APPDATA%/Claude/ :
{
"mcpServers": {
"n8n-mcp-server": {
"command": "node",
"args": ["/chemin/absolu/vers/mcp-n8n-server/dist/server.js"]
}
}
}
项目结构
mcp-n8n-server/
├── src/ # Code source
│ ├── tools/ # Outils MCP
│ │ ├── N8nApiTool.ts # Outil pour interagir avec l'API n8n
│ │ ├── WorkflowManagerTool.ts # Outil pour gérer les workflows
│ │ ├── NextJSIntegrationTool.ts # Outil pour générer des intégrations NextJS
│ │ ├── WorkflowValidatorTool.ts # Outil pour valider les workflows
│ │ └── ...
│ ├── validators/ # Validateurs de workflows
│ │ ├── naming.js # Validateur de conventions de nommage
│ │ ├── errorHandling.js # Validateur de gestion des erreurs
│ │ ├── security.js # Validateur de sécurité
│ │ ├── performance.js # Validateur de performance
│ │ └── documentation.js # Validateur de documentation
│ ├── resources/ # Ressources partagées
│ └── server.ts # Point d'entrée du serveur
├── dist/ # Code compilé
├── public/ # Fichiers statiques
├── output/ # Répertoire pour les sorties des outils
├── .env.example # Exemple de fichier de configuration
└── README.md # Documentation
可用工具
1. N8nApi工具
直接与N8N API交互。
// Exemple d'utilisation
{
"method": "GET",
"endpoint": "/workflows",
"params": "?active=true"
}
2.工作流管理器工具
管理N8N工作流(列表、检索、创建、更新、删除、导出、导入)。
// Exemple d'utilisation
{
"action": "list",
"tags": "production"
}
3.下一个JSIntegration工具
为N8N工作流生成NextJS集成。
// Exemple d'utilisation
{
"workflowId": "123",
"outputDir": "./my-nextjs-app/pages/api",
"generateTypes": true,
"generateOpenAPI": true
}
4.工作流验证工具
根据不同标准验证N8N工作流。
// Exemple d'utilisation
{
"workflow": "{...}",
"validators": ["naming", "errorHandling", "security"],
"strictness": "high"
}
贡献
欢迎捐款!不要犹豫打开问题或拉取请求。
许可证
麻省理工学院
