n8n-ops-mcp 0.3.0 → 0.5.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/README.md CHANGED
@@ -30,6 +30,8 @@ For a catalog/docs tool that indexes n8n's node library, see [n8n-mcp](https://w
30
30
  | `n8n_deactivate` | Disable a workflow's triggers | ✓ |
31
31
  | `n8n_save_workflow` | Overwrite a workflow with auto-backup + validation + confirm gate | ✓ |
32
32
  | `n8n_cancel_execution` | Stop a running or waiting execution by id | ✓ |
33
+ | `n8n_retry_execution` | Retry a failed execution by id (returns a new execution) | ✓ |
34
+ | `n8n_delete_execution` | Permanently delete an execution record (confirm-gated, irreversible) | ✓ |
33
35
 
34
36
  Write tools are hidden unless `N8N_ENABLE_EDIT=true`.
35
37
 
@@ -60,6 +62,10 @@ Write tools are hidden unless `N8N_ENABLE_EDIT=true`.
60
62
 
61
63
  **`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).
62
64
 
65
+ **`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.
66
+
67
+ **`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.
68
+
63
69
  </details>
64
70
 
65
71
  ## Install
@@ -236,6 +242,14 @@ Calls `n8n_list_workflows` with a name filter, then `n8n_deactivate` on the matc
236
242
 
237
243
  Calls `n8n_search_executions` with `query: "ECONNREFUSED"`, then `n8n_cancel_execution` on the match.
238
244
 
245
+ > Retry yesterday's failed "nightly intel" run against the current workflow *(requires `N8N_ENABLE_EDIT=true`)*
246
+
247
+ Calls `n8n_search_executions` to find the failed id, then `n8n_retry_execution` with `loadWorkflow: true`.
248
+
249
+ > Purge the noisy test-run execution logs from last week *(requires `N8N_ENABLE_EDIT=true`)*
250
+
251
+ Calls `n8n_search_executions` to find the ids, then `n8n_delete_execution` with `confirm: true` on each. Deletion is irreversible.
252
+
239
253
  ## Development
240
254
 
241
255
  ```bash
@@ -133,6 +133,24 @@ var N8nClient = class {
133
133
  method: "POST"
134
134
  });
135
135
  }
136
+ async retryExecution(id, opts = {}) {
137
+ if (!/^[A-Za-z0-9_-]+$/.test(id)) {
138
+ throw new Error(`Invalid execution id: ${id}`);
139
+ }
140
+ const init = { method: "POST" };
141
+ if (opts.loadWorkflow !== void 0) {
142
+ init.body = JSON.stringify({ loadWorkflow: opts.loadWorkflow });
143
+ }
144
+ return this.request(`/api/v1/executions/${id}/retry`, init);
145
+ }
146
+ async deleteExecution(id) {
147
+ if (!/^[A-Za-z0-9_-]+$/.test(id)) {
148
+ throw new Error(`Invalid execution id: ${id}`);
149
+ }
150
+ return this.request(`/api/v1/executions/${id}`, {
151
+ method: "DELETE"
152
+ });
153
+ }
136
154
  async listExecutions(params = {}) {
137
155
  const qs = new URLSearchParams();
138
156
  if (params.workflowId) qs.set("workflowId", params.workflowId);
@@ -1347,8 +1365,135 @@ function createCancelExecutionTool(getClient) {
1347
1365
  };
1348
1366
  }
1349
1367
 
1368
+ // src/tools/retry-execution.ts
1369
+ import { Type as Type13 } from "@sinclair/typebox";
1370
+ var Schema13 = Type13.Object(
1371
+ {
1372
+ id: Type13.String({
1373
+ description: "Execution id to retry (from n8n_list_executions or n8n_search_executions)."
1374
+ }),
1375
+ loadWorkflow: Type13.Optional(
1376
+ Type13.Boolean({
1377
+ description: "If true, retry against the currently saved workflow instead of the version captured at the original execution time. Omit to accept n8n's default."
1378
+ })
1379
+ )
1380
+ },
1381
+ { additionalProperties: false }
1382
+ );
1383
+ function createRetryExecutionTool(getClient) {
1384
+ return {
1385
+ name: "n8n_retry_execution",
1386
+ label: "n8n: retry execution",
1387
+ description: "Retry a failed n8n execution by id via POST /executions/{id}/retry. Creates a NEW execution \u2014 the response surfaces both the original id and the newExecutionId so agents can follow up. If the id no longer matches an execution (404), returns ok:false with reason 'not_found'. If the execution is not retryable (409 \u2014 typically still running), returns ok:false with reason 'not_retryable'. All other API errors rethrow. Optional loadWorkflow:true retries against the current saved workflow rather than the version captured at the original execution time. Requires enableEdit.",
1388
+ parameters: Schema13,
1389
+ execute: async (_toolCallId, rawParams) => {
1390
+ const { id, loadWorkflow } = rawParams;
1391
+ const client = getClient();
1392
+ const opts = loadWorkflow === void 0 ? {} : { loadWorkflow };
1393
+ try {
1394
+ const ex = await client.retryExecution(id, opts);
1395
+ const status = ex.status ?? (ex.finished ? "success" : "running");
1396
+ return jsonToolResult({
1397
+ ok: true,
1398
+ action: "retry",
1399
+ originalExecutionId: id,
1400
+ newExecutionId: String(ex.id),
1401
+ workflowId: String(ex.workflowId ?? ""),
1402
+ workflowName: ex.workflowData?.name ?? null,
1403
+ status,
1404
+ finished: ex.finished,
1405
+ startedAt: ex.startedAt ?? null,
1406
+ stoppedAt: ex.stoppedAt ?? null,
1407
+ loadWorkflow: loadWorkflow ?? null
1408
+ });
1409
+ } catch (err) {
1410
+ if (err instanceof N8nApiError && err.status === 404) {
1411
+ return jsonToolResult({
1412
+ ok: false,
1413
+ action: "retry",
1414
+ originalExecutionId: id,
1415
+ reason: "not_found",
1416
+ message: "Execution not found. It may have been deleted or never existed."
1417
+ });
1418
+ }
1419
+ if (err instanceof N8nApiError && err.status === 409) {
1420
+ return jsonToolResult({
1421
+ ok: false,
1422
+ action: "retry",
1423
+ originalExecutionId: id,
1424
+ reason: "not_retryable",
1425
+ message: "Execution is not retryable. It may still be running, or n8n refused the retry for this execution's state."
1426
+ });
1427
+ }
1428
+ throw err;
1429
+ }
1430
+ }
1431
+ };
1432
+ }
1433
+
1434
+ // src/tools/delete-execution.ts
1435
+ import { Type as Type14 } from "@sinclair/typebox";
1436
+ var Schema14 = Type14.Object(
1437
+ {
1438
+ id: Type14.String({
1439
+ description: "Execution id to delete (from n8n_list_executions or n8n_search_executions)."
1440
+ }),
1441
+ confirm: Type14.Boolean({
1442
+ description: "Must be true to actually delete. Deletion is irreversible: execution logs, run data, and error payloads are gone from n8n after this call. If you may need the record later, fetch n8n_get_execution first and save the output."
1443
+ })
1444
+ },
1445
+ { additionalProperties: false }
1446
+ );
1447
+ function createDeleteExecutionTool(getClient) {
1448
+ return {
1449
+ name: "n8n_delete_execution",
1450
+ label: "n8n: delete execution",
1451
+ description: "Permanently delete an n8n execution record by id via DELETE /executions/{id}. Irreversible: execution logs, per-node run data, and error payloads are erased. Requires enableEdit and explicit confirm=true. If the id no longer matches an execution (404), returns ok:false with reason 'not_found'. All other API errors rethrow.",
1452
+ parameters: Schema14,
1453
+ execute: async (_toolCallId, rawParams) => {
1454
+ const { id, confirm } = rawParams;
1455
+ if (!confirm) {
1456
+ return jsonToolResult({
1457
+ ok: false,
1458
+ action: "delete",
1459
+ executionId: id,
1460
+ error: "confirm must be true to delete",
1461
+ hint: "Deletion is irreversible. Fetch n8n_get_execution first if you need the record."
1462
+ });
1463
+ }
1464
+ const client = getClient();
1465
+ try {
1466
+ const ex = await client.deleteExecution(id);
1467
+ const status = ex.status ?? (ex.finished ? "success" : "running");
1468
+ return jsonToolResult({
1469
+ ok: true,
1470
+ action: "delete",
1471
+ executionId: String(ex.id ?? id),
1472
+ workflowId: String(ex.workflowId ?? ""),
1473
+ workflowName: ex.workflowData?.name ?? null,
1474
+ status,
1475
+ finished: ex.finished ?? null,
1476
+ startedAt: ex.startedAt ?? null,
1477
+ stoppedAt: ex.stoppedAt ?? null
1478
+ });
1479
+ } catch (err) {
1480
+ if (err instanceof N8nApiError && err.status === 404) {
1481
+ return jsonToolResult({
1482
+ ok: false,
1483
+ action: "delete",
1484
+ executionId: id,
1485
+ reason: "not_found",
1486
+ message: "Execution not found. It may have already been deleted or never existed."
1487
+ });
1488
+ }
1489
+ throw err;
1490
+ }
1491
+ }
1492
+ };
1493
+ }
1494
+
1350
1495
  // mcp-server.ts
1351
- var VERSION = "0.3.0";
1496
+ var VERSION = "0.5.0";
1352
1497
  function readConfigFromEnv() {
1353
1498
  const baseUrl = (process.env.N8N_BASE_URL ?? "").trim();
1354
1499
  if (!baseUrl) {
@@ -1509,6 +1654,22 @@ async function main() {
1509
1654
  "Execution id to stop (from n8n_list_executions or n8n_search_executions)."
1510
1655
  )
1511
1656
  });
1657
+ bind(server, createRetryExecutionTool(getClient), {
1658
+ id: z.string().describe(
1659
+ "Execution id to retry (from n8n_list_executions or n8n_search_executions). The response contains a NEW execution id."
1660
+ ),
1661
+ loadWorkflow: z.boolean().optional().describe(
1662
+ "If true, retry against the currently saved workflow instead of the version captured at the original execution time. Omit to accept n8n's default."
1663
+ )
1664
+ });
1665
+ bind(server, createDeleteExecutionTool(getClient), {
1666
+ id: z.string().describe(
1667
+ "Execution id to delete (from n8n_list_executions or n8n_search_executions)."
1668
+ ),
1669
+ confirm: z.boolean().describe(
1670
+ "Must be true to actually delete. Deletion is irreversible: execution logs, per-node run data, and error payloads are erased."
1671
+ )
1672
+ });
1512
1673
  }
1513
1674
  const transport = new StdioServerTransport();
1514
1675
  await server.connect(transport);
package/index.ts CHANGED
@@ -13,6 +13,8 @@ import { createActivateTool } from "./src/tools/activate.ts";
13
13
  import { createDeactivateTool } from "./src/tools/deactivate.ts";
14
14
  import { createSaveWorkflowTool } from "./src/tools/save-workflow.ts";
15
15
  import { createCancelExecutionTool } from "./src/tools/cancel-execution.ts";
16
+ import { createRetryExecutionTool } from "./src/tools/retry-execution.ts";
17
+ import { createDeleteExecutionTool } from "./src/tools/delete-execution.ts";
16
18
 
17
19
  export default definePluginEntry({
18
20
  id: "n8n",
@@ -51,6 +53,8 @@ export default definePluginEntry({
51
53
  }) as AnyAgentTool,
52
54
  );
53
55
  api.registerTool(createCancelExecutionTool(getClient) as AnyAgentTool);
56
+ api.registerTool(createRetryExecutionTool(getClient) as AnyAgentTool);
57
+ api.registerTool(createDeleteExecutionTool(getClient) as AnyAgentTool);
54
58
  }
55
59
  },
56
60
  });
@@ -24,7 +24,7 @@
24
24
  "enableEdit": {
25
25
  "type": "boolean",
26
26
  "default": false,
27
- "description": "Enable write tools (save/activate/deactivate/cancel-execution). Off by default."
27
+ "description": "Enable write tools (save/activate/deactivate/cancel-execution/retry-execution/delete-execution). Off by default. delete-execution is irreversible and has a confirm gate."
28
28
  },
29
29
  "maxExecutionLogBytes": {
30
30
  "type": "number",
@@ -55,7 +55,7 @@
55
55
  },
56
56
  "enableEdit": {
57
57
  "label": "Enable Edit Tools",
58
- "help": "Exposes save/activate/deactivate/cancel-execution. save has a confirm-gate and auto-backup; cancel stops running executions on the server."
58
+ "help": "Exposes save/activate/deactivate/cancel-execution/retry-execution/delete-execution. save has a confirm-gate and auto-backup; cancel stops running executions; retry re-runs a failed execution and returns a NEW execution id; delete permanently removes an execution record (confirm-gated, irreversible)."
59
59
  },
60
60
  "maxExecutionLogBytes": {
61
61
  "label": "Max Log Bytes",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-ops-mcp",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "Ops-focused n8n tools (list, inspect, trigger, validate, save) for Claude-compatible clients. MCP server + first-class OpenClaw plugin.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/client.ts CHANGED
@@ -227,6 +227,29 @@ export class N8nClient {
227
227
  });
228
228
  }
229
229
 
230
+ async retryExecution(
231
+ id: string,
232
+ opts: { loadWorkflow?: boolean } = {},
233
+ ): Promise<N8nExecution> {
234
+ if (!/^[A-Za-z0-9_-]+$/.test(id)) {
235
+ throw new Error(`Invalid execution id: ${id}`);
236
+ }
237
+ const init: RequestInit = { method: "POST" };
238
+ if (opts.loadWorkflow !== undefined) {
239
+ init.body = JSON.stringify({ loadWorkflow: opts.loadWorkflow });
240
+ }
241
+ return this.request<N8nExecution>(`/api/v1/executions/${id}/retry`, init);
242
+ }
243
+
244
+ async deleteExecution(id: string): Promise<N8nExecution> {
245
+ if (!/^[A-Za-z0-9_-]+$/.test(id)) {
246
+ throw new Error(`Invalid execution id: ${id}`);
247
+ }
248
+ return this.request<N8nExecution>(`/api/v1/executions/${id}`, {
249
+ method: "DELETE",
250
+ });
251
+ }
252
+
230
253
  async listExecutions(params: {
231
254
  workflowId?: string;
232
255
  status?: string;
@@ -0,0 +1,67 @@
1
+ import { Type } from "@sinclair/typebox";
2
+ import { N8nApiError, type N8nClient } from "../client.ts";
3
+ import { jsonToolResult } from "./result.ts";
4
+
5
+ const Schema = Type.Object(
6
+ {
7
+ id: Type.String({
8
+ description:
9
+ "Execution id to delete (from n8n_list_executions or n8n_search_executions).",
10
+ }),
11
+ confirm: Type.Boolean({
12
+ description:
13
+ "Must be true to actually delete. Deletion is irreversible: execution logs, run data, and error payloads are gone from n8n after this call. If you may need the record later, fetch n8n_get_execution first and save the output.",
14
+ }),
15
+ },
16
+ { additionalProperties: false },
17
+ );
18
+
19
+ export function createDeleteExecutionTool(getClient: () => N8nClient) {
20
+ return {
21
+ name: "n8n_delete_execution",
22
+ label: "n8n: delete execution",
23
+ description:
24
+ "Permanently delete an n8n execution record by id via DELETE /executions/{id}. Irreversible: execution logs, per-node run data, and error payloads are erased. Requires enableEdit and explicit confirm=true. If the id no longer matches an execution (404), returns ok:false with reason 'not_found'. All other API errors rethrow.",
25
+ parameters: Schema,
26
+ execute: async (_toolCallId: string, rawParams: Record<string, unknown>) => {
27
+ const { id, confirm } = rawParams as { id: string; confirm: boolean };
28
+ if (!confirm) {
29
+ return jsonToolResult({
30
+ ok: false,
31
+ action: "delete",
32
+ executionId: id,
33
+ error: "confirm must be true to delete",
34
+ hint: "Deletion is irreversible. Fetch n8n_get_execution first if you need the record.",
35
+ });
36
+ }
37
+ const client = getClient();
38
+ try {
39
+ const ex = await client.deleteExecution(id);
40
+ const status = ex.status ?? (ex.finished ? "success" : "running");
41
+ return jsonToolResult({
42
+ ok: true,
43
+ action: "delete",
44
+ executionId: String(ex.id ?? id),
45
+ workflowId: String(ex.workflowId ?? ""),
46
+ workflowName: ex.workflowData?.name ?? null,
47
+ status,
48
+ finished: ex.finished ?? null,
49
+ startedAt: ex.startedAt ?? null,
50
+ stoppedAt: ex.stoppedAt ?? null,
51
+ });
52
+ } catch (err) {
53
+ if (err instanceof N8nApiError && err.status === 404) {
54
+ return jsonToolResult({
55
+ ok: false,
56
+ action: "delete",
57
+ executionId: id,
58
+ reason: "not_found",
59
+ message:
60
+ "Execution not found. It may have already been deleted or never existed.",
61
+ });
62
+ }
63
+ throw err;
64
+ }
65
+ },
66
+ };
67
+ }
@@ -0,0 +1,77 @@
1
+ import { Type } from "@sinclair/typebox";
2
+ import { N8nApiError, type N8nClient } from "../client.ts";
3
+ import { jsonToolResult } from "./result.ts";
4
+
5
+ const Schema = Type.Object(
6
+ {
7
+ id: Type.String({
8
+ description:
9
+ "Execution id to retry (from n8n_list_executions or n8n_search_executions).",
10
+ }),
11
+ loadWorkflow: Type.Optional(
12
+ Type.Boolean({
13
+ description:
14
+ "If true, retry against the currently saved workflow instead of the version captured at the original execution time. Omit to accept n8n's default.",
15
+ }),
16
+ ),
17
+ },
18
+ { additionalProperties: false },
19
+ );
20
+
21
+ export function createRetryExecutionTool(getClient: () => N8nClient) {
22
+ return {
23
+ name: "n8n_retry_execution",
24
+ label: "n8n: retry execution",
25
+ description:
26
+ "Retry a failed n8n execution by id via POST /executions/{id}/retry. Creates a NEW execution — the response surfaces both the original id and the newExecutionId so agents can follow up. If the id no longer matches an execution (404), returns ok:false with reason 'not_found'. If the execution is not retryable (409 — typically still running), returns ok:false with reason 'not_retryable'. All other API errors rethrow. Optional loadWorkflow:true retries against the current saved workflow rather than the version captured at the original execution time. Requires enableEdit.",
27
+ parameters: Schema,
28
+ execute: async (_toolCallId: string, rawParams: Record<string, unknown>) => {
29
+ const { id, loadWorkflow } = rawParams as {
30
+ id: string;
31
+ loadWorkflow?: boolean;
32
+ };
33
+ const client = getClient();
34
+ const opts: { loadWorkflow?: boolean } =
35
+ loadWorkflow === undefined ? {} : { loadWorkflow };
36
+ try {
37
+ const ex = await client.retryExecution(id, opts);
38
+ const status = ex.status ?? (ex.finished ? "success" : "running");
39
+ return jsonToolResult({
40
+ ok: true,
41
+ action: "retry",
42
+ originalExecutionId: id,
43
+ newExecutionId: String(ex.id),
44
+ workflowId: String(ex.workflowId ?? ""),
45
+ workflowName: ex.workflowData?.name ?? null,
46
+ status,
47
+ finished: ex.finished,
48
+ startedAt: ex.startedAt ?? null,
49
+ stoppedAt: ex.stoppedAt ?? null,
50
+ loadWorkflow: loadWorkflow ?? null,
51
+ });
52
+ } catch (err) {
53
+ if (err instanceof N8nApiError && err.status === 404) {
54
+ return jsonToolResult({
55
+ ok: false,
56
+ action: "retry",
57
+ originalExecutionId: id,
58
+ reason: "not_found",
59
+ message:
60
+ "Execution not found. It may have been deleted or never existed.",
61
+ });
62
+ }
63
+ if (err instanceof N8nApiError && err.status === 409) {
64
+ return jsonToolResult({
65
+ ok: false,
66
+ action: "retry",
67
+ originalExecutionId: id,
68
+ reason: "not_retryable",
69
+ message:
70
+ "Execution is not retryable. It may still be running, or n8n refused the retry for this execution's state.",
71
+ });
72
+ }
73
+ throw err;
74
+ }
75
+ },
76
+ };
77
+ }