@设计/tcs-n8n-mcp
通过AI助手管理您的n8n工作流程
](https://www.npmjs.com/package/@thecodesaiyan/tcs-n8n-mcp)  ](https://nodejs.org)  
一 主控程序 服务器,让AI助手完全控制您的 n8n 工作流自动化平台。通过自然语言列出、创建、更新、执行和管理工作流、执行、标记、变量、凭据和用户。
______________________________________________________________________
特性
- 22工具 涵盖完整的n8n REST API
- 适用于所有地方 --克劳德代码,克劳德桌面,VS代码,光标,风帆,Cline
- 缺省安全 --ID验证、经过净化的错误、隐藏的秘密、请求超时
- 灵活的身份验证 -API密钥(默认)、承载令牌或基本身份验证
- 零配置 -只需提供n8n API密钥即可
- 轻量级 --在30KB以下,除了MCP SDK和Zod之外,没有运行时依赖关系
______________________________________________________________________
先决条件
______________________________________________________________________
安装
快速开始
npx @thecodesaiyan/tcs-n8n-mcp --setup安装向导将引导您完成配置,测试您的连接,并为MCP客户端输出可粘贴的配置。
Windows用户:npx无法解析Windows上作用域包中的bin命令。改为全局安装: ``bash npm install -g @thecodesaiyan/tcs-n8n-mcp tcs-n8n-mcp --setup``
环境变量
| 变量 | 必填 | 默认 | 描述 |
|---|---|---|---|
N8N_API_KEY | 是 | - | 您的n8n API密钥(或基本身份验证的密码) |
N8N_API_URL | 没有 | http://localhost:5678 | n8n实例的基本URL |
N8N_AUTH_TYPE | 没有 | apikey | 身份验证方法: apikey, bearer,或 basic |
N8N_API_USER | 仅适用于 basic | -- | 基本身份验证的用户名 |
N8N_TIMEOUT_MS | 没有 | 30000 | 请求超时(毫秒) |
身份验证类型
apikey(默认)--发送X-N8N-API-KEY头球这是n8n的标准API身份验证。bearer--发送Authorization: Bearer头球basic--发送Authorization: Basic头球需要N8N_API_USER待设定。
______________________________________________________________________
客户端设置
Claude Code
选项A:交互式向导
npx @thecodesaiyan/tcs-n8n-mcp --setup选项B:CLI命令
macOS/Linux:
claude mcp add n8n -e N8N_API_URL=http://localhost:5678 -e N8N_API_KEY=your-api-key -- npx -y @thecodesaiyan/tcs-n8n-mcp视窗 (首先全局安装):
npm install -g @thecodesaiyan/tcs-n8n-mcp
claude mcp add n8n -e N8N_API_URL=http://localhost:5678 -e N8N_API_KEY=your-api-key -- tcs-n8n-mcp选项C:手动配置
增添 ~/.claude.json:
macOS/Linux:
{
"mcpServers": {
"n8n": {
"command": "npx",
"args": ["-y", "@thecodesaiyan/tcs-n8n-mcp"],
"env": {
"N8N_API_KEY": "your-api-key-here",
"N8N_API_URL": "http://localhost:5678"
}
}
}
}窗户:
{
"mcpServers": {
"n8n": {
"command": "tcs-n8n-mcp",
"args": [],
"env": {
"N8N_API_KEY": "your-api-key-here",
"N8N_API_URL": "http://localhost:5678"
}
}
}
}Claude Desktop
添加到您的Claude Desktop配置文件中:
| 操作系统 | 路径 |
|---|---|
| 窗户 | %APPDATA%\Claude\claude_desktop_config.json |
| macOS | ~/Library/Application Support/Claude/claude_desktop_config.json |
| Linux | ~/.config/Claude/claude_desktop_config.json |
macOS/Linux:
{
"mcpServers": {
"n8n": {
"command": "npx",
"args": ["-y", "@thecodesaiyan/tcs-n8n-mcp"],
"env": {
"N8N_API_KEY": "your-api-key-here",
"N8N_API_URL": "http://localhost:5678"
}
}
}
}视窗 (奔跑 npm install -g @thecodesaiyan/tcs-n8n-mcp 第一):
{
"mcpServers": {
"n8n": {
"command": "tcs-n8n-mcp",
"args": [],
"env": {
"N8N_API_KEY": "your-api-key-here",
"N8N_API_URL": "http://localhost:5678"
}
}
}
}保存后重新启动Claude Desktop。
VS Code (GitHub Copilot)
增添 .vscode/mcp.json 在您的项目中,或使用 命令面板 > MCP: Open User Configuration:
macOS/Linux:
{
"servers": {
"n8n": {
"command": "npx",
"args": ["-y", "@thecodesaiyan/tcs-n8n-mcp"],
"env": {
"N8N_API_KEY": "your-api-key-here",
"N8N_API_URL": "http://localhost:5678"
}
}
}
}视窗 (奔跑 npm install -g @thecodesaiyan/tcs-n8n-mcp 第一):
{
"servers": {
"n8n": {
"command": "tcs-n8n-mcp",
"args": [],
"env": {
"N8N_API_KEY": "your-api-key-here",
"N8N_API_URL": "http://localhost:5678"
}
}
}
}Cursor
增添 ~/.cursor/mcp.json (全球)或 .cursor/mcp.json (项目层面):
macOS/Linux:
{
"mcpServers": {
"n8n": {
"command": "npx",
"args": ["-y", "@thecodesaiyan/tcs-n8n-mcp"],
"env": {
"N8N_API_KEY": "your-api-key-here",
"N8N_API_URL": "http://localhost:5678"
}
}
}
}视窗 (奔跑 npm install -g @thecodesaiyan/tcs-n8n-mcp 第一):
{
"mcpServers": {
"n8n": {
"command": "tcs-n8n-mcp",
"args": [],
"env": {
"N8N_API_KEY": "your-api-key-here",
"N8N_API_URL": "http://localhost:5678"
}
}
}
}Windsurf
添加到您的Windsurf配置文件中:
| 操作系统 | 路径 |
|---|---|
| 窗户 | %USERPROFILE%\.codeium\windsurf\mcp_config.json |
| macOS/Linux | ~/.codeium/windsurf/mcp_config.json |
macOS/Linux:
{
"mcpServers": {
"n8n": {
"command": "npx",
"args": ["-y", "@thecodesaiyan/tcs-n8n-mcp"],
"env": {
"N8N_API_KEY": "your-api-key-here",
"N8N_API_URL": "http://localhost:5678"
}
}
}
}视窗 (奔跑 npm install -g @thecodesaiyan/tcs-n8n-mcp 第一):
{
"mcpServers": {
"n8n": {
"command": "tcs-n8n-mcp",
"args": [],
"env": {
"N8N_API_KEY": "your-api-key-here",
"N8N_API_URL": "http://localhost:5678"
}
}
}
}Cline
打开 MCP服务器 > 配置 > 高级MCP设置 并添加:
macOS/Linux:
{
"mcpServers": {
"n8n": {
"command": "npx",
"args": ["-y", "@thecodesaiyan/tcs-n8n-mcp"],
"env": {
"N8N_API_KEY": "your-api-key-here",
"N8N_API_URL": "http://localhost:5678"
}
}
}
}视窗 (奔跑 npm install -g @thecodesaiyan/tcs-n8n-mcp 第一):
{
"mcpServers": {
"n8n": {
"command": "tcs-n8n-mcp",
"args": [],
"env": {
"N8N_API_KEY": "your-api-key-here",
"N8N_API_URL": "http://localhost:5678"
}
}
}
}______________________________________________________________________
可用工具(22)
工作流程(8)
| 工具 | 说明 |
|---|---|
list_workflows | 列出所有带分页的工作流 |
get_workflow | 获取完整的工作流详细信息,包括节点、连接和设置 |
create_workflow | 使用可选节点和连接创建新工作流 |
update_workflow | 更新现有工作流的名称、节点、连接或设置 |
delete_workflow | 永久删除工作流 |
activate_workflow | 激活工作流,使其在配置的触发器上运行 |
deactivate_workflow | 停用工作流以停止基于触发器的执行 |
execute_workflow | 立即执行工作流并返回执行ID |
处决(3)
| 工具 | 说明 |
|---|---|
list_executions | 使用工作流ID和状态的可选筛选器列出执行情况 |
get_execution | 获取完整的执行详细信息,包括每个节点的结果和错误 |
delete_execution | 删除执行记录 |
标签(4)
| 工具 | 说明 |
|---|---|
list_tags | 列出用于组织工作流的所有标签 |
create_tag | 创建新标签 |
update_tag | 重命名现有标记 |
delete_tag | 删除标签 |
变量(4)
| 工具 | 说明 |
|---|---|
list_variables | 列出所有环境变量(为了安全起见,值被屏蔽) |
create_variable | 创建新的键值环境变量 |
update_variable | 更新现有变量的键或值 |
delete_variable | 删除环境变量 |
证书(1)
| 工具 | 说明 |
|---|---|
list_credentials | 列出所有凭据(仅元数据——机密永远不会暴露) |
用户(2)
| 工具 | 说明 |
|---|---|
list_users | 列出所有用户及其角色和状态 |
get_user | 按ID获取用户的完整详细信息 |
______________________________________________________________________
安全
| 保护 | 说明 |
|---|---|
| ID验证 | 所有资源ID都被验证为数字字符串,以防止路径遍历攻击 |
| 错误消毒 | API错误响应仅返回HTTP状态代码,从不返回原始响应体 |
| 秘密面具 | 变量值隐藏在列表输出中,以防止意外泄露秘密 |
| 请求超时 | 所有API调用都有一个可配置的超时(默认为30秒),以防止挂起连接 |
| 无密钥记录 | API键从不记录、回显或包含在工具输出中 |
| 凭证安全 | 凭据工具只返回元数据——机密永远不会暴露 |
| 启动验证 | 在接受任何请求之前,在启动时验证凭据和连接 |
| 防止集管注入 | 验证基本身份验证凭据以拒绝控制字符 |
______________________________________________________________________
发展
git clone https://github.com/ntatschner/tcs-n8n-mcp.git
cd tcs-n8n-mcp
npm install命令
| 命令 | 描述 |
|---|---|
npm run build | 将TypeScript编译为 build/ |
npm test | 运行测试套件 |
npm run test:coverage | 使用覆盖率报告运行测试 |
npm start | 启动MCP服务器 |
在本地运行
# API key auth (default)
N8N_API_KEY=your-key N8N_API_URL=http://localhost:5678 npm start
# Bearer token auth
N8N_AUTH_TYPE=bearer N8N_API_KEY=your-token N8N_API_URL=http://localhost:5678 npm start
# Basic auth
N8N_AUTH_TYPE=basic N8N_API_USER=admin N8N_API_KEY=password N8N_API_URL=http://localhost:5678 npm start项目结构
src/
index.ts Entry point, fetch wrapper, server setup
config.ts Auth type parsing, header building, timeout, connection check
types.ts Shared types, interfaces, response helpers
validation.ts Zod schemas for input validation
tools/
workflows.ts Workflow CRUD, activation, execution
executions.ts Execution listing and management
tags.ts Tag CRUD operations
variables.ts Environment variable management
credentials.ts Credential metadata listing
users.ts User listing and details______________________________________________________________________
贡献
欢迎投稿!请打开问题或提交拉取请求。
- 分叉存储库
- 创建功能分支(
git checkout -b feat/my-feature) - 运行测试(
npm test) - 提交您的更改(
git commit -m 'feat: add my feature') - 推到分支(
git push origin feat/my-feature) - 打开拉取请求
______________________________________________________________________
