n8n主控服务器
一个主控程序服务器,提供针对n8n自动化项目的工作流验证工具和最佳实践,包括工作流管理、NextJS集成和API访问。
MCP 服务配置
复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用
{
"mcpServers": {
"n8n-mcp-server": {
"args": [
"/chemin/absolu/vers/mcp-n8n-server/dist/server.js"
],
"command": "node"
}
}
}
该服务需要配置环境变量:N8N_API_KEY、N8N_API_URL、PORT
服务介绍
n8n 的 MCP 服务器
该项目是一个用于 n8n 的 MCP(主控程序)服务器,它提供了工作流验证工具和最佳实践,以帮助您的 n8n 自动化项目。
功能
- 工作流验证:检查您的工作流是否遵循最佳实践
- 命名约定
- 错误处理
- 安全性
- 性能
- 文档
- NextJS 集成:为您的 n8n 工作流生成 NextJS 应用集成
- 自动生成 API 路由
- 创建 OpenAPI/Swagger 文档
- 生成 TypeScript 类型
- API 客户端以简化集成
- 工作流管理:与您的 n8n 工作流交互(列出、获取、创建、更新、删除、导出、导入)
- n8n API:直接访问 n8n API 进行高级操作
- 工作流模板:使用现成的模板适用于不同场景,包括 Google 日历
先决条件
- 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 一起使用,您需要配置 %APPDATA%/Claude/ 文件夹中的 claude_desktop_config.json 文件:
{
"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. N8nApiTool
直接与 n8n API 交互。
// Exemple d'utilisation
{
"method": "GET",
"endpoint": "/workflows",
"params": "?active=true"
}
2. WorkflowManagerTool
管理 n8n 工作流(列出、获取、创建、更新、删除、导出、导入)。
// Exemple d'utilisation
{
"action": "list",
"tags": "production"
}
3. NextJSIntegrationTool
为 n8n 工作流生成 NextJS 集成。
// Exemple d'utilisation
{
"workflowId": "123",
"outputDir": "./my-nextjs-app/pages/api",
"generateTypes": true,
"generateOpenAPI": true
}
4. WorkflowValidatorTool
根据不同的标准验证 n8n 工作流。
// Exemple d'utilisation
{
"workflow": "{...}",
"validators": ["naming", "errorHandling", "security"],
"strictness": "high"
}
贡献
欢迎贡献!请随时提出问题或拉取请求。
许可证
MIT