n8n-ops-mcp 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Solomon Neas
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,225 @@
1
+ # n8n-ops-mcp
2
+
3
+ Ops-focused n8n tools for Claude-compatible clients. List, inspect, trigger, validate, and safely edit n8n workflows from any MCP host — with first-class [OpenClaw](https://github.com/openclaw/openclaw) support.
4
+
5
+ Works with Claude Desktop, Claude Code, OpenClaw, Hermes Agent, Codex CLI, and any other MCP-compatible client.
6
+
7
+ ## Why
8
+
9
+ Your AI agent has no native awareness of your n8n footprint. If a pipeline breaks, you SSH to the host or open the n8n UI. With this package, your agent can answer "what's broken in my n8n?" from chat, and trigger manual workflows without you leaving your client.
10
+
11
+ This is an **ops** tool — focused on listing, triggering, validating, and editing workflows. If you want a catalog/docs tool that indexes n8n's node library, see [n8n-mcp](https://www.npmjs.com/package/n8n-mcp).
12
+
13
+ ## Tools
14
+
15
+ **`n8n_list_workflows`** - list workflows with optional `active`, `tags`, `name` (substring), `limit` filters. Returns id, name, active state, tags, updatedAt.
16
+
17
+ **`n8n_get_workflow`** - fetch one workflow by id. Returns metadata by default. Pass `includeDefinition: true` to get the full node graph + connections.
18
+
19
+ **`n8n_list_executions`** - list recent executions with optional `workflowId`, `status` (success/error/running/waiting/canceled), `limit` filters. Returns id, workflowId, workflowName, status, mode, startedAt, stoppedAt.
20
+
21
+ **`n8n_get_execution`** - fetch one execution by id. Includes per-node run log (truncated to `maxExecutionLogBytes`, default 64 KB, with a tail hint when it exceeds) and the raw error object verbatim when status is `error`. Pass `includeRunData: false` to skip the run log and get just status + error.
22
+
23
+ **`n8n_list_webhooks`** - scan workflows for webhook and form-trigger nodes and return their paths + fully-formed `triggerUrl`. Pairs with `n8n_trigger` mode='webhook' so agents can discover and call webhooks without opening n8n. Optional `workflowId` for a single workflow, `activeOnly` (default true), `limit` (default 50).
24
+
25
+ **`n8n_validate_workflow`** - static checks on a workflow: deprecated node types (function → code), legacy Code-node API (`$node[]`, `items` global, `require()`), orphan nodes, disabled nodes, missing trigger. Returns issues with severity (error/warning/info) and a summary count.
26
+
27
+ ### Write tools (behind `enableEdit`)
28
+
29
+ **`n8n_activate`** - activate a workflow so its triggers start firing. Idempotent.
30
+
31
+ **`n8n_deactivate`** - deactivate a workflow so triggers stop firing. Running executions are not cancelled. Idempotent.
32
+
33
+ **`n8n_save_workflow`** - overwrite a workflow. Before writing: fetches the current version, snapshots it to `backupDir` as `<id>-<timestamp>.json` (mode 0600), runs `validateWorkflow` on the proposed new state, and aborts on error-severity issues (pass `skipValidation: true` to bypass). Requires `confirm: true` to actually PUT. Response includes the backup path and a `restoreHint` describing how to roll back.
34
+
35
+ **`n8n_trigger`** - run a workflow. Two modes:
36
+ - `mode: "webhook"` + `webhookPath` - POST (or GET/PUT/DELETE) to the configured base URL + path, with an optional JSON `payload`. This is the reliable path.
37
+ - `mode: "workflow"` + `workflowId` - attempts `POST /api/v1/workflows/:id/execute`. Pre-checks that the workflow is active and has a webhook/manual/form trigger node. Most n8n builds do not expose this endpoint on the Public API and will 405; the tool surfaces a hint to switch to webhook mode in that case.
38
+
39
+ ## Install
40
+
41
+ ```bash
42
+ npm install -g n8n-ops-mcp
43
+ ```
44
+
45
+ Or from source:
46
+
47
+ ```bash
48
+ git clone https://github.com/solomonneas/n8n-ops-mcp.git
49
+ cd n8n-ops-mcp
50
+ npm install
51
+ npm run build
52
+ ```
53
+
54
+ ## Configuration
55
+
56
+ Generate an API key in n8n under Settings -> API, then set these env vars in your MCP client config:
57
+
58
+ | Variable | Required | Default | Description |
59
+ |---|---|---|---|
60
+ | `N8N_BASE_URL` | yes | — | n8n base URL, e.g. `http://localhost:5678` |
61
+ | `N8N_API_KEY` | yes | — | n8n Public API key (`X-N8N-API-KEY`) |
62
+ | `N8N_ENABLE_EDIT` | no | `false` | Set to `true` to expose `n8n_activate`, `n8n_deactivate`, `n8n_save_workflow` |
63
+ | `N8N_BACKUP_DIR` | no | `~/.n8n-backups` | Where `n8n_save_workflow` writes pre-save snapshots |
64
+ | `N8N_MAX_EXECUTION_LOG_BYTES` | no | `65536` | Cap on inline execution log bytes |
65
+ | `N8N_REQUEST_TIMEOUT_MS` | no | `15000` | HTTP timeout for n8n API calls |
66
+
67
+ ### Claude Desktop
68
+
69
+ Add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
70
+
71
+ ```json
72
+ {
73
+ "mcpServers": {
74
+ "n8n": {
75
+ "command": "n8n-ops-mcp",
76
+ "env": {
77
+ "N8N_BASE_URL": "http://localhost:5678",
78
+ "N8N_API_KEY": "your-api-key-here"
79
+ }
80
+ }
81
+ }
82
+ }
83
+ ```
84
+
85
+ ### Claude Code
86
+
87
+ ```bash
88
+ claude mcp add n8n \
89
+ --env N8N_BASE_URL=http://localhost:5678 \
90
+ --env N8N_API_KEY=your-api-key-here \
91
+ -- n8n-ops-mcp
92
+ ```
93
+
94
+ Add `--scope user` to make it available from any directory instead of only the current project.
95
+
96
+ ### OpenClaw (as a native plugin)
97
+
98
+ n8n-ops-mcp is a first-class OpenClaw plugin — not an MCP bridge — which means it shares the gateway's process, auth profiles, and hooks. Register it in `~/.openclaw/openclaw.json`:
99
+
100
+ ```json
101
+ {
102
+ "plugins": {
103
+ "allow": ["n8n"],
104
+ "load": {
105
+ "paths": ["/absolute/path/to/n8n-ops-mcp"]
106
+ },
107
+ "entries": {
108
+ "n8n": {
109
+ "enabled": true,
110
+ "config": {
111
+ "baseUrl": "http://your-n8n-host:5678",
112
+ "enableEdit": false
113
+ }
114
+ }
115
+ }
116
+ }
117
+ }
118
+ ```
119
+
120
+ Put the API key in your OpenClaw workspace env so the plugin can read it without inlining:
121
+
122
+ ```bash
123
+ # ~/.openclaw/workspace/.env
124
+ N8N_API_KEY=eyJhbGciOi...
125
+ ```
126
+
127
+ Restart the gateway:
128
+
129
+ ```bash
130
+ systemctl --user restart openclaw-gateway
131
+ ```
132
+
133
+ OpenClaw plugin config keys (passed via `plugins.entries.n8n.config`): `baseUrl`, `apiKey`, `apiKeyEnv`, `enableEdit`, `maxExecutionLogBytes`, `requestTimeoutMs`, `backupDir`. See [`openclaw.plugin.json`](./openclaw.plugin.json) for the full schema.
134
+
135
+ ### OpenClaw (via ClawHub)
136
+
137
+ If you prefer the registry path:
138
+
139
+ ```bash
140
+ openclaw plugins install clawhub:n8n-ops-mcp
141
+ ```
142
+
143
+ Then add a `plugins.entries.n8n` config block as above, restart the gateway, and you're done. ClawHub handles install + updates.
144
+
145
+ ### Hermes Agent
146
+
147
+ [Hermes Agent](https://github.com/NousResearch/hermes-agent) reads MCP config from `~/.hermes/config.yaml` under the `mcp_servers` key:
148
+
149
+ ```yaml
150
+ mcp_servers:
151
+ n8n:
152
+ command: "n8n-ops-mcp"
153
+ env:
154
+ N8N_BASE_URL: "http://localhost:5678"
155
+ N8N_API_KEY: "your-api-key-here"
156
+ ```
157
+
158
+ Then reload MCP from inside a Hermes session:
159
+
160
+ ```
161
+ /reload-mcp
162
+ ```
163
+
164
+ ### Codex CLI
165
+
166
+ [Codex CLI](https://github.com/openai/codex) registers MCP servers via `codex mcp add`:
167
+
168
+ ```bash
169
+ codex mcp add n8n \
170
+ --env N8N_BASE_URL=http://localhost:5678 \
171
+ --env N8N_API_KEY=your-api-key-here \
172
+ -- n8n-ops-mcp
173
+ ```
174
+
175
+ Codex writes the entry to `~/.codex/config.toml` under `[mcp_servers.n8n]`. Verify with:
176
+
177
+ ```bash
178
+ codex mcp list
179
+ ```
180
+
181
+ ## Example prompts
182
+
183
+ > What n8n workflows broke today?
184
+
185
+ Calls `n8n_list_executions` with `status=error`, then optionally `n8n_get_execution` for the failing run log.
186
+
187
+ > Trigger the "nightly intel" workflow
188
+
189
+ Calls `n8n_list_webhooks` to find the webhook path, then `n8n_trigger` with `mode=webhook`.
190
+
191
+ > Audit my workflows for deprecated Code-node API usage
192
+
193
+ Calls `n8n_list_workflows` then `n8n_validate_workflow` per id, filters for `code-node-old-node-ref` and `code-node-items-global` warnings.
194
+
195
+ > Deactivate the "experimental-bot" workflow (requires `N8N_ENABLE_EDIT=true`)
196
+
197
+ Calls `n8n_list_workflows` with a name filter, then `n8n_deactivate` on the matching id.
198
+
199
+ ## Development
200
+
201
+ ```bash
202
+ npm install
203
+ npm run dev # tsx on mcp-server.ts (MCP stdio)
204
+ npm run typecheck # tsc --noEmit
205
+ npm run build # tsup bundle to dist/mcp-server.js
206
+ npm start # node dist/mcp-server.js (post-build)
207
+ ```
208
+
209
+ ## Roadmap
210
+
211
+ - [x] `n8n_list_workflows`
212
+ - [x] `n8n_get_workflow`
213
+ - [x] `n8n_list_executions`
214
+ - [x] `n8n_get_execution`
215
+ - [x] `n8n_trigger` (webhook + manual)
216
+ - [x] `n8n_list_webhooks` (surface webhook paths for mode='webhook')
217
+ - [x] `n8n_validate_workflow` (Code node + deprecated node checks)
218
+ - [x] `n8n_activate` / `n8n_deactivate` (behind `enableEdit`)
219
+ - [x] `n8n_save_workflow` with auto-backup + validation gate (behind `enableEdit`)
220
+ - [x] MCP wrapper (stdio)
221
+ - [ ] `n8n_search_executions` (text search across run logs)
222
+
223
+ ## License
224
+
225
+ MIT