Loading...
Loading...
Compare original and translation side by side
Execute Workflow TriggerExecute Workflow Triggerlist_tagsupdate_workflowaddTagsremoveTagsPOST /credentialslist_tagsupdate_workflowaddTagsremoveTagsPOST /credentialsn8n-credentials-and-security-officialn8n-credentials-and-security-officialsearch_workflows({ tags: ['tool'] })search_workflows({ tags: ['tool'] })1. User asks for a capability (missing MCP feature, or a workflow they want
the agent to be able to invoke).
2. You: "I can build a workflow that exposes this as a tool the MCP can call.
Want me to create it?"
3. User: yes.
4. You build the workflow:
- Trigger: Execute Workflow Trigger with declared inputs.
- Body: whatever logic the tool needs (HTTP Request to n8n's API, a
third-party call, internal computation).
- Output: structured response.
5. Validate, test, publish.
6. Ask the user if you can add an entry for this tool to their agent context
file (CLAUDE.md / AGENTS.md / etc.) so future sessions know to search for
it by name. Edit the file directly when they say yes.
7. The workflow is immediately callable: agent-created workflows have `availableInMCP: true` set by default.1. 用户提出需求(缺失的MCP功能,或希望Agent能触发的工作流)。
2. 你:"我可以构建一个工作流,将该功能暴露为MCP可调用的工具。需要我创建吗?"
3. 用户:同意。
4. 你构建工作流:
- 触发器:使用声明了输入的Execute Workflow Trigger。
- 主体:实现工具所需的逻辑(调用n8n API的HTTP请求、第三方调用、内部计算等)。
- 输出:结构化响应。
5. 验证、测试、发布。
6. 询问用户是否可将该工具条目添加到其Agent上下文文件(CLAUDE.md / AGENTS.md / 其他文件),以便未来会话可按名称搜索到该工具。用户同意后直接编辑文件。
7. 工作流可立即被调用:Agent创建的工作流默认设置`availableInMCP: true`。n8n REST API reference: https://docs.n8n.io/api/api-reference/. Start here for any case-1 wrap. Find the endpoint, then wrap it with an HTTP Request node +credential. Self-hosted instances expose this atn8nApi.<instance-url>/api/v1/
n8n REST API参考文档: https://docs.n8n.io/api/api-reference/。构建场景1封装工具时请先查阅此处。找到对应端点后,使用HTTP Request节点 +凭证进行封装。自托管实例的API地址为n8nApi。<instance-url>/api/v1/
Tool: create folder
Input: { projectId: string, name: string, parentFolderId?: string }
Output: { id, name, projectId, parentFolderId? }工具:创建文件夹
输入:{ projectId: string, name: string, parentFolderId?: string }
输出:{ id, name, projectId, parentFolderId? }Tool: get instance info
Input: {}
Output: { version, edition, integrations: [...], limits: {...} }工具:获取实例信息
输入:{}
输出:{ version, edition, integrations: [...], limits: {...} }search_workflows({ query: '<keyword>' })availableInMCP: trueexecute_workflow({ workflowId, inputs })get_workflow_detailsExecute Workflow TriggeravailableInMCP: truesearch_workflows({ query: '<keyword>' })availableInMCP: trueexecute_workflow({ workflowId, inputs })get_workflow_detailsExecute Workflow TriggeravailableInMCP: true| Anti-pattern | What goes wrong | Fix |
|---|---|---|
| Building an MCP-extension workflow without asking the user | Surprise creation of workflows on their instance with credentials | Always ask permission first |
| Not documenting the new tool in the agent's context file | Future sessions don't auto-enumerate tool workflows. Without a hint they'll re-derive the implementation. | Ask the user, then edit CLAUDE.md / AGENTS.md / whichever file their agent reads, directly. Don't make them paste a snippet. |
| Hardcoding the n8n API token in the HTTP Request node | Token leak when the workflow is exported or copied | Use a credential of type |
| Side-effecting tool with no mention of side effects in its name/description | Agent invokes thinking it's a read, ends up sending real messages or writing real data | Name and describe the side effect explicitly (e.g., |
| Wrapper that does bulk or destructive ops (archive, delete) with no dry-run | One bug touches many workflows | Strong explicit opt-in per call, plus a dry-run mode that lists targets without acting |
| Wrapper returns credential values | Token leak via tool output | Return IDs, names, types only. Never the secret. |
| Skipping the validate + verify + test cycle on the wrapper | The "tool" itself is broken, manifests as confusing tool-not-found or empty-response errors | Same lifecycle as any workflow: see |
| 反模式 | 问题 | 修复方案 |
|---|---|---|
| 未征得用户同意就构建MCP扩展工作流 | 在用户实例上意外创建带凭证的工作流 | 始终先征得用户许可 |
| 未在Agent上下文文件中记录新工具 | 未来会话不会自动枚举工具工作流,若无提示会重新推导实现逻辑 | 询问用户后,直接编辑CLAUDE.md / AGENTS.md / 其他Agent读取的文件,无需让用户粘贴代码片段 |
| 在HTTP Request节点中硬编码n8n API令牌 | 导出或复制工作流时会泄露令牌 | 使用 |
| 有副作用的工具未在名称/描述中提及副作用 | Agent以为是只读操作,实际却发送真实消息或写入真实数据 | 在名称和描述中明确说明副作用(例如: |
| 封装批量或破坏性操作(归档、删除)的工具无试运行模式 | 一个bug可能影响多个工作流 | 每次调用需明确确认,且添加试运行模式,仅列出目标对象而不执行操作 |
| 封装工具返回凭证值 | 通过工具输出泄露令牌 | 仅返回ID、名称、类型,绝不返回密钥 |
| 跳过封装工具的验证+确认+测试流程 | “工具”本身存在问题,表现为令人困惑的工具未找到或空响应错误 | 遵循与其他工作流相同的生命周期:详见 |