n8n-ops-mcp 0.14.0 → 0.14.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,35 +1,81 @@
1
1
  <p align="center">
2
- <img src="docs/assets/n8n-ops-mcp-banner.jpg" alt="n8n-ops-mcp banner">
2
+ <img src="docs/assets/n8nctrl-social-preview.jpg" alt="n8nctrl banner" width="900">
3
3
  </p>
4
4
 
5
- <h1 align="center">n8n-ops-mcp</h1>
5
+ <p align="center">
6
+ <a href="https://lidless.dev"><img src="docs/assets/marks/n8nctrl-circle.png" width="48" alt="Lidless Labs"></a>
7
+ </p>
8
+ <h1 align="center">n8nctrl</h1>
9
+
10
+ <p align="center">
11
+ <strong>Operator control CLI for n8n, with an MCP adapter for AI clients.</strong>
12
+ </p>
6
13
 
7
14
  <p align="center">
8
- <strong>Ops-focused n8n tools for MCP-compatible agents and OpenClaw plugins.</strong>
15
+ <a href="https://lidless.dev/n8n-ops-mcp"><strong>Website &amp; docs &rarr; lidless.dev/n8n-ops-mcp</strong></a>
9
16
  </p>
10
17
 
11
18
  <p align="center">
12
- <a href="https://www.npmjs.com/package/n8n-ops-mcp"><img src="https://img.shields.io/npm/v/n8n-ops-mcp?style=for-the-badge&logo=npm&logoColor=white" alt="npm version"></a>
13
- <img src="https://img.shields.io/badge/Node.js-%3E%3D20-339933?style=for-the-badge&logo=nodedotjs&logoColor=white" alt="Node.js >=20">
14
- <img src="https://img.shields.io/badge/TypeScript-5.5-3178C6?style=for-the-badge&logo=typescript&logoColor=white" alt="TypeScript 5.5">
15
- <img src="https://img.shields.io/badge/MCP-compatible-2563eb?style=for-the-badge" alt="MCP compatible">
16
- <img src="https://img.shields.io/badge/OpenClaw-plugin-ef4444?style=for-the-badge" alt="OpenClaw plugin">
17
- <img src="https://img.shields.io/badge/n8n-ops-ff6d5a?style=for-the-badge" alt="n8n ops">
18
- <img src="https://img.shields.io/npm/l/n8n-ops-mcp?style=for-the-badge" alt="license">
19
+ <img src="https://shieldcn.dev/github/ci/lidless-labs/n8nctrl.svg?branch=main&workflow=ci.yml" alt="CI">
20
+ <img src="https://shieldcn.dev/npm/v/n8n-ops-mcp.svg" alt="npm version">
21
+ <img src="https://shieldcn.dev/github/license/lidless-labs/n8nctrl.svg" alt="license">
19
22
  </p>
20
23
 
21
- Ops-focused n8n tools for any MCP-compatible client. List, inspect, trigger, validate, manage tags, run security audits, and safely edit n8n workflows - with auto-backup and confirm gates on destructive writes.
24
+ **n8nctrl is an operator control CLI for [n8n](https://n8n.io) workflow automation.** It lists, inspects, validates, audits, and reports on your n8n workflows and executions over the n8n Public API, so you can ask "what broke in my n8n today?" and act on the answer from a terminal, cron, CI, or an agent. Unlike catalog/docs tools that index n8n's node library for building flows, n8nctrl is built for operating the flows you already run: triage failed executions, find drift, scan for security risks, and inspect live schedules, webhooks, credentials metadata, and tags.
25
+
26
+ The MCP surface is the adapter layer: run `n8nctrl mcp` for stdio MCP, or keep using the back-compat `n8n-ops-mcp` binary in existing launchers. The same package also ships a first-class [OpenClaw](https://github.com/openclaw/openclaw) plugin. It works with Claude Desktop, Claude Code, Codex CLI, Cursor, Windsurf, or any other MCP host, with no hard dependency on a specific model or agent harness.
27
+
28
+ ## What it does
29
+
30
+ n8nctrl connects operators and agents to a running n8n instance for **workflow automation ops**: it surfaces your n8n workflows, executions, schedules, webhooks, tags, and credentials over the n8n Public API. From the CLI, you get scriptable read/report commands for shells, cron, and CI. Through `n8nctrl mcp` or the compatibility `n8n-ops-mcp` bin, your agent gets native awareness of your n8n footprint, so it can answer "what's broken in my n8n?", trigger a workflow from chat, audit for security risks, or clean up old executions without leaving your client.
31
+
32
+ Read tools are always available. Write tools (create, save, archive, delete, trigger, retry, tag CRUD, pin data) are hidden unless `N8N_ENABLE_EDIT=true`, and credential writes sit behind a second gate. Destructive operations are confirm-gated and snapshot to a backup directory first. See the [Security model](#security-model).
33
+
34
+ ## Install
35
+
36
+ ```bash
37
+ npm install -g n8n-ops-mcp
38
+ ```
39
+
40
+ The npm package name remains `n8n-ops-mcp` for compatibility. After a global install, use the standard CLI as `n8nctrl`. Existing `n8n-ops` and `n8n-ops-mcp` launchers remain supported as compatibility aliases.
41
+
42
+ For MCP launchers, you can still run it on demand via `npx -y n8n-ops-mcp` (no global install needed), which is what the MCP client config below does.
43
+
44
+ ## Try it: MCP client config
45
+
46
+ Drop this into your MCP client config (Claude Desktop shown). The binary runs straight from npm via `npx`, so there is nothing to install first:
47
+
48
+ ```json
49
+ {
50
+ "mcpServers": {
51
+ "n8n": {
52
+ "command": "npx",
53
+ "args": ["-y", "n8n-ops-mcp"],
54
+ "env": {
55
+ "N8N_BASE_URL": "https://n8n.example.com",
56
+ "N8N_API_KEY": "your-n8n-api-key"
57
+ }
58
+ }
59
+ }
60
+ }
61
+ ```
62
+
63
+ Generate the API key in n8n under **Settings &rarr; API**. Point `N8N_BASE_URL` at your n8n instance. That is the whole read-only setup. To unlock write tools, add `"N8N_ENABLE_EDIT": "true"` to `env`.
64
+
65
+ Then ask your agent:
22
66
 
23
- Built for [OpenClaw](https://github.com/openclaw/openclaw) as a first-class plugin, exposed as an MCP server for everyone else. Works with Claude Desktop, Claude Code, Codex CLI, Hermes Agent, Cursor, Windsurf, or any other MCP host. No hard dependency on a specific model or agent harness.
67
+ > What n8n workflows broke today?
24
68
 
25
- ## Why
69
+ It calls `n8n_list_executions` with `status=error`, then `n8n_get_execution` on the failing run for the per-node log and raw error.
26
70
 
27
- Your agent has no native awareness of your n8n footprint. With this package, it can answer "what's broken in my n8n?", trigger workflows from chat, or clean up old executions without you leaving your client.
71
+ ![n8nctrl ops loop workflow: an operator asks what broke, read tools list executions and inspect workflows, edit gates reveal writes, snapshots happen before confirmed actions](docs/assets/n8n-ops-loop-workflow.svg)
28
72
 
29
- For a catalog/docs tool that indexes n8n's node library, see [n8n-mcp](https://www.npmjs.com/package/n8n-mcp). This one is ops-focused - list, trigger, validate, edit.
73
+ Generated from [`docs/assets/workflows/n8n-ops-loop.json`](docs/assets/workflows/n8n-ops-loop.json) with `lidless workflow`.
30
74
 
31
75
  ## Tools
32
76
 
77
+ 40 tools across read-only ops, the workflow + execution lifecycle, tags, and credentials. Write tools (marked) are hidden unless `N8N_ENABLE_EDIT=true`; credential writes (marked ✓✓) need a second gate.
78
+
33
79
  | Tool | Purpose | Write |
34
80
  |---|---|---|
35
81
  | `n8n_list_workflows` | List workflows, filter by `active` / `tags` / `name` | |
@@ -41,8 +87,7 @@ For a catalog/docs tool that indexes n8n's node library, see [n8n-mcp](https://w
41
87
  | `n8n_validate_workflow` | Static checks: deprecated nodes, legacy Code-node API, orphans | |
42
88
  | `n8n_diff_workflow` | Compare a workflow against a snapshot file or inline object - semantic diff (added/removed/modified nodes with field paths) | |
43
89
  | `n8n_list_schedules` | List every schedule trigger across workflows with human-readable descriptions ("daily at 03:00", "cron: 0 */6 * * *") | |
44
- | `n8n_trigger` | Run a workflow via webhook (reliable) or workflow-id | |
45
- | `n8n_audit_browser_bridge_usage` | Find every workflow that calls the [`browser-bridge`](https://github.com/solomonneas/browser-bridge) CLI (Execute Command, Code, SSH nodes) | |
90
+ | `n8n_audit_browser_bridge_usage` | Find every workflow that calls the [`browser-bridge`](https://github.com/lidless-labs/browser-bridge) CLI (Execute Command, Code, SSH nodes) | |
46
91
  | `n8n_scaffold_browser_bridge_node` | Generate a ready-to-paste n8n node that calls a `browser-bridge <platform> <action>` (no API call) | |
47
92
  | `n8n_run_audit` | Run n8n's built-in security audit (credentials, database, nodes, filesystem, instance) | |
48
93
  | `n8n_find_workflows_using_node_type` | Find every workflow using a given node type (e.g. `n8n-nodes-base.slack`), with `exact` or `contains` match | |
@@ -53,22 +98,23 @@ For a catalog/docs tool that indexes n8n's node library, see [n8n-mcp](https://w
53
98
  | `n8n_get_credential_schema` | Fetch the JSON schema for a credential type (e.g. `freshdeskApi`) | |
54
99
  | `n8n_find_workflows_using_credential` | Find every workflow node that references a credential by `id` (preferred) or `name` substring; rotation/blast-radius scanner | |
55
100
  | `n8n_check_disabled_nodes` | Scan workflows for `disabled: true` nodes - common drift signals not surfaced in the n8n UI | |
56
- | `n8n_create_workflow` | Create a workflow (accepts `n8n_get_workflow` output directly; primary restore path) | ✓ |
57
- | `n8n_activate` | Enable a workflow's triggers | ✓ |
58
- | `n8n_deactivate` | Disable a workflow's triggers | ✓ |
101
+ | `n8n_trigger` | Run a workflow via webhook (reliable) or workflow-id (confirm-gated; executes arbitrary workflow nodes) | ✓ |
102
+ | `n8n_create_workflow` | Create a workflow (confirm-gated for writes; dry-run preview without confirm; accepts `n8n_get_workflow` output directly; optional project/folder target) | ✓ |
103
+ | `n8n_activate` | Enable a workflow's triggers (confirm-gated; arms arbitrary-code execution) | ✓ |
104
+ | `n8n_deactivate` | Disable a workflow's triggers (confirm-gated) | ✓ |
59
105
  | `n8n_save_workflow` | Overwrite a workflow with auto-backup + validation + confirm gate | ✓ |
60
- | `n8n_archive_workflow` | Soft-delete a workflow (reversible; preserves id) | ✓ |
61
- | `n8n_unarchive_workflow` | Restore an archived workflow (does NOT reactivate) | ✓ |
106
+ | `n8n_archive_workflow` | Soft-delete a workflow (confirm-gated; reversible; preserves id) | ✓ |
107
+ | `n8n_unarchive_workflow` | Restore an archived workflow (confirm-gated; does NOT reactivate) | ✓ |
62
108
  | `n8n_delete_workflow` | Permanently delete a workflow (confirm-gated, snapshot-before-delete, restore via `n8n_create_workflow`) | ✓ |
63
- | `n8n_cancel_execution` | Stop a running or waiting execution by id | ✓ |
64
- | `n8n_retry_execution` | Retry a failed execution by id (returns a new execution) | ✓ |
109
+ | `n8n_cancel_execution` | Stop a running or waiting execution by id (confirm-gated) | ✓ |
110
+ | `n8n_retry_execution` | Retry a failed execution by id (confirm-gated; returns a new execution) | ✓ |
65
111
  | `n8n_delete_execution` | Permanently delete an execution record (confirm-gated, irreversible) | ✓ |
66
112
  | `n8n_delete_executions` | Batch form of delete (client-side fan-out, confirm-gated, irreversible, max 50 ids) | ✓ |
67
113
  | `n8n_pin_node_data` | Pin sample data to a node so downstream nodes use it during testing (confirm-gated, replace-or-merge) | ✓ |
68
114
  | `n8n_unpin_node_data` | Clear pinned data on one node or the whole workflow (confirm-gated, idempotent) | ✓ |
69
- | `n8n_create_tag` | Create a workflow tag (no confirm; reversible via `n8n_delete_tag`) | ✓ |
115
+ | `n8n_create_tag` | Create a workflow tag (confirm-gated; reversible via `n8n_delete_tag`) | ✓ |
70
116
  | `n8n_delete_tag` | Permanently delete a tag (confirm-gated; cascades - removes the tag from every workflow) | ✓ |
71
- | `n8n_set_workflow_tags` | Replace the tag set on a workflow (no confirm; reversible by re-setting) | ✓ |
117
+ | `n8n_set_workflow_tags` | Replace the tag set on a workflow (confirm-gated; reversible by re-setting) | ✓ |
72
118
  | `n8n_retry_executions` | Batch retry executions (confirm-gated, max 50 ids, AbortController on 5xx) | ✓ |
73
119
  | `n8n_create_credential` | Create a credential (confirm-gated; **double-gated** behind `enableCredentialsWrite`; tool layer redacts `data` from every response branch) | ✓✓ |
74
120
  | `n8n_delete_credential` | Permanently delete a credential (confirm-gated; **double-gated**; cascades - every workflow referencing it will fail) | ✓✓ |
@@ -94,31 +140,31 @@ Write tools are hidden unless `N8N_ENABLE_EDIT=true`.
94
140
 
95
141
  **`n8n_list_schedules`** - scans `n8n-nodes-base.scheduleTrigger` and the legacy `n8n-nodes-base.cron` nodes across workflows and decodes each interval rule into a human-readable string. Answers "what's running at 3am?" without clicking through the n8n UI. Supported rule fields: `seconds` / `minutes` / `hours` / `days` / `weeks` / `months` (with `triggerAtHour`, `triggerAtMinute`, `triggerAtDay`, `triggerAtDayOfMonth`) and raw `cronExpression`. One entry per interval - multi-interval rules emit multiple rows. Each row includes `workflowId`, `workflowName`, `active`, `nodeName`, `nodeType`, `schedule`, `field`, optional `cronExpression`, and the original `raw` rule for further inspection. Optional `workflowId` (single-workflow scan), `activeOnly` (default true - inactive schedules don't fire), `limit` (default 100, max 250).
96
142
 
97
- **`n8n_diff_workflow`** - compare a workflow's current state against a snapshot. Pass `id` plus exactly one of `snapshotPath` (absolute path; `~` resolved) or `snapshot` (inline object). Snapshot accepts both shapes: the flat backup written by `n8n_save_workflow` / `n8n_delete_workflow`, and the nested `n8n_get_workflow(includeDefinition=true)` shape (graph data under `definition`). Returns `summary` (counts: added/removed/modified/nameChanged/connectionsChanged/settingsChanged) plus `diff` with per-node `fieldsChanged` paths (e.g. `parameters.command`, `parameters.url`, `disabled`). Node matching is two-pass: id first, then name fallback for any unmatched nodes - handles legacy/hand-edited snapshots. Cosmetic changes (`position`, `webhookId`) are suppressed by default; pass `ignoreCosmetic: false` to surface them. Per-node detail is capped at `maxModifiedDetails` (default 50, max 500); `summary.nodesModified` counter is uncapped and `diff.nodesModifiedTruncated: true` flags when detail was clipped. Read-only.
143
+ **`n8n_diff_workflow`** - compare a workflow's current state against a snapshot. Pass `id` plus exactly one of `snapshotPath` or `snapshot` (inline object). `snapshotPath` is **confined to the configured `backupDir`** (default `~/.n8n-backups`): it may be given relative to that directory or as an absolute path inside it, but any path that resolves outside `backupDir` (including `..` traversal) is rejected before the file is read. This keeps the tool from being used as an arbitrary file-read primitive even though it is available without `enableEdit`. Snapshot accepts both shapes: the flat backup written by `n8n_save_workflow` / `n8n_delete_workflow`, and the nested `n8n_get_workflow(includeDefinition=true)` shape (graph data under `definition`). Returns `summary` (counts: added/removed/modified/nameChanged/connectionsChanged/settingsChanged) plus `diff` with per-node `fieldsChanged` paths (e.g. `parameters.command`, `parameters.url`, `disabled`). Node matching is two-pass: id first, then name fallback for any unmatched nodes - handles legacy/hand-edited snapshots. Cosmetic changes (`position`, `webhookId`) are suppressed by default; pass `ignoreCosmetic: false` to surface them. Per-node detail is capped at `maxModifiedDetails` (default 50, max 500); `summary.nodesModified` counter is uncapped and `diff.nodesModifiedTruncated: true` flags when detail was clipped. Read-only.
98
144
 
99
- **`n8n_audit_browser_bridge_usage`** - scans every workflow for nodes that invoke the `browser-bridge` CLI. Inspects `command` (Execute Command + SSH nodes) and `jsCode` / `pythonCode` / `functionCode` (Code + legacy Function nodes). Heuristic: `\bbrowser-bridge\.[cm]?js` followed by two kebab-slug args; the bare bin form is intentionally not detected to avoid false positives from path mentions like `cd /opt/browser-bridge`. Returns one finding per `(workflowId, nodeName, platform, action)` plus a `summary` of platform×action counts. Optional `platform`, `action`, `activeOnly` (default false), `includeArchived` (default false), `maxWorkflows` (default 250, max 1000), `concurrency` (default 3, max 8). Read-only. Pairs with `n8n_scaffold_browser_bridge_node` when you need to add another call. Companion repo: [browser-bridge](https://github.com/solomonneas/browser-bridge).
145
+ **`n8n_audit_browser_bridge_usage`** - scans every workflow for nodes that invoke the `browser-bridge` CLI. Inspects `command` (Execute Command + SSH nodes) and `jsCode` / `pythonCode` / `functionCode` (Code + legacy Function nodes). Heuristic: `\bbrowser-bridge\.[cm]?js` followed by two kebab-slug args; the bare bin form is intentionally not detected to avoid false positives from path mentions like `cd /opt/browser-bridge`. Returns one finding per `(workflowId, nodeName, platform, action)` plus a `summary` of platform×action counts. Optional `platform`, `action`, `activeOnly` (default false), `includeArchived` (default false), `maxWorkflows` (default 250, max 1000), `concurrency` (default 3, max 8). Read-only. Pairs with `n8n_scaffold_browser_bridge_node` when you need to add another call. Companion repo: [browser-bridge](https://github.com/lidless-labs/browser-bridge).
100
146
 
101
- **`n8n_scaffold_browser_bridge_node`** - pure local generator (no n8n API call). Given `platform`, `action`, optional `input` JSON, and `mode: "code-node" | "execute-command"` (default `code-node`), emits a ready-to-paste n8n node JSON that mirrors `browser-bridge`'s `docs/n8n-usage.md` patterns. The Code node uses `spawnSync` with stdin JSON and surfaces `payload.exitCode` + `stderr` so downstream nodes can branch on `ok`. The Execute Command node uses a quoted `<<'JSON'` heredoc so the input passes through unmangled. Optional `bridgeDir` (default `/home/clawdbot/.openclaw/workspace/pipeline/work/browser-bridge`), `nodeName`, `position`. Platform/action are validated as kebab slugs - keeps them safe to interpolate into the shell command. Warns when `execute-command` is used with non-empty `input` (heredoc bakes the JSON in; no per-item upstream wiring).
147
+ **`n8n_scaffold_browser_bridge_node`** - pure local generator (no n8n API call). Given `platform`, `action`, optional `input` JSON, and `mode: "code-node" | "execute-command"` (default `code-node`), emits a ready-to-paste n8n node JSON that mirrors `browser-bridge`'s `docs/n8n-usage.md` patterns. The Code node uses `spawnSync` with stdin JSON and surfaces `payload.exitCode` + `stderr` so downstream nodes can branch on `ok`. The Execute Command node uses a quoted `<<'JSON'` heredoc so the input passes through unmangled. Optional `bridgeDir`, `nodeName`, `position`. Platform/action are validated as kebab slugs - keeps them safe to interpolate into the shell command. Warns when `execute-command` is used with non-empty `input` (heredoc bakes the JSON in; no per-item upstream wiring).
102
148
 
103
- **`n8n_trigger`** - two modes:
149
+ **`n8n_trigger`** - **write tool** (hidden unless `enableEdit`); requires `confirm: true`. Triggering runs the workflow's nodes (Code / Execute Command / HTTP, etc.) and POSTs to webhooks, all of which can have arbitrary real-world side effects, so it lives behind the same edit gate as the other write tools and refuses without `confirm: true`. `webhookPath` is validated client-side: it must resolve to a path under `/webhook`, `/webhook-test`, or `/form`, with no `..` traversal or scheme-relative `//host` form, so a confused agent cannot redirect the call off the base URL. Two modes:
104
150
  - `mode: "webhook"` + `webhookPath` - POST (or GET/PUT/DELETE) to the configured base URL + path, with an optional JSON `payload`. This is the reliable path.
105
151
  - `mode: "workflow"` + `workflowId` - attempts `POST /api/v1/workflows/:id/execute`. Pre-checks that the workflow is active and has a webhook/manual/form trigger. Most n8n builds don't expose this endpoint on the Public API and will 405; the tool surfaces a hint to switch to webhook mode.
106
152
 
107
- **`n8n_create_workflow`** - `POST /workflows`. Accepts the full output of `n8n_get_workflow` (with `includeDefinition=true`) directly. Strips read-only fields (`id`, `active`, `createdAt`, `updatedAt`, `isArchived`, `versionId`, `triggerCount`, `tags`, `shared`, `meta`, `pinData`) before POSTing - n8n enforces `additionalProperties: false` on the workflow schema and will 400 on any readOnly field. Runs `n8n_validate_workflow` on the proposed state as a pre-check; errors block, warnings pass through (pass `skipValidation: true` to bypass). No confirm gate - creation is non-destructive. The new workflow is created INACTIVE; call `n8n_activate` afterwards if you want triggers running. This is the primary restore path for `n8n_delete_workflow` snapshots: read the backup file into `definition` and call this tool. The restored workflow gets a new id.
153
+ **`n8n_create_workflow`** - `POST /workflows`. Creates from structured workflow JSON: `name`, `nodes`, `connections`, optional `settings` / `staticData`. Also accepts the full output of `n8n_get_workflow` (with `includeDefinition=true`) and backup snapshots directly. Strips read-only fields (`id`, `active`, `createdAt`, `updatedAt`, `isArchived`, `versionId`, `triggerCount`, `tags`, `shared`, `meta`, `pinData`) before POSTing - n8n enforces `additionalProperties: false` on the workflow schema and will 400 on any readOnly field. Runs `n8n_validate_workflow` on the proposed state as a pre-check; errors block, warnings pass through (pass `skipValidation: true` to bypass). Optional `dryRun:true` returns the cleaned POST body and validation issues without writing (no `confirm` needed for a dry run). Optional `projectId` and `folderId` are sent as create-target query params. Requires `confirm: true` to actually write - the tool accepts an arbitrary `nodes` graph that will live on the server, so an unconfirmed call (without `dryRun`) returns `ok: false` and never touches the API. The new workflow is created INACTIVE; call `n8n_activate` afterwards if you want triggers running. This is also the primary restore path for `n8n_delete_workflow` snapshots: read the backup file into `definition` and call this tool. The restored workflow gets a new id.
108
154
 
109
- **`n8n_activate`** / **`n8n_deactivate`** - idempotent. Deactivating does not cancel running executions.
155
+ **`n8n_activate`** / **`n8n_deactivate`** - idempotent; both require `confirm: true`. Activating arms the workflow's triggers, so its nodes can start running automatically (effectively arming arbitrary-code execution); deactivating halts that automation. Deactivating does not cancel running executions.
110
156
 
111
157
  **`n8n_save_workflow`** - before writing: fetches the current version, snapshots it to `backupDir` as `<id>-<timestamp>.json` (mode 0600), runs `validateWorkflow` on the proposed state, and aborts on error-severity issues (pass `skipValidation: true` to bypass). Requires `confirm: true` to actually PUT; calling with `confirm: false` returns `ok: false` and never touches the API (omitting `confirm` is rejected at the MCP schema layer). Response includes the backup path and a `restoreHint`.
112
158
 
113
- **`n8n_archive_workflow`** - `POST /workflows/{id}/archive`. Soft-deletes a workflow: triggers stop firing, the workflow disappears from the default UI list, but the definition and execution history are preserved. Idempotent (archiving an already-archived workflow returns the current state). No confirm gate - this is the safe cleanup path. Archiving deactivates as a side effect; the response surfaces `active: false` explicitly. Returns `ok: false` with `reason: "not_found"` on 404.
159
+ **`n8n_archive_workflow`** - `POST /workflows/{id}/archive`. Soft-deletes a workflow: triggers stop firing, the workflow disappears from the default UI list, but the definition and execution history are preserved. Idempotent (archiving an already-archived workflow returns the current state). Requires `confirm: true` (it deactivates and soft-deletes the workflow); reversible via `n8n_unarchive_workflow`. Archiving deactivates as a side effect; the response surfaces `active: false` explicitly. Returns `ok: false` with `reason: "not_found"` on 404.
114
160
 
115
- **`n8n_unarchive_workflow`** - `POST /workflows/{id}/unarchive`. Restores an archived workflow. Does NOT reactivate - triggers stay off until you call `n8n_activate` explicitly. Returns `ok: false` with `reason: "not_found"` on 404.
161
+ **`n8n_unarchive_workflow`** - `POST /workflows/{id}/unarchive`. Restores an archived workflow. Does NOT reactivate - triggers stay off until you call `n8n_activate` explicitly. Requires `confirm: true`; omitting it or passing `false` returns `ok: false` and never touches the API. Returns `ok: false` with `reason: "not_found"` on 404.
116
162
 
117
163
  **`n8n_delete_workflow`** - `DELETE /workflows/{id}`. Permanent, irreversible. Before firing the DELETE: fetches the current workflow and snapshots it to `backupDir` as `<id>-DELETED-<timestamp>.json` (mode 0600). If the snapshot can't be written, the DELETE is aborted - there is no un-safety-netted path. Requires `confirm: true`; omitting it or passing `false` returns `ok: false` and never touches the API. Returns `ok: false` with `reason: "not_found"` on 404 (either before or after the snapshot). **Restore is one-call via `n8n_create_workflow`** with the snapshot contents; the restored workflow gets a new id and is created inactive. Deleting does NOT cancel running executions - use `n8n_list_executions(workflowId, status='running')` + `n8n_cancel_execution` first if needed. **Prefer `n8n_archive_workflow` for cleanup** if you want to preserve the original id.
118
164
 
119
- **`n8n_cancel_execution`** - `POST /executions/{id}/stop`. Closes the triage loop after `n8n_search_executions` locates a stuck run. Returns a success summary with the execution's final status, or `ok: false` with `reason: "not_found_or_finished"` if the id no longer matches a running execution (404).
165
+ **`n8n_cancel_execution`** - `POST /executions/{id}/stop`. Closes the triage loop after `n8n_search_executions` locates a stuck run. Requires `confirm: true`; omitting it or passing `false` returns `ok: false` and never touches the API. Cancellation can leave a multi-step automation partially applied (e.g. a record written but its follow-up notification or cleanup never run). Returns a success summary with the execution's final status, or `ok: false` with `reason: "not_found_or_finished"` if the id no longer matches a running execution (404).
120
166
 
121
- **`n8n_retry_execution`** - `POST /executions/{id}/retry`. Creates a NEW execution - the response surfaces both `originalExecutionId` and `newExecutionId` so agents can follow up with `n8n_get_execution` on the retry. Optional `loadWorkflow: true` retries against the currently saved workflow instead of the version captured at original execution time. Returns `ok: false` with `reason: "not_found"` on 404 or `reason: "not_retryable"` on 409 (e.g. still running); all other API errors rethrow.
167
+ **`n8n_retry_execution`** - `POST /executions/{id}/retry`. Creates a NEW execution - the response surfaces both `originalExecutionId` and `newExecutionId` so agents can follow up with `n8n_get_execution` on the retry. Requires `confirm: true`; omitting it or passing `false` returns `ok: false` and never touches the API. Each retry may re-run side effects (HTTP calls, DB writes, etc). Verify the workflow is safe to re-run before confirming. Optional `loadWorkflow: true` retries against the currently saved workflow instead of the version captured at original execution time. Returns `ok: false` with `reason: "not_found"` on 404 or `reason: "not_retryable"` on 409 (e.g. still running); all other API errors rethrow.
122
168
 
123
169
  **`n8n_delete_execution`** - `DELETE /executions/{id}`. Permanently removes an execution record: logs, per-node run data, and error payloads are erased from n8n. Requires `confirm: true` to actually delete; calling with `confirm: false` returns `ok: false` and never touches the API (omitting `confirm` is rejected at the MCP schema layer). Returns `ok: false` with `reason: "not_found"` on 404; all other API errors rethrow. Not idempotent from an agent's perspective: the record is gone after the first successful call, so fetch `n8n_get_execution` first if you may need it later.
124
170
 
@@ -140,11 +186,11 @@ Write tools are hidden unless `N8N_ENABLE_EDIT=true`.
140
186
 
141
187
  **`n8n_get_workflow_tags`** - `GET /workflows/{id}/tags`. Returns the array of tag objects currently attached. Pairs with `n8n_set_workflow_tags` for diffs and reattach flows.
142
188
 
143
- **`n8n_create_tag`** - `POST /tags`. No confirm gate - creating a tag is reversible via `n8n_delete_tag` and harmless on its own. The name is trimmed before send. Returns `ok: false` with `reason: "conflict"` on 409 (tag with this name already exists); use `n8n_list_tags` to find the existing id.
189
+ **`n8n_create_tag`** - `POST /tags`. Requires `confirm: true` (consistent with the other mutating tag tools); reversible via `n8n_delete_tag`. The name is trimmed before send. Returns `ok: false` with `reason: "conflict"` on 409 (tag with this name already exists); use `n8n_list_tags` to find the existing id.
144
190
 
145
191
  **`n8n_delete_tag`** - `DELETE /tags/{id}`. Confirm-gated. **Cascades**: n8n removes the tag from every workflow it was attached to. The workflows themselves are NOT deleted, only the tag association. Returns `ok: false` with `reason: "not_found"` on 404. To find affected workflows beforehand, use `n8n_list_workflows(tags=<name>)` or scan `n8n_get_workflow_tags`.
146
192
 
147
- **`n8n_set_workflow_tags`** - `PUT /workflows/{id}/tags`. **REPLACES** the workflow's tag set (not append) - pass the full desired list. Empty `tagIds: []` clears all tags. Tag ids are deduped before send. No confirm gate (reversible by re-setting). Returns `ok: false` with `reason: "not_found"` on 404 (the workflow id OR one of the tag ids does not exist; verify both with `n8n_list_workflows` and `n8n_list_tags`).
193
+ **`n8n_set_workflow_tags`** - `PUT /workflows/{id}/tags`. **REPLACES** the workflow's tag set (not append) - pass the full desired list. Empty `tagIds: []` clears all tags. Tag ids are deduped before send. Requires `confirm: true` (reversible by re-setting). Returns `ok: false` with `reason: "not_found"` on 404 (the workflow id OR one of the tag ids does not exist; verify both with `n8n_list_workflows` and `n8n_list_tags`).
148
194
 
149
195
  **`n8n_list_credentials`** - `GET /credentials`. Returns metadata only - n8n's API explicitly excludes the `data` field (encrypted secrets) from list responses, and the tool layer strips `data` defensively in case of a future regression. Each row: `{id, name, type, createdAt, updatedAt, shared[]}`. Optional `limit` (default 100, max 250) and `cursor`. Requires the API key to belong to an instance owner or admin - non-admin keys get `ok: false, reason: "unauthorized"` with a clear hint.
150
196
 
@@ -160,36 +206,13 @@ Write tools are hidden unless `N8N_ENABLE_EDIT=true`.
160
206
 
161
207
  </details>
162
208
 
163
- ## Security model
164
-
165
- Two flags gate write access, with deliberately different blast radii:
166
-
167
- - **`enableEdit`** (default `false`) - exposes the workflow + execution lifecycle write tools (create/save/archive/delete workflows, cancel/retry/delete executions, pin/unpin node data, tag CRUD). Destructive tools are confirm-gated and the destructive workflow ones snapshot to `backupDir` first.
168
- - **`enableCredentialsWrite`** (default `false`) - **second gate**, on top of `enableEdit`, required to expose `n8n_create_credential` and `n8n_delete_credential`. An agent that has been overprovisioned with `enableEdit` cannot inject or destroy credentials without this separate, deliberate config change.
169
-
170
- Both flags must be true for credential writes to register. The credential **read** tools (`list-credentials`, `get-credential-schema`, `find-workflows-using-credential`) and the disabled-node scanner are always available regardless.
171
-
172
- Why credentials get a second gate:
173
- 1. `create-credential` is the only tool in this package where agent input contains plaintext secrets. A prompt-injected or confused agent with `enableEdit` shouldn't be able to inject credentials.
174
- 2. `delete-credential` cascades - every workflow referencing the credential fails on its next run. The blast radius is wider than any single workflow operation.
175
-
176
- Defense-in-depth on `data`:
177
- - n8n's OpenAPI marks `data` as `writeOnly` - the API contract excludes it from every response. We trust but verify: **the tool layer strips `data` from every credential response before surfacing**, including success paths and the deleted-credential echo, so a future n8n regression can't leak secrets through us.
178
- - On `create-credential` errors, the n8n response body (which can echo back fragments of submitted `data` on validation 400s) is replaced at the client layer with a status-only error message. The tool surfaces `status` + `path` only. Tests assert no portion of a forced-400 request body reaches the tool response.
179
-
180
- ## Install
181
-
182
- ```bash
183
- npm install -g n8n-ops-mcp
184
- ```
185
-
186
209
  ## Configuration
187
210
 
188
211
  Generate an API key in n8n under **Settings → API**, then set these env vars in your MCP client config:
189
212
 
190
213
  | Variable | Required | Default | Description |
191
214
  |---|---|---|---|
192
- | `N8N_BASE_URL` | yes | - | n8n base URL, e.g. `http://localhost:5678` |
215
+ | `N8N_BASE_URL` | yes | - | n8n base URL, e.g. `https://n8n.example.com` |
193
216
  | `N8N_API_KEY` | yes | - | n8n Public API key (`X-N8N-API-KEY`) |
194
217
  | `N8N_ENABLE_EDIT` | no | `false` | Expose write tools |
195
218
  | `N8N_ENABLE_CREDENTIALS_WRITE` | no | `false` | Second gate (on top of `N8N_ENABLE_EDIT`) for `n8n_create_credential` and `n8n_delete_credential`. See [Security model](#security-model). |
@@ -197,6 +220,35 @@ Generate an API key in n8n under **Settings → API**, then set these env vars i
197
220
  | `N8N_MAX_EXECUTION_LOG_BYTES` | no | `65536` | Cap on inline execution log bytes |
198
221
  | `N8N_REQUEST_TIMEOUT_MS` | no | `15000` | HTTP timeout for n8n API calls |
199
222
 
223
+ ## CLI
224
+
225
+ `n8nctrl` is the standard read-only **operator control CLI** for shells, cron, and CI. It talks to the same n8n Public API as the MCP server and shares the same client core, so what the agent can read, you can read from a terminal. It exposes only the read/report tools - no create, save, archive, delete, cancel, retry, or trigger. The older `n8n-ops` bin remains a compatibility alias.
226
+
227
+ ```bash
228
+ # installed globally, the standard bin is `n8nctrl`:
229
+ n8nctrl workflows list --active
230
+ n8nctrl workflows get <id> --full
231
+ n8nctrl workflows validate <id>
232
+ n8nctrl executions list --status error --since 24
233
+ n8nctrl executions search "ECONNREFUSED" --scope all
234
+ n8nctrl executions stats --since 48
235
+ n8nctrl webhooks list
236
+ n8nctrl schedules list
237
+ n8nctrl tags list
238
+ n8nctrl credentials find-usage <credentialId>
239
+ n8nctrl nodes find n8n-nodes-base.slack --contains
240
+ n8nctrl nodes check-disabled
241
+ n8nctrl audit run # exit 1 if the backend is unreachable (cron-friendly)
242
+ n8nctrl audit browser-bridge
243
+ n8nctrl --json tags list # raw JSON for piping
244
+ ```
245
+
246
+ Run `n8nctrl help` for the full command and flag list. Configure with the same `N8N_BASE_URL` / `N8N_API_KEY` env vars as the MCP server (see the table above). Exit codes: `0` success, `1` runtime error (backend unreachable or a call failed), `2` usage error (unknown command/flag or bad value).
247
+
248
+ ### Starting the MCP adapter
249
+
250
+ `n8nctrl mcp` starts the stdio MCP adapter. The `n8n-ops-mcp` bin remains supported for existing MCP client configs and package launchers. If a launcher referenced the built file path `dist/mcp-server.js` directly, point it at `dist/mcp-bin.js` (or `dist/cli.js mcp`); launchers that use the `n8n-ops-mcp` bin name need no change.
251
+
200
252
  ### Claude Desktop
201
253
 
202
254
  Add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
@@ -205,9 +257,10 @@ Add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS)
205
257
  {
206
258
  "mcpServers": {
207
259
  "n8n": {
208
- "command": "n8n-ops-mcp",
260
+ "command": "npx",
261
+ "args": ["-y", "n8n-ops-mcp"],
209
262
  "env": {
210
- "N8N_BASE_URL": "http://localhost:5678",
263
+ "N8N_BASE_URL": "https://n8n.example.com",
211
264
  "N8N_API_KEY": "your-api-key-here"
212
265
  }
213
266
  }
@@ -219,9 +272,9 @@ Add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS)
219
272
 
220
273
  ```bash
221
274
  claude mcp add n8n \
222
- --env N8N_BASE_URL=http://localhost:5678 \
275
+ --env N8N_BASE_URL=https://n8n.example.com \
223
276
  --env N8N_API_KEY=your-api-key-here \
224
- -- n8n-ops-mcp
277
+ -- npx -y n8n-ops-mcp
225
278
  ```
226
279
 
227
280
  Add `--scope user` to make it available from any directory instead of only the current project.
@@ -230,16 +283,16 @@ Add `--scope user` to make it available from any directory instead of only the c
230
283
 
231
284
  ```bash
232
285
  codex mcp add n8n \
233
- --env N8N_BASE_URL=http://localhost:5678 \
286
+ --env N8N_BASE_URL=https://n8n.example.com \
234
287
  --env N8N_API_KEY=your-api-key-here \
235
- -- n8n-ops-mcp
288
+ -- npx -y n8n-ops-mcp
236
289
  ```
237
290
 
238
291
  Writes the entry to `~/.codex/config.toml` under `[mcp_servers.n8n]`. Verify with `codex mcp list`.
239
292
 
240
293
  ### Cursor / Windsurf / other MCP hosts
241
294
 
242
- Any MCP-compatible client that accepts a stdio command + env will work. Point it at the `n8n-ops-mcp` binary with `N8N_BASE_URL` and `N8N_API_KEY` in the environment.
295
+ Any MCP-compatible client that accepts a stdio command + env will work. Point it at `npx -y n8n-ops-mcp` (or the globally installed `n8n-ops-mcp` binary) with `N8N_BASE_URL` and `N8N_API_KEY` in the environment.
243
296
 
244
297
  <details>
245
298
  <summary><b>Hermes Agent</b></summary>
@@ -249,9 +302,10 @@ Any MCP-compatible client that accepts a stdio command + env will work. Point it
249
302
  ```yaml
250
303
  mcp_servers:
251
304
  n8n:
252
- command: "n8n-ops-mcp"
305
+ command: "npx"
306
+ args: ["-y", "n8n-ops-mcp"]
253
307
  env:
254
- N8N_BASE_URL: "http://localhost:5678"
308
+ N8N_BASE_URL: "https://n8n.example.com"
255
309
  N8N_API_KEY: "your-api-key-here"
256
310
  ```
257
311
 
@@ -265,7 +319,7 @@ Then reload from inside a session:
265
319
 
266
320
  ### OpenClaw (first-class plugin)
267
321
 
268
- n8n-ops-mcp was built for OpenClaw and ships as a first-class plugin - not an MCP bridge - so it shares the gateway's process, auth profiles, and hooks.
322
+ n8nctrl ships as a first-class OpenClaw plugin through the `n8n-ops-mcp` package - not an MCP bridge - so it shares the gateway's process, auth profiles, and hooks.
269
323
 
270
324
  ```bash
271
325
  openclaw plugins install clawhub:n8n-ops-mcp
@@ -280,7 +334,7 @@ Add the config block to `~/.openclaw/openclaw.json`:
280
334
  "n8n": {
281
335
  "enabled": true,
282
336
  "config": {
283
- "baseUrl": "http://your-n8n-host:5678",
337
+ "baseUrl": "https://n8n.example.com",
284
338
  "enableEdit": false
285
339
  }
286
340
  }
@@ -293,7 +347,7 @@ Put the API key in your OpenClaw workspace env:
293
347
 
294
348
  ```bash
295
349
  # ~/.openclaw/workspace/.env
296
- N8N_API_KEY=eyJhbGciOi...
350
+ N8N_API_KEY=your-api-key-here
297
351
  ```
298
352
 
299
353
  Restart the gateway:
@@ -320,7 +374,7 @@ If you want to point OpenClaw at a local clone instead of the registry:
320
374
  "n8n": {
321
375
  "enabled": true,
322
376
  "config": {
323
- "baseUrl": "http://your-n8n-host:5678",
377
+ "baseUrl": "https://n8n.example.com",
324
378
  "enableEdit": false
325
379
  }
326
380
  }
@@ -331,6 +385,23 @@ If you want to point OpenClaw at a local clone instead of the registry:
331
385
 
332
386
  </details>
333
387
 
388
+ ## Security model
389
+
390
+ Two flags gate write access, with deliberately different blast radii:
391
+
392
+ - **`enableEdit`** (default `false`) - exposes the workflow + execution lifecycle write tools (create/save/archive/delete workflows, activate/deactivate, **trigger**, cancel/retry/delete executions, pin/unpin node data, tag CRUD). `n8n_trigger` is gated here too: running a workflow executes arbitrary Code / Execute Command / HTTP nodes and POSTs to webhooks, so it is treated as a write. Mutating tools are confirm-gated (including `trigger`, `activate`, `deactivate`, `archive`, `create_workflow`, `create_tag`, and `set_workflow_tags`), and the destructive workflow ones snapshot to `backupDir` first. The read-only `n8n_diff_workflow` confines `snapshotPath` reads to `backupDir` so it cannot be turned into an arbitrary file-read primitive.
393
+ - **`enableCredentialsWrite`** (default `false`) - **second gate**, on top of `enableEdit`, required to expose `n8n_create_credential` and `n8n_delete_credential`. An agent that has been overprovisioned with `enableEdit` cannot inject or destroy credentials without this separate, deliberate config change.
394
+
395
+ Both flags must be true for credential writes to register. The credential **read** tools (`list-credentials`, `get-credential-schema`, `find-workflows-using-credential`) and the disabled-node scanner are always available regardless.
396
+
397
+ Why credentials get a second gate:
398
+ 1. `create-credential` is the only tool in this package where agent input contains plaintext secrets. A prompt-injected or confused agent with `enableEdit` shouldn't be able to inject credentials.
399
+ 2. `delete-credential` cascades - every workflow referencing the credential fails on its next run. The blast radius is wider than any single workflow operation.
400
+
401
+ Defense-in-depth on `data`:
402
+ - n8n's OpenAPI marks `data` as `writeOnly` - the API contract excludes it from every response. We trust but verify: **the tool layer strips `data` from every credential response before surfacing**, including success paths and the deleted-credential echo, so a future n8n regression can't leak secrets through us.
403
+ - On `create-credential` errors, the n8n response body (which can echo back fragments of submitted `data` on validation 400s) is replaced at the client layer with a status-only error message. The tool surfaces `status` + `path` only. Tests assert no portion of a forced-400 request body reaches the tool response.
404
+
334
405
  ## Example prompts
335
406
 
336
407
  > What n8n workflows broke today?
@@ -341,9 +412,9 @@ Calls `n8n_list_executions` with `status=error`, then `n8n_get_execution` for th
341
412
 
342
413
  Calls `n8n_search_executions` with `query: "ECONNREFUSED"`.
343
414
 
344
- > Trigger the "nightly intel" workflow
415
+ > Trigger the "nightly intel" workflow *(requires `N8N_ENABLE_EDIT=true`)*
345
416
 
346
- Calls `n8n_list_webhooks` to find the path, then `n8n_trigger` with `mode=webhook`.
417
+ Calls `n8n_list_webhooks` to find the path, then `n8n_trigger` with `mode=webhook` and `confirm: true`.
347
418
 
348
419
  > What's running at 3am?
349
420
 
@@ -353,33 +424,25 @@ Calls `n8n_list_schedules`, then filters the result for any schedule whose descr
353
424
 
354
425
  Calls `n8n_diff_workflow` with `id` and `snapshotPath` pointing to the backup file. Returns added/removed/modified nodes with parameter-level field paths.
355
426
 
356
- > Where am I calling Linktree sync from?
357
-
358
- Calls `n8n_audit_browser_bridge_usage` with `platform: "linktree"` to list every node (across all workflows) that invokes `browser-bridge linktree <action>`.
359
-
360
- > Add a CoderLegion `scan-comments` step to a new workflow
427
+ > Audit my workflows for deprecated Code-node API usage
361
428
 
362
- Calls `n8n_scaffold_browser_bridge_node` with `platform: "coderlegion"`, `action: "scan-comments"`, `input: {limit: 5}` to get a Code node JSON, then pastes it into n8n.
429
+ Calls `n8n_list_workflows` then `n8n_validate_workflow` per id, filters for `code-node-old-node-ref` and `code-node-items-global` warnings.
363
430
 
364
- > Pin a sample browser-bridge response on the "BB call" node so I can iterate on downstream parsing without re-spawning the browser *(requires `N8N_ENABLE_EDIT=true`)*
431
+ > Which workflows are flaky this week?
365
432
 
366
- Calls `n8n_get_execution` to grab the most recent successful output of the node, then `n8n_pin_node_data` with `nodeName: "BB call"`, `data: <captured items>`, `confirm: true`. Clear later via `n8n_unpin_node_data`.
433
+ Calls `n8n_execution_stats` with `sinceHours: 168`, then sorts by `failureRate`.
367
434
 
368
- > Audit my workflows for deprecated Code-node API usage
435
+ > I'm rotating Slack credentials - where do I need to update?
369
436
 
370
- Calls `n8n_list_workflows` then `n8n_validate_workflow` per id, filters for `code-node-old-node-ref` and `code-node-items-global` warnings.
437
+ Calls `n8n_find_workflows_using_credential` with the credential id to enumerate the blast radius before you touch anything.
371
438
 
372
439
  > Deactivate the "experimental-bot" workflow *(requires `N8N_ENABLE_EDIT=true`)*
373
440
 
374
- Calls `n8n_list_workflows` with a name filter, then `n8n_deactivate` on the matching id.
441
+ Calls `n8n_list_workflows` with a name filter, then `n8n_deactivate` with `confirm: true` on the matching id.
375
442
 
376
443
  > Kill the execution stuck on ECONNREFUSED *(requires `N8N_ENABLE_EDIT=true`)*
377
444
 
378
- Calls `n8n_search_executions` with `query: "ECONNREFUSED"`, then `n8n_cancel_execution` on the match.
379
-
380
- > Retry yesterday's failed "nightly intel" run against the current workflow *(requires `N8N_ENABLE_EDIT=true`)*
381
-
382
- Calls `n8n_search_executions` to find the failed id, then `n8n_retry_execution` with `loadWorkflow: true`.
445
+ Calls `n8n_search_executions` with `query: "ECONNREFUSED"`, then `n8n_cancel_execution` with `confirm: true` on the match.
383
446
 
384
447
  > Purge the noisy test-run execution logs from last week *(requires `N8N_ENABLE_EDIT=true`)*
385
448
 
@@ -387,19 +450,27 @@ Calls `n8n_search_executions` to find the ids, then `n8n_delete_executions` with
387
450
 
388
451
  > Archive the old "staging-bot" workflow - I might need it back someday *(requires `N8N_ENABLE_EDIT=true`)*
389
452
 
390
- Calls `n8n_list_workflows` with a name filter, then `n8n_archive_workflow` on the match. Reversible via `n8n_unarchive_workflow` (you'll still need `n8n_activate` to turn triggers back on).
453
+ Calls `n8n_list_workflows` with a name filter, then `n8n_archive_workflow` with `confirm: true` on the match. Reversible via `n8n_unarchive_workflow` with `confirm: true` (you'll still need `n8n_activate` with `confirm: true` to turn triggers back on).
391
454
 
392
455
  > Delete the abandoned "poc-scraper" workflow - it's been dead for months *(requires `N8N_ENABLE_EDIT=true`)*
393
456
 
394
457
  Calls `n8n_list_workflows` to find the id, then `n8n_delete_workflow` with `confirm: true`. A snapshot lands in `backupDir` first; restore is one-call via `n8n_create_workflow` with the snapshot. Prefer `n8n_archive_workflow` if you want to preserve the original id.
395
458
 
396
- > Restore the workflow I accidentally deleted yesterday - backup is at `~/.n8n-backups/wf-42-DELETED-2026-04-22_15-00-00.json` *(requires `N8N_ENABLE_EDIT=true`)*
459
+ ## Why not the bigger n8n MCP projects?
397
460
 
398
- Reads the backup file, calls `n8n_create_workflow` with `definition=<backup contents>`. Read-only fields are stripped automatically; the restored workflow gets a new id and starts inactive. Call `n8n_activate` on the new id to re-enable triggers.
461
+ n8nctrl is deliberately narrow. It is for **operating** the n8n you already run, not for authoring new flows from a node catalog.
399
462
 
400
- > Clone workflow "intel-nightly" to "intel-nightly-staging" for testing *(requires `N8N_ENABLE_EDIT=true`)*
463
+ - For a catalog/docs tool that indexes n8n's node library so an agent can scaffold new workflows from node metadata, see [n8n-mcp](https://www.npmjs.com/package/n8n-mcp). That is the right tool when you want the agent to know about every node type and its parameters.
464
+ - n8nctrl is the right tool when you want the agent or CLI to answer "what's broken, what changed, what's risky, what's scheduled" against your live instance and to act on it: triage failed executions, diff against backups, scan for security and credential blast radius, and edit workflows behind explicit, snapshotted write gates.
401
465
 
402
- Calls `n8n_get_workflow` with `includeDefinition=true`, changes `name` to "intel-nightly-staging" in the definition, then `n8n_create_workflow`. The new workflow is a full copy, inactive, with a fresh id.
466
+ The two are complementary. One helps build; this one helps run.
467
+
468
+ ## What n8nctrl is not
469
+
470
+ - **Not a node-catalog or workflow-authoring assistant.** It does not index n8n's node library or suggest node parameters. Use [n8n-mcp](https://www.npmjs.com/package/n8n-mcp) for that.
471
+ - **Not a replacement for the n8n UI or its REST API.** It is a thin, opinionated operator layer over the n8n Public API, focused on ops questions and safe writes.
472
+ - **Not a hosted service.** No daemon, no telemetry. It runs as a local stdio process (or an in-process OpenClaw plugin) and talks only to the n8n instance you configure.
473
+ - **Not a credential exfiltration path.** Credential reads return metadata only; credential writes are double-gated and `data` is stripped from every response branch. See the [Security model](#security-model).
403
474
 
404
475
  ## Development
405
476
 
@@ -415,16 +486,128 @@ npm start # node dist/mcp-server.js (post-build)
415
486
  Or install from source:
416
487
 
417
488
  ```bash
418
- git clone https://github.com/solomonneas/n8n-ops-mcp.git
419
- cd n8n-ops-mcp
489
+ git clone https://github.com/lidless-labs/n8nctrl.git
490
+ cd n8nctrl
420
491
  npm install
421
492
  npm run build
422
493
  ```
423
494
 
495
+ ## Contributing
496
+
497
+ Patches welcome. See [CONTRIBUTING.md](./CONTRIBUTING.md) for what lands easily, [SECURITY.md](./SECURITY.md) for how to report a vulnerability, and the [Code of Conduct](./CODE_OF_CONDUCT.md).
498
+
424
499
  ## Changelog
425
500
 
426
501
  See [CHANGELOG.md](./CHANGELOG.md) for the full version history.
427
502
 
428
503
  ## License
429
504
 
430
- MIT
505
+ MIT. See [LICENSE](./LICENSE).
506
+
507
+ ---
508
+
509
+ <p align="center"><a href="https://lidless.dev">Part of <strong>Lidless Labs</strong></a> &middot; the eye does not close</p>
510
+
511
+ <p align="center"><sub><strong>Network:</strong> <a href="https://github.com/lidless-labs/librenmsctrl">librenmsctrl</a> &middot; <a href="https://github.com/lidless-labs/watchtower">watchtower</a> &middot; <a href="https://github.com/lidless-labs/portgrid">portgrid</a> &middot; <a href="https://github.com/lidless-labs/cutsheet">cutsheet</a> &middot; <a href="https://github.com/lidless-labs/eero-cli">eero-cli</a></sub></p>
512
+
513
+ <p align="center"><sub><a href="https://lidless.dev">All tools</a> &middot; <a href="https://github.com/lidless-labs">Lidless Labs on GitHub</a></sub></p>
514
+
515
+ ## HTTP mode
516
+
517
+ Run a shared Streamable HTTP server with `node dist/mcp-bin.js --http`.
518
+ The existing `node dist/mcp-bin.js` command continues to use stdio.
519
+
520
+ Set `N8N_BASE_URL`, `N8N_API_KEY` (or the variable selected by
521
+ `N8N_API_KEY_ENV`), and an independent random `N8N_MCP_HTTP_TOKEN`.
522
+ Startup rejects blank HTTP tokens and tokens equal to the API key or URL
523
+ credentials. Bearer tokens use SHA-256 digests and constant-time comparison.
524
+
525
+ | Variable | Default | Purpose |
526
+ | --- | --- | --- |
527
+ | `N8N_MCP_HTTP_TOKEN` | Required | Independent bearer token, at least 32 characters |
528
+ | `N8N_MCP_HTTP_HOST` | IPv4 loopback | Specific listener bind host; wildcard addresses are refused |
529
+ | `N8N_MCP_HTTP_PORT` | `3117` | TCP port, or `0` for an available port |
530
+
531
+ The resolved address is printed to stderr. `/mcp` requires bearer authentication
532
+ on every POST, GET, and DELETE. `GET /healthz` returns only `{"status":"ok"}`
533
+ without authentication. Host checks reject DNS rebinding. Supplied Origins must
534
+ be HTTP or HTTPS loopback origins. Bodies are limited to 1 MiB, sessions to 128,
535
+ and idle sessions expire after 30 minutes on a minute timer. Active POST calls
536
+ are excluded from idle expiry. SIGTERM and SIGINT close sessions and the listener.
537
+
538
+ Configuration, including `N8N_ENABLE_EDIT`, `N8N_ENABLE_CREDENTIALS_WRITE`, and
539
+ `N8N_BACKUP_DIR`, is read once at startup and used by every session. Credential
540
+ writes require both write gates. Every mutation still requires `confirm: true`
541
+ on that call. Each session has its own MCP server, lazy API client, and tool
542
+ instances. There are no pending approval tokens or shared tool-visibility sets.
543
+ HTTP mutation calls are serialized across sessions so pin/unpin read-modify-write
544
+ operations cannot overwrite another HTTP call's update. HTTP save/delete backups
545
+ use exclusive writes and UUID suffixes to prevent filename collisions. The backup
546
+ root and file-read confinement stay unchanged. Other processes and direct n8n
547
+ clients can still race with this process's writes.
548
+
549
+ All clients holding the bearer token share the same n8n account and privileges.
550
+ Keep the default loopback binding. Remote access needs a trusted TLS proxy or
551
+ tunnel and network access controls. This listener provides no TLS or per-client
552
+ accounts. Preserve an allowed Host header through a proxy. Clients must initialize
553
+ again after expiry or restart.
554
+
555
+ ### Claude Code
556
+
557
+ Add this entry under `mcpServers` in your client configuration:
558
+
559
+ ```json
560
+ {
561
+ "mcpServers": {
562
+ "n8n": {
563
+ "type": "http",
564
+ "url": "http://localhost:3117/mcp",
565
+ "headersHelper": "/path/to/helper N8N_MCP_HTTP_TOKEN"
566
+ }
567
+ }
568
+ }
569
+ ```
570
+
571
+ The executable helper reads the named environment variable and prints
572
+ `{"Authorization":"Bearer ..."}`. For example, save this as the helper and make
573
+ it executable. Keep its environment private:
574
+
575
+ ```python
576
+ #!/usr/bin/env python3
577
+ import json
578
+ import os
579
+ import sys
580
+ print(json.dumps({"Authorization": "Bearer " + os.environ[sys.argv[1]]}))
581
+ ```
582
+
583
+ ### Codex
584
+
585
+ Export `N8N_MCP_HTTP_TOKEN` in the environment launching Codex and configure:
586
+
587
+ ```toml
588
+ [mcp_servers.n8n]
589
+ url = "http://localhost:3117/mcp"
590
+ bearer_token_env_var = "N8N_MCP_HTTP_TOKEN"
591
+ ```
592
+
593
+ The client needs only the HTTP token. Upstream credentials stay on the server.
594
+
595
+ ### systemd user service
596
+
597
+ See [the example unit](docs/systemd/n8n-ops-mcp-http.service). Adjust its generic
598
+ installation paths and build the project there. Create the EnvironmentFile at
599
+ `%h/.config/n8n-ops-mcp/http.env` with mode `0600`, containing:
600
+
601
+ ```sh
602
+ N8N_BASE_URL=https://n8n.example.com
603
+ N8N_API_KEY=REPLACE_WITH_UPSTREAM_KEY
604
+ N8N_MCP_HTTP_TOKEN=REPLACE_WITH_INDEPENDENT_RANDOM_TOKEN
605
+ N8N_MCP_HTTP_PORT=3117
606
+ N8N_ENABLE_EDIT=true
607
+ N8N_ENABLE_CREDENTIALS_WRITE=false
608
+ N8N_BACKUP_DIR=/var/lib/n8n-ops-mcp/backups
609
+ ```
610
+
611
+ The backup directory must be writable by the service user. The unit sets
612
+ `NoNewPrivileges=true`, `PrivateTmp=true`, and `UMask=0077`. Installing or starting
613
+ it is a separate operator action.