访问 n8n MCP 服务器#
¥Accessing n8n MCP server
通过 n8n 内置的 MCP 服务器,将受支持的 MCP 客户端连接到你的 n8n 工作流。
¥Connect supported MCP clients to your n8n workflows through n8n's built-in MCP server.
服务器允许 Lovable 或 Claude Desktop 等客户端安全地连接到 n8n 实例。连接后,这些客户端可以:
¥The server allows clients such as Lovable or Claude Desktop to connect securely to an n8n instance. Once connected, these clients can:
- 在 MCP 中标记为可用的工作流中搜索。
¥Search within workflows marked as available in MCP
- 检索工作流的元数据和触发信息。
¥Retrieve metadata and trigger information for workflows
- 触发并运行已公开的工作流
¥Trigger and run exposed workflows
实例级 MCP 访问和 MCP 服务器触发器的区别节点#
¥Difference between instance-level MCP access and MCP Server Trigger node
实例级 MCP 访问权限允许你为每个 n8n 实例创建一个连接,使用集中式身份验证,并选择要启用访问权限的工作流。启用后的工作流易于查找和运行,无需为每个工作流进行额外设置。
¥Instance-level MCP access lets you create one connection per n8n instance, use centralized authentication, and choose which workflows to enable for access. Enabled workflows are easy to find and run without extra setup for each workflow.
相比之下,你可以在单个工作流中配置 MCP 服务器触发节点。此节点仅公开该工作流中的工具,当你希望在一个工作流中构建特定的 MCP 服务器行为时,这是一种有用的方法。
¥In comparison, you configure an MCP Server Trigger node inside a single workflow. This node exposes tools only from that workflow, a useful approach when you want to craft a specific MCP server behavior within one workflow.
使用实例级 MCP 访问时的关键注意事项#
¥Key considerations when using instance-level MCP access
- 它不是从 AI 客户端构建或编辑工作流的方法;创作仍保留在 n8n 中。
¥It isn't a way to build or edit workflows from an AI client; authoring remains in n8n.
- 它不会全面暴露实例中的所有工作流。你必须在实例级别启用 MCP,然后单独启用每个工作流。
¥It doesn't provide blanket exposure to all workflows in your instance. You must enable MCP at the instance level and then enable each workflow individually.
- 不局限于每个 MCP 客户端。任何连接的客户端都可以看到你为 MCP 访问权限启用的所有工作流。
¥It's not scoped to each MCP client. Any connected client sees all workflows you’ve enabled for MCP access.
启用 MCP 访问#
¥Enabling MCP access
适用于云端和自托管实例#
¥For Cloud and self-hosted instances
- 导航至“设置”>“MCP 访问”。
¥Navigate to Settings > MCP Access 2. 启用 MCP 访问(需要实例所有者或管理员权限)。
¥Toggle Enable MCP access (requires instance owner or admin permissions).
启用后,你将看到:
¥Once enabled, you'll see:
- 连接说明
¥Connection instructions
- 向 MCP 客户端公开的工作流列表
¥List of workflows exposed to MCP clients
禁用:关闭开关。
¥To disable: Toggle the switch off.
对于自托管实例:完全禁用#
¥For self-hosted: Complete disablement
要完全移除该功能,请设置环境变量:
¥To remove the feature entirely, set the environment variable:
N8N_DISABLED_MODULES=mcp
此操作会移除 MCP 端点并隐藏所有相关的 UI 元素。
¥This action removes MCP endpoints and hides all related UI elements.
设置 MCP 身份验证#
¥Setting up MCP authentication
MCP 访问页面上的“如何连接”部分提供了两种 MCP 客户端身份验证方法:
¥The How to connect section on the MCP Access page provides two authentication methods for MCP clients:
-
OAuth2
-
访问令牌
¥Access Token
使用 OAuth2#
¥Using OAuth2
从 OAuth 选项卡复制你的实例服务器 URL,并使用它来配置你的 MCP 客户端。连接后,客户端会将你重定向到 n8n 以授权访问。
¥Copy your instance server URL from the OAuth tab and use it to configure your MCP client. After connecting, the client will redirect you to n8n to authorize access.
撤销客户端访问权限#
¥Revoking client access
要撤销已连接的 MCP 客户端的访问权限:
¥To revoke access for connected MCP clients:
- 导航至“设置”>“MCP 访问”。
¥Navigate to Settings > MCP Access. 2. 切换到“如何连接”部分中的“OAuth”选项卡。你应该在“已连接的 OAuth 客户端”部分中看到已连接客户端的表格。
¥Switch to the OAuth tab in the How to connect section. You should see a table of connected clients in the Connected OAuth clients section. 3. 使用每个客户端行中的操作菜单可以撤销特定客户端的访问权限。
¥Use the action menu in each client's row to revoke access for specific clients.
使用访问令牌#
¥Using Access Token
使用你的实例服务器 URL 和你的个人 MCP 访问令牌(位于设置页面的“访问令牌”选项卡中)。
¥Use your instance server URL and your personal MCP Access Token from the Access Token tab on the settings page.
首次访问 MCP 访问页面时,n8n 会自动生成一个与你的用户账户关联的个人 MCP 访问令牌。
¥When you first visit the MCP Access page, n8n automatically generates a personal MCP Access Token tied to your user account.
Info
立即复制你的令牌。在后续访问中,你将只能看到已编辑的值,并且复制按钮将被禁用。
¥Copy your token right away. On future visits, you'll only see a redacted value and the copy button will be disabled.
轮换令牌#
¥Rotating your token
如果你丢失令牌或需要轮换令牌:
¥If you lose your token or need to rotate it:
- 导航至“设置”>“MCP 访问”。
¥Navigate to Settings > MCP Access.
- 确保你位于“如何连接”部分的“访问令牌”标签页。
¥Make sure you are on the Access Token tab in the How to connect section.
- 生成新令牌
¥Generate a new token.
当你生成新令牌时,n8n 会撤销之前的令牌。
¥n8n revokes the previous token when you generate a new one.
- 使用新值更新所有已连接的 MCP 客户端
¥Update all connected MCP clients with the new value.
向 MCP 客户端公开工作流#
¥Exposing workflows to MCP clients
工作流资格#
¥Workflow eligibility
为了使工作流能够对 MCP 客户端可用,它必须满足以下条件:
¥In order for a workflow to be available to MCP clients, it must meet the following criteria:
- 保持活跃
¥Be active 2. 包含以下触发节点之一:
¥Contain one of the following trigger nodes:
-
Webhook
-
计划
¥Schedule
-
聊天
¥Chat
-
表单
¥Form
默认情况下,MCP 客户端不可见任何工作流。你必须显式启用访问权限。
¥By default, no workflows are visible to MCP clients. You must explicitly enable access.
Info
停用工作流后,n8n 将移除其 MCP 访问权限。当你再次激活工作流时,你需要重新启用访问权限。
¥Once you deactivate a workflow, n8n removes its MCP access. You will have to re-enable access when you activate the workflow again.
启用访问#
¥Enabling access
选项 1:从工作流编辑器#
¥Option 1: From the workflow editor
- 打开工作流。
¥Open the workflow. 2. 前往设置。
¥Go to Settings. 3. 在 MCP 中启用切换。
¥Toggle Available in MCP.
选项 2:从工作流列表#
¥Option 2: From the workflows list
- 前往工作流。
¥Go to Workflows. 2. 打开工作流卡片上的菜单。
¥Open the menu on a workflow card. 3. 选择“启用 MCP 访问”。
¥Select Enable MCP access.
管理访问权限#
¥Managing access
MCP 访问设置页面显示所有可供 MCP 客户端使用的工作流程。从此列表中,你可以:
¥The MCP Access settings page shows all workflows available to MCP clients. From this list you can:
- 直接打开工作流
¥Open a workflow directly
- 使用操作菜单撤销访问权限(或从工作流卡片菜单中使用“禁用 MCP 访问”)
¥Revoke access using the action menu (or use Disable MCP access from the workflow card menu)
工作流描述#
¥Workflow descriptions
为了帮助 MCP 客户端识别工作流,你可以按如下方式添加自由文本描述:
¥To help MCP clients identify workflows, you can add free-text descriptions as follows:
- 打开工作流。
¥Open the workflow. 2. 点击工作流名称旁边的铅笔图标。
¥Click the pencil icon next to the workflow name. 3. 在“描述”字段中输入你的描述。
¥Enter your description in the Description field.
通过 MCP 客户端执行工作流#
¥Executing workflows through MCP clients
MCP 客户端可以根据你的请求执行符合条件的流程。当客户端触发工作流时,它将在 n8n 中正常运行,你可以在“执行”列表中监控其执行情况。执行完成后,MCP 客户端将检索结果。
¥MCP clients can execute eligible workflows on your request. When a client triggers a workflow, it runs as usual in n8n, and you can monitor its execution in the Executions list. Once the execution is complete, the MCP client will retrieve the results.
提供输入数据#
¥Providing input data
如果工作流需要输入数据,MCP 客户端必须在触发工作流时提供该数据。工作流的触发节点决定输入数据的模式:
¥If a workflow requires input data, the MCP client must provide that data when triggering the workflow. The workflow's trigger node determines the schema of the input data:
- Webhook 触发器:MCP 客户端会在工作流内容及其描述中查找提示。工作流作者有责任提供足够的信息,以便客户端生成有效的输入数据。
¥Webhook trigger: The MCP client will look for hints in workflow contents and its description. It's up to the workflow author to provide enough information for the client to generate valid input data. 2. 计划触发器:无需输入数据。
¥Schedule trigger: No input data is required. 3. 聊天触发:聊天输入格式由聊天节点配置决定。
¥Chat trigger: Chat input format is determined by the chat node configuration. 4. 表单触发器:表单字段由表单节点配置决定。
¥Form trigger: Form fields are determined by the form node configuration.
工作流超时#
¥Workflow timeouts
n8n 对由 MCP 客户端触发的工作流执行强制执行 5 分钟超时。如果工作流未按时完成,n8n 会停止执行并向 MCP 客户端发送错误,忽略你在工作流设置中为 MCP 触发的执行设置的任何超时时间。
¥n8n enforces a 5-minute timeout for workflow executions triggered by MCP clients. If a workflow doesn't finish in time, n8n stops the execution and sends an error to the MCP client, ignoring any timeout you set in the workflow settings for MCP-triggered executions.
局限性#
¥Limitations
- 如果工作流中存在多个受支持的触发器,则 MCP 客户端可能只能使用其中一个(第一个)触发器来触发工作流。
¥If there are multiple supported triggers in a workflow, MCP clients may only be able to use one (first one) of them to trigger the workflow.
- 不支持执行包含多步骤表单或任何类型的人工交互的工作流。
¥Executing workflows with multi-step forms or any kind of human-in-the-loop interactions isn't supported.
- 不支持二进制输入数据。MCP 客户端只能为你的流程提供基于文本的输入。
¥Binary input data isn't supported. MCP clients can only provide text-based inputs for your workflows.
示例#
¥Examples
将 Lovable 连接到 n8n MCP 服务器#
¥Connecting Lovable to n8n MCP server
- 在 Lovable 中配置 MCP 服务器(OAuth)。
¥Configure MCP Server in Lovable (OAuth).
-
导航至你的工作区“设置”>“集成”。
¥Navigate to your workspace Settings > Integrations.
-
在“MCP 服务器”部分,找到 n8n 并单击“连接”。
¥In the MCP Servers section, find n8n and click Connect.
-
输入你的 n8n 服务器 URL(显示在 MCP 访问页面上)。
¥Enter your n8n server URL (shown on the MCP Access page).
-
保存连接。如果成功,n8n 会将你重定向到 Lovable 授权页面。
¥Save the connection. If successful, n8n redirects you to authorize Lovable. 2. 验证连接性。
¥Verify connectivity.
-
连接后,Lovable 可以查询已启用 MCP 访问权限的工作流。
¥Once connected, Lovable can query for workflows with MCP access enabled.
-
示例:请求 Lovable 构建一个列出用户并允许删除用户的工作流 UI。
¥Example: Asking Lovable to build a workflow UI that lists users and allows deleting them.
将 Claude Desktop 连接到 n8n MCP 服务器#
¥Connecting Claude Desktop to n8n MCP server
使用 OAuth2#
¥Using OAuth2
- 在 Claude Desktop 中,导航至“设置”>“连接器”。
¥Navigate to Settings > Connectors in Claude Desktop. 2. 点击“添加自定义连接器”。
¥Click on Add custom connector. 3. 输入以下详细信息:
¥Enter the following details:
-
名称:n8n MCP
¥Name: n8n MCP
-
远程 MCP 服务器 URL:你的 n8n 基本 URL(显示在 MCP 访问页面上)
¥Remote MCP Server URL: Your n8n base URL (shown on the MCP Access page) 4. 保存连接器。
¥Save the connector. 5. 出现提示时,请授权 Claude Desktop 访问你的 n8n 实例。
¥When prompted, authorize Claude Desktop to access your n8n instance.
使用访问令牌#
¥Using Access Token
将以下条目添加到 claude_desktop_config.json 文件:
¥Add the following entry to your claude_desktop_config.json file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
在此处替换:
¥Here, replace:
<your-n8n-domain>:你的 n8n 基本 URL(显示在 MCP 访问页面上)
¥<your-n8n-domain>: Your n8n base URL (shown on the MCP Access page)
<YOUR_N8N_MCP_TOKEN>:你生成的令牌
¥<YOUR_N8N_MCP_TOKEN>: Your generated token
将 Claude Code 连接到 n8n MCP 服务器#
¥Connecting Claude Code to n8n MCP server
使用以下 CLI 命令:
¥Use the following CLI command:
1 2 | |
或者,将以下条目添加到你的 claude.json 文件中:
¥Alternatively, add the following entry to your claude.json file:
1 2 3 4 5 6 7 8 9 10 11 | |
在此处替换:
¥Here, replace:
<your-n8n-domain>:你的 n8n 基本 URL(显示在 MCP 访问页面上)
¥<your-n8n-domain>: Your n8n base URL (shown on the MCP Access page)
<YOUR_N8N_MCP_TOKEN>:你生成的令牌
¥<YOUR_N8N_MCP_TOKEN>: Your generated token
将 Codex CLI 连接到 n8n MCP 服务器#
¥Connecting Codex CLI to n8n MCP server
将以下条目添加到 ~/.codex/config.toml 文件:
¥Add the following entry to your ~/.codex/config.toml file:
1 2 3 4 5 6 7 8 9 10 | |
在此处替换:
¥Here, replace:
<your-n8n-domain>:你的 n8n 基本 URL(显示在 MCP 访问页面上)
¥<your-n8n-domain>: Your n8n base URL (shown on the MCP Access page)
<YOUR_N8N_MCP_TOKEN>:你生成的令牌
¥<YOUR_N8N_MCP_TOKEN>: Your generated token
故障排除#
¥Troubleshooting
如果你在将 MCP 客户端连接到 n8n 实例时遇到问题,请考虑以下事项:
¥If you encounter issues connecting MCP clients to your n8n instance, consider the following:
- 如果你使用基于云的 MCP 客户端,请确保你的 n8n 实例可公开访问。
¥Ensure that your n8n instance is publicly accessible if you are using cloud-based MCP clients.
- 验证是否已在 n8n 设置中启用 MCP 访问。
¥Verify that the MCP access is enabled in n8n settings.
- 检查你要访问的工作流是否在 MCP 中标记为可用。
¥Check that the workflows you want to access are marked as available in MCP.
- 确认你的 MCP 客户端中已正确配置身份验证方法(OAuth2 或访问令牌)。
¥Confirm that the authentication method (OAuth2 or Access Token) is correctly configured in your MCP client.
- 检查 n8n 服务器日志中是否存在与 MCP 连接相关的任何错误消息。
¥Review n8n server logs for any error messages related to MCP connections.
- 如果你使用的是桌面 MCP 客户端,请确保已安装最新版本的 Node.js。
¥If you are using desktop MCP clients, make sure you have the latest Node.js version installed.

