n8n-ops-mcp 0.4.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
@@ -31,6 +31,7 @@ For a catalog/docs tool that indexes n8n's node library, see [n8n-mcp](https://w
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
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) | ✓ |
34
35
 
35
36
  Write tools are hidden unless `N8N_ENABLE_EDIT=true`.
36
37
 
@@ -63,6 +64,8 @@ Write tools are hidden unless `N8N_ENABLE_EDIT=true`.
63
64
 
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.
65
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
+
66
69
  </details>
67
70
 
68
71
  ## Install
@@ -243,6 +246,10 @@ Calls `n8n_search_executions` with `query: "ECONNREFUSED"`, then `n8n_cancel_exe
243
246
 
244
247
  Calls `n8n_search_executions` to find the failed id, then `n8n_retry_execution` with `loadWorkflow: true`.
245
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
+
246
253
  ## Development
247
254
 
248
255
  ```bash
@@ -143,6 +143,14 @@ var N8nClient = class {
143
143
  }
144
144
  return this.request(`/api/v1/executions/${id}/retry`, init);
145
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
+ }
146
154
  async listExecutions(params = {}) {
147
155
  const qs = new URLSearchParams();
148
156
  if (params.workflowId) qs.set("workflowId", params.workflowId);
@@ -1423,8 +1431,69 @@ function createRetryExecutionTool(getClient) {
1423
1431
  };
1424
1432
  }
1425
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
+
1426
1495
  // mcp-server.ts
1427
- var VERSION = "0.4.0";
1496
+ var VERSION = "0.5.0";
1428
1497
  function readConfigFromEnv() {
1429
1498
  const baseUrl = (process.env.N8N_BASE_URL ?? "").trim();
1430
1499
  if (!baseUrl) {
@@ -1593,6 +1662,14 @@ async function main() {
1593
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."
1594
1663
  )
1595
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
+ });
1596
1673
  }
1597
1674
  const transport = new StdioServerTransport();
1598
1675
  await server.connect(transport);
package/index.ts CHANGED
@@ -14,6 +14,7 @@ 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
16
  import { createRetryExecutionTool } from "./src/tools/retry-execution.ts";
17
+ import { createDeleteExecutionTool } from "./src/tools/delete-execution.ts";
17
18
 
18
19
  export default definePluginEntry({
19
20
  id: "n8n",
@@ -53,6 +54,7 @@ export default definePluginEntry({
53
54
  );
54
55
  api.registerTool(createCancelExecutionTool(getClient) as AnyAgentTool);
55
56
  api.registerTool(createRetryExecutionTool(getClient) as AnyAgentTool);
57
+ api.registerTool(createDeleteExecutionTool(getClient) as AnyAgentTool);
56
58
  }
57
59
  },
58
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/retry-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/retry-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."
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.4.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
@@ -241,6 +241,15 @@ export class N8nClient {
241
241
  return this.request<N8nExecution>(`/api/v1/executions/${id}/retry`, init);
242
242
  }
243
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
+
244
253
  async listExecutions(params: {
245
254
  workflowId?: string;
246
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
+ }