n8n-ops-mcp 0.14.2 → 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 +123 -8
- package/dist/cli.js +748 -121
- package/dist/index.js +5637 -0
- package/dist/mcp-bin.js +2807 -1506
- package/dist/mcp-server.js +748 -119
- package/package.json +6 -8
- package/src/cli.ts +4 -2
- package/src/client.ts +162 -38
- package/src/config.ts +141 -0
- package/src/http.ts +251 -0
- package/src/tools/archive-workflow.ts +16 -3
- package/src/tools/cancel-execution.ts +15 -2
- package/src/tools/delete-workflow.ts +9 -6
- package/src/tools/result.ts +16 -3
- package/src/tools/retry-execution.ts +16 -2
- package/src/tools/save-workflow.ts +8 -3
package/README.md
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
<img src="docs/assets/n8nctrl-social-preview.jpg" alt="n8nctrl banner" width="900">
|
|
3
3
|
</p>
|
|
4
4
|
|
|
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>
|
|
5
8
|
<h1 align="center">n8nctrl</h1>
|
|
6
9
|
|
|
7
10
|
<p align="center">
|
|
@@ -65,6 +68,10 @@ Then ask your agent:
|
|
|
65
68
|
|
|
66
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.
|
|
67
70
|
|
|
71
|
+

|
|
72
|
+
|
|
73
|
+
Generated from [`docs/assets/workflows/n8n-ops-loop.json`](docs/assets/workflows/n8n-ops-loop.json) with `lidless workflow`.
|
|
74
|
+
|
|
68
75
|
## Tools
|
|
69
76
|
|
|
70
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.
|
|
@@ -97,10 +104,10 @@ It calls `n8n_list_executions` with `status=error`, then `n8n_get_execution` on
|
|
|
97
104
|
| `n8n_deactivate` | Disable a workflow's triggers (confirm-gated) | ✓ |
|
|
98
105
|
| `n8n_save_workflow` | Overwrite a workflow with auto-backup + validation + confirm gate | ✓ |
|
|
99
106
|
| `n8n_archive_workflow` | Soft-delete a workflow (confirm-gated; reversible; preserves id) | ✓ |
|
|
100
|
-
| `n8n_unarchive_workflow` | Restore an archived workflow (does NOT reactivate) | ✓ |
|
|
107
|
+
| `n8n_unarchive_workflow` | Restore an archived workflow (confirm-gated; does NOT reactivate) | ✓ |
|
|
101
108
|
| `n8n_delete_workflow` | Permanently delete a workflow (confirm-gated, snapshot-before-delete, restore via `n8n_create_workflow`) | ✓ |
|
|
102
|
-
| `n8n_cancel_execution` | Stop a running or waiting execution by id | ✓ |
|
|
103
|
-
| `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) | ✓ |
|
|
104
111
|
| `n8n_delete_execution` | Permanently delete an execution record (confirm-gated, irreversible) | ✓ |
|
|
105
112
|
| `n8n_delete_executions` | Batch form of delete (client-side fan-out, confirm-gated, irreversible, max 50 ids) | ✓ |
|
|
106
113
|
| `n8n_pin_node_data` | Pin sample data to a node so downstream nodes use it during testing (confirm-gated, replace-or-merge) | ✓ |
|
|
@@ -151,13 +158,13 @@ Write tools are hidden unless `N8N_ENABLE_EDIT=true`.
|
|
|
151
158
|
|
|
152
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.
|
|
153
160
|
|
|
154
|
-
**`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.
|
|
155
162
|
|
|
156
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.
|
|
157
164
|
|
|
158
|
-
**`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).
|
|
159
166
|
|
|
160
|
-
**`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.
|
|
161
168
|
|
|
162
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.
|
|
163
170
|
|
|
@@ -435,7 +442,7 @@ Calls `n8n_list_workflows` with a name filter, then `n8n_deactivate` with `confi
|
|
|
435
442
|
|
|
436
443
|
> Kill the execution stuck on ECONNREFUSED *(requires `N8N_ENABLE_EDIT=true`)*
|
|
437
444
|
|
|
438
|
-
Calls `n8n_search_executions` with `query: "ECONNREFUSED"`, then `n8n_cancel_execution` on the match.
|
|
445
|
+
Calls `n8n_search_executions` with `query: "ECONNREFUSED"`, then `n8n_cancel_execution` with `confirm: true` on the match.
|
|
439
446
|
|
|
440
447
|
> Purge the noisy test-run execution logs from last week *(requires `N8N_ENABLE_EDIT=true`)*
|
|
441
448
|
|
|
@@ -443,7 +450,7 @@ Calls `n8n_search_executions` to find the ids, then `n8n_delete_executions` with
|
|
|
443
450
|
|
|
444
451
|
> Archive the old "staging-bot" workflow - I might need it back someday *(requires `N8N_ENABLE_EDIT=true`)*
|
|
445
452
|
|
|
446
|
-
Calls `n8n_list_workflows` with a name filter, then `n8n_archive_workflow` with `confirm: true` on the match. Reversible via `n8n_unarchive_workflow` (you'll still need `n8n_activate` with `confirm: true` 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).
|
|
447
454
|
|
|
448
455
|
> Delete the abandoned "poc-scraper" workflow - it's been dead for months *(requires `N8N_ENABLE_EDIT=true`)*
|
|
449
456
|
|
|
@@ -496,3 +503,111 @@ See [CHANGELOG.md](./CHANGELOG.md) for the full version history.
|
|
|
496
503
|
## License
|
|
497
504
|
|
|
498
505
|
MIT. See [LICENSE](./LICENSE).
|
|
506
|
+
|
|
507
|
+
---
|
|
508
|
+
|
|
509
|
+
<p align="center"><a href="https://lidless.dev">Part of <strong>Lidless Labs</strong></a> · 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> · <a href="https://github.com/lidless-labs/watchtower">watchtower</a> · <a href="https://github.com/lidless-labs/portgrid">portgrid</a> · <a href="https://github.com/lidless-labs/cutsheet">cutsheet</a> · <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> · <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.
|