n8n MCP Server

by leonardsellem
Verified

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Integrations

  • Uses .env files for configuration of the MCP server, allowing setting of n8n API URL, API key, and debug options.

  • Used for cloning the repository during source installation of the MCP server.

  • Provides access to the source code repository for manual installation and development of the MCP server.

n8n MCP 服务器

模型上下文协议 (MCP) 服务器允许 AI 助手通过自然语言与 n8n 工作流进行交互。

概述

该 MCP 服务器为 AI 助手提供工具和资源,用于管理 n8n 工作流程和执行。它允许助手:

  • 列出、创建、更新和删除工作流
  • 激活和停用工作流程
  • 执行工作流程并监控其状态
  • 访问工作流程信息和执行统计数据

安装

先决条件

  • Node.js 18 或更高版本
  • 启用 API 访问的 n8n 实例

从 npm 安装

npm install -g 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 .

配置

在运行服务器的目录中创建一个.env文件,使用.env.example作为模板:

cp .env.example .env

配置以下环境变量:

多变的描述例子
N8N_API_URLn8n API 的完整 URL,包括/api/v1http://localhost:5678/api/v1
N8N_API_KEY用于使用 n8n 进行身份验证的 API 密钥n8n_api_...
N8N_WEBHOOK_USERNAMEWebhook 身份验证的用户名(如果使用 Webhook)username
N8N_WEBHOOK_PASSWORDWebhook 身份验证的密码password
DEBUG启用调试日志记录(可选)truefalse

生成 n8n API 密钥

  1. 在浏览器中打开您的 n8n 实例
  2. 前往“设置”>“API”>“API 密钥”
  3. 创建具有适当权限的新 API 密钥
  4. 将密钥复制到你的.env文件

用法

运行服务器

从安装目录:

n8n-mcp-server

或者如果全局安装:

n8n-mcp-server

与人工智能助手集成

构建服务器( npm run build )后,你需要配置你的 AI 助手(例如带有 Claude 扩展的 VS Code 或 Claude 桌面应用)来运行它。这通常需要编辑 JSON 配置文件。

示例配置(例如,在 VS Code settings.json或 Claude Desktop claude_desktop_config.json中):

{ "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 } }

要点:

  • /path/to/your/cloned/n8n-mcp-server/替换为您克隆和构建存储库的实际绝对路径。
  • 使用适合您操作系统的正确路径分隔符(macOS/Linux 使用正斜杠/ ,Windows 使用双反斜杠\\ )。
  • 确保您提供正确的N8N_API_URL (包括/api/v1 )和N8N_API_KEY
  • 需要先构建服务器( npm run build ),然后助手才能运行build/index.js文件。

可用工具

该服务器提供以下工具:

使用 Webhook

此 MCP 服务器支持通过 n8n webhook 执行工作流。使用此功能的步骤如下:

  1. 在 n8n 中创建一个由 webhook 触发的工作流。
  2. 在您的 webhook 节点上设置基本身份验证。
  3. 使用run_webhook工具来触发工作流,只需传递工作流名称。

例子:

const result = await useRunWebhook({ workflowName: "hello-world", // Will call <n8n-url>/webhook/hello-world data: { prompt: "Hello from AI assistant!" } });

使用N8N_WEBHOOK_USERNAMEN8N_WEBHOOK_PASSWORD环境变量自动处理 webhook 身份验证。

工作流管理

  • workflow_list :列出所有工作流程
  • workflow_get :获取特定工作流程的详细信息
  • workflow_create :创建一个新的工作流程
  • workflow_update :更新现有工作流程
  • workflow_delete :删除工作流程
  • workflow_activate :激活工作流程
  • workflow_deactivate :停用工作流程

执行管理

  • execution_run :通过 API 执行工作流
  • run_webhook :通过 webhook 执行工作流
  • execution_get :获取特定执行的详细信息
  • execution_list :列出工作流程的执行
  • execution_stop :停止正在运行的执行

资源

服务器提供以下资源:

  • n8n://workflows/list :所有工作流程的列表
  • n8n://workflow/{id} :特定工作流的详细信息
  • n8n://executions/{workflowId} :工作流的执行列表
  • n8n://execution/{id} :特定执行的详细信息

发展

建筑

npm run build

以开发模式运行

npm run dev

测试

npm test

代码检查

npm run lint

执照

麻省理工学院

-
security - not tested
F
license - not found
-
quality - not tested

模型上下文协议服务器,使 AI 助手能够通过自然语言与 n8n 工作流交互,支持列出、创建、更新、执行和监控工作流等操作。

  1. Overview
    1. Installation
      1. Prerequisites
      2. Install from npm
      3. Install from source
    2. Configuration
      1. Generating an n8n API Key
    3. Usage
      1. Running the Server
      2. Integrating with AI Assistants
    4. Available Tools
      1. Using Webhooks
      2. Workflow Management
      3. Execution Management
    5. Resources
      1. Development
        1. Building
        2. Running in Development Mode
        3. Testing
        4. Linting
      2. License
        ID: bysl8wgg6t