n8n-mcp

应用程序

czlonkowski/n8n-mcp

让AI助手构建n8n工作流的MCP服务器。

项目简介

n8n-MCP是一个模型上下文协议服务器,连接n8n工作流自动化平台与AI模型,提供对1650多个n8n节点、模板和文档的全面访问。它使Claude等AI助手能够高效理解和创建n8n工作流。

README 预览

# n8n-MCP\n\n[](https://opensource.org/licenses/MIT)\n[](https://github.com/czlonkowski/n8n-mcp)\n[](https://www.npmjs.com/package/n8n-mcp)\n[](https://codecov.io/gh/czlonkowski/n8n-mcp)\n[](https://github.com/czlonkowski/n8n-mcp/actions)\n[](https://github.com/n8n-io/n8n)\n[](https://github.com/czlonkowski/n8n-mcp/pkgs/container/n8n-mcp)\n[](https://railway.com/deploy/n8n-mcp?referralCode=n8n-mcp)\n\nA Model Context Protocol (MCP) server that provides AI assistants with comprehensive access to n8n node documentation, properties, and operations. Deploy in minutes to give Claude and other AI assistants deep knowledge about n8n's 1,650 workflow automation nodes (820 core + 830 community).\n\n## Overview\n\nn8n-MCP serves as a bridge between n8n's workflow automation platform and AI models, enabling them to understand and work with n8n nodes effectively. It provides structured access to:\n\n- **1,650 n8n nodes** - 820 core nodes + 830 community nodes (741 verified)\n- **Node properties** - 99% coverage with detailed schemas\n- **Node operations** - 63.6% coverage of available actions\n- **Documentation** - 87% coverage from official n8n docs (including AI nodes)\n- **AI tools** - 265 AI-capable tool variants detected with full documentation\n- **Real-world examples** - 156 ranked configurations extracted from popular templates\n- **Template library** - 2,352 workflow templates with 99.96% AI metadata coverage\n- **Community nodes** - Search verified community integrations with `source` filter\n\n## Support This Project\n\n\n  \n    \n  \n\n\n**n8n-mcp** started as a personal tool but now helps tens of thousands of developers automate their workflows efficiently. Maintaining and developing this project competes with my paid work. Your sponsorship helps me dedicate focused time to new features, respond quickly to issues, keep documentation up-to-date, and ensure compatibility with latest n8n releases. **[Become a sponsor](https://github.com/sponsors/czlonkowski)**\n\n## 

常见问题 (5)

故障排除
如何禁用 n8n MCP Apps 结果卡片并修复 "Couldn't open n8n-mcp" 小组件错误?

升级到 n8n MCP 2.92.0 或更高版本。要为整个服务器禁用 UI 卡片,请在启动进程之前设置 N8N_MCP_DISABLE_UI_APPS=true;仅接受精确值 true。此设置同时适用于 stdio 和 HTTP 部署,并会覆盖任何按请求设置的 uiAppsEnabled: true。如需按请求控制,请将 InstanceContext.uiAppsEnabled 设置为 false。服务器随后会停止通告 _meta.ui、_meta['ui/resourceUri']、_meta['n8n-mcp/toolName'] 和 ui://n8n-mcp/* 资源,而所有工具和文本结果仍然可用。针对 ui:// URI 的现有 resources/read 请求仍会继续成功,以便已缓存的客户端不会再生成错误卡片。如果客户端缓存了旧的工具到卡片映射,请启动新的 ChatGPT/MCP 会话。

来源 Issue #1152
故障排除
如何修复 n8n-mcp 中 pythonNative Python Code 节点的 validate_node 返回 "Code cannot be empty" 的问题?

验证器只检查 language === 'python',但 n8n 2.x 使用的是 pythonNative,因此它错误地读取了 jsCode 字段而不是 pythonCode。请通过在 validateCode 中对语言进行规范化来修复 src/services/config-validator.ts:

const language = config.language === 'pythonNative' ? 'python' : config.language;
const codeField = language === 'python' ? 'pythonCode' : 'jsCode';

或者,使用:

const codeField = ['python', 'pythonNative'].includes(config.language)
  ? 'pythonCode'
  : 'jsCode';

作为临时变通方案,在调用 validate_node 之前将 pythonNative 规范化为 python。添加一个 validate_node 回归测试,使用 language: "pythonNative" 且 pythonCode 非空。

来源 Issue #1112
故障排除
为什么即使节点执行成功,$jmespath() 在 n8n 表达式中仍返回 null?

n8n 会有意吞掉 {{ }} 表达式中的 JMESPath 解析错误,因此无效查询会解析为 null,而节点仍报告成功。在 Filter/IF 节点中,这个 null 会导致每个数据项都无法通过条件判断。

修复 JMESPath 语法:

- 用反引号包裹数字字面量:
{{ $jmespath($json, "customers[?revenue > 100000].name") }}
- 字符串字面量使用单引号;双引号会被当作字段标识符:
{{ $jmespath($json, "customers[?country=='PL'].name") }}
- 使用 JMESPath 逻辑运算符 && 和 ||,而不是 and/or:
{{ $jmespath($json, "customers[?country=='PL' && active].name") }}
- 使用 ==,而不是单个 =。
- 保持参数顺序为对象在前、查询在后:
$jmespath($json, "customers[].name")

此前,JMESPath 校验仅在 Code 节点内运行。如果你使用 n8n-mcp 的 validate_workflow,请升级到 v2.87.0 或更高版本;它会静态检查表达式内的 $jmespath() 调用,并在运行时之前报告这些错误。

来源 Issue #1114
故障排除
为什么 n8n 的 Python Code 节点会因 _input 或 _json 报 NameError 错误,并阻止 json/datetime 的导入?

n8n 2.x 使用原生 Python 运行时(language: "pythonNative"),而不是已移除的 Pyodide "Python (Beta)" 运行时。请按以下方式更新 Code 节点脚本:

1. 在 All Items 模式下,将 _input.all() 替换为 _items:

return [{"json": item} for item in _items]

2. 在 Each Item 模式下,使用 _item 而非 _json:
return {"json": _item}

3. 只能使用字典语法访问数据。_input、_json、_node、_now、_today 和 _jmespath 均不可用。
4. 除非你的自托管 task runner 明确将其列入允许列表,否则不要使用 import json、import datetime 或其他标准库导入。n8n Cloud 默认不允许任何导入。
5. 避免使用 class、type()、getattr()、hasattr()、dunder 访问和 global;在需要时使用 nonlocal。
6. 返回值必须与模式匹配:All Items 接受 {"json": ...} 对象的列表、普通字典的列表或单个字典;Each Item 接受单个字典。返回 None 会丢弃该条目,而返回列表则会报错。

如果自托管 Docker 报告 Python runner unavailable: Python 3 is missing from this system,请部署 n8nio/runners sidecar;否则 Python Code 节点将无法运行。

来源 Issue #1116
故障排除
如何修复在更新已发布的工作流时出现的 n8n 403 "insufficient_api_key_scope" 或 "insufficient_permissions" 错误?

在 n8n 2.39+ 中,PUT /workflows/{id} 会将更改保存为草稿,但当调用者无法发布时会返回 403。已发布的工作流保持在线运行。请为 API 密钥授予 workflow:activate 权限范围,并确保用户对该工作流拥有 workflow:publish 权限,然后重试更新。如果使用 n8n-mcp,请升级到 v2.87.0 或更高版本;此类响应将被报告为 PUBLISH_FORBIDDEN,而不是之前具有误导性的部分更新提示信息。使用 n8n_update_full_workflow 时,草稿会被保留;使用 n8n_update_partial_workflow 时,草稿会被回滚。使用相同的受限凭据重试将创建另一个草稿,而不会发布。

来源 Issue #1118