n8n-guard
Compares live n8n workflows with JSON exports in a Git repository to identify workflows that are missing, deleted, drifted, or duplicated.
Provides read-only operational monitoring for self-hosted n8n instances, including instance reachability, workflow inventory, datastore health and growth, stuck execution detection, retention reporting, and drift checks against exported workflows.
Reads an n8n SQLite datastore directly to report database size, per-table breakdown, growth rate, projected headroom, and retention statistics.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@n8n-guard run a full health check on my n8n instance"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
n8n-guard
An MCP server for the operational layer underneath the n8n Public API.
Most n8n MCP servers on the registry wrap the same public endpoints: list workflows, list executions, create, activate, delete. That is useful for building workflows. It is close to useless for keeping a self-hosted instance alive, because the things that actually take an instance down are not in that API at all.
n8n-guard answers the four questions the API cannot:
How big is the datastore, and when does it become a problem? The Public API has no endpoint for database size. n8n-guard reads the SQLite file or queries Postgres directly, breaks the size down per table, derives the growth rate, and tells you how many days of headroom are left.
Which executions are stuck? Listing executions by status is not detection. A run sitting in
runninglooks identical to a healthy long job until you compare it against what that workflow normally takes. n8n-guard builds a per-workflow median from finished runs and flags the outliers.What is retention costing? How many execution records are stored, how far back they reach, and what a given retention window would free.
Has the instance drifted from git? Existing servers diff one API object against another. n8n-guard diffs the running instance against the JSON exports in a repository: live but never exported, exported but deleted, and content that quietly diverged.
It is strictly read-only. n8n-guard never writes to your instance, never deletes executions, and never activates or edits a workflow. It reports; you decide.
Install
npx -y n8n-guardRequires Node.js 22 or newer (it uses the built-in node:sqlite). For a
permanent install use npm install -g n8n-guard.
Claude Desktop / any MCP client
{
"mcpServers": {
"n8n-guard": {
"command": "n8n-guard",
"env": {
"N8N_URL": "https://n8n.example.com",
"N8N_API_KEY": "n8n_api_...",
"N8N_SQLITE_PATH": "/var/lib/n8n/.n8n/database.sqlite",
"N8N_GIT_REPO_PATH": "/srv/workflow-exports"
}
}
}
}Related MCP server: n8n-workflow-tester-safe
Configuration
Everything is an environment variable. There are no hardcoded hosts, paths, container names or accounts, so the server runs against any self-hosted instance.
Variable | Required | Default | Purpose |
| no |
| Base URL of the instance |
| for execution and workflow checks | none | Public API key (Settings, n8n API) |
| for datastore checks on SQLite | none | Path to |
| for datastore checks on Postgres | none | Connection string, takes precedence over SQLite |
| for the drift check | none | Checkout holding exported workflow JSON |
| no |
| Minutes in |
| no |
| Datastore warning threshold |
| no |
| Datastore critical threshold |
| no |
| Per-request API timeout |
Partial configuration is a supported mode, not an error. With only N8N_URL and
N8N_SQLITE_PATH you still get disk and retention answers; the API-backed checks
report that they are unconfigured and the rest of the run continues.
Tools
Tool | What it does |
| Reachability, configured datastore, workflow inventory. Shows which checks are usable. |
| Datastore size, per-table breakdown, growth rate, projected days until the critical threshold. |
| Runs stuck in |
| Execution count, age span, and what pruning to a retention window would free. |
| Live workflows against the repository exports: missing, deleted, drifted, duplicated. |
| All of the above in one resilient sweep. This is the one to schedule. |
Example call
Point the server at an instance and let your client call a tool. Every tool answers with a readable summary first and the full structured payload after it:
## Retention report
- 200 execution records spanning 8.3 days (24.1/day)
- nothing older than 30 days, retention is already tight
- n8n-guard never deletes. To act on this, set EXECUTIONS_DATA_PRUNE=true and
EXECUTIONS_DATA_MAX_AGE=720 (hours) on the n8n instance, then restart it.followed by the structured payload the summary was derived from:
{
"executionCount": 200,
"oldestExecutionAt": "2026-08-28T23:43:28.651Z",
"spanDays": 8.29,
"executionsPerDay": 24.12,
"buckets": [
{ "olderThanDays": 7, "rows": 32, "share": 0.16, "estimatedBytes": 3277 },
{ "olderThanDays": 30, "rows": 0, "share": 0, "estimatedBytes": 0 }
]
}guard_run wraps all six checks. With only a datastore configured it reports
the gap instead of aborting:
## Guard run (degraded)
- stuck_executions failed after 3 attempt(s): N8N_API_KEY is not set, so the n8n Public API cannot be queried
- git_drift failed after 2 attempt(s): N8N_GIT_REPO_PATH is not set, so there is nothing to diff the instance against
- 4 of 6 checks completed despite the failures aboveRecovery: guard_run survives a partial outage
A monitoring run that aborts on the first unreachable dependency is worthless precisely when it matters. The API being down is the incident, and it is no reason to stop looking at the disk.
guard_run isolates every step. A failing step is retried with backoff, and if
it still fails it becomes a finding while the remaining checks run to completion.
Steps that depend on a failed step are skipped with the reason attached rather
than crashing on missing input. The report says so plainly:
## Guard run (degraded)
- stuck_executions failed after 3 attempt(s): cannot reach http://n8n.internal:5678: fetch failed
- git_drift skipped: depends on instance, which failed
- 4 of 6 checks completed despite the failures aboveThis behaviour is covered by tests in test/unit/runner.test.ts and
test/unit/serviceRecovery.test.ts, the latter running a real SQLite datastore
against a deliberately dead API endpoint.
Render Workflows
The same sweep also runs as a Render Workflow:
one Render task per check, with ordering, retries and backoff declared in the
task definitions and executed by Render rather than by the in-process runner.
Deploy steps, the task table and how to trigger a run (including a deliberate
failure that demonstrates the retry path) are in
docs/render-workflow.md.
Try it on a throwaway instance
The compose file starts a fresh n8n you can safely point the server at. The data directory is bind-mounted, which is exactly how n8n-guard reads a real deployment.
git clone https://github.com/flow-84/n8n-guard && cd n8n-guard
npm install && npm run build
docker compose up -d
./scripts/demo-setup.sh # owner, API key, workflows, and a drifted export folderThe script generates the owner password, keeps it in the gitignored
.n8n-demo-credentials, and prints it along with the environment block to run
the server with. It seeds one workflow that matches its export, one that was
never exported, one that points at a sink container so a run can hang, and one
export whose workflow does not exist, so git_drift and stuck_executions
have something real to find.
export N8N_URL=http://localhost:5679
export N8N_API_KEY=... # printed by the script
export N8N_SQLITE_PATH=$PWD/.n8n-demo/database.sqlite
export N8N_GIT_REPO_PATH=$PWD/.n8n-demo-exports
npm startThe instance publishes on 5679, not on n8n's default 5678, so it cannot collide
with an instance you care about. Set N8N_DEMO_PORT to move it, and pass the
same value to demo-setup.sh, the integration tests and N8N_URL.
Tests
npm test # unit tests, no instance required
npm run test:integration # against the compose instance aboveThe integration suite skips the API-backed cases when N8N_API_KEY is unset, so
it stays runnable on a bare docker compose up.
License
MIT
Available Tools
6 toolsdb_healthDatabase healthA
Size, per-table breakdown and growth rate of the n8n datastore, plus an estimate of when it hits the critical threshold. Works on SQLite and Postgres. The n8n Public API has no endpoint for this.
Inputs: no named parameters.
git_driftGit driftA
Diffs the workflows in the running instance against the JSON exports in a git checkout: live but unexported, exported but deleted, and content that has drifted apart.
Inputs: no named parameters.
guard_runFull guard runB
Runs every check in one resilient sweep. Individual steps retry and, if they still fail, are reported as findings while the remaining checks finish. Use this for scheduled monitoring.
Inputs: keep_days.
instance_infoInstance infoA
Reachability, configuration and workflow inventory of the monitored n8n instance. Start here: it shows which checks are configured and which are not.
Inputs: no named parameters.
retention_reportRetention reportA
How many execution records are stored, how far back they go, and what pruning to a retention window would free. Read-only: n8n-guard never deletes anything.
Inputs: keep_days.
stuck_executionsStuck executionsA
Executions sitting in running past a threshold or far past their own workflow's median runtime. Listing by status is not detection: this compares against a baseline.
Inputs: threshold_minutes.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each check targets a distinct n8n failure mode: instance inventory, datastore growth, stuck executions, retention, and git drift. guard_run is explicitly an aggregate sweep, so its overlap with the individual checks is intentional and clearly described.
All tool names use lower_snake_case and concise check-oriented identifiers. guard_run is slightly more action-oriented than the others, but the naming convention remains consistent throughout.
Six tools is well-scoped for a read-only n8n monitoring server. Each tool maps to a meaningful check or aggregate runner, with no filler.
The surface covers the core monitoring lifecycle: instance discovery, DB health, stuck executions, retention, git drift, and a resilient aggregate run. Minor gaps remain around explicit alerting/escalation or worker/queue health, but the main guard workflows are covered.
Maintenance
Related MCP Connectors
n8n MCP — query your own n8n instance (BYO).
Security scanner for n8n workflows + live MCP Trust-Check. 18 rules, OWASP mapped. Paid x402 API.
Monitor MCP servers, API contracts and AI outputs for schema drift. Alerts on breaking changes.
Know when your n8n workflows, URLs, and AI apps break, before your customers do.
Related MCP Servers
- AlicenseAqualityDmaintenance🪄 MCP server for programmatic creation and management of n8n workflows. Enables AI assistants to build, modify, and manage workflows without direct user intervention through a comprehensive set of tools and resources for interacting with n8n's REST API.1029 npm86MIT
- AlicenseBqualityCmaintenanceSafe MCP server and CLI tool for testing, scoring, and inspecting n8n workflows. Features 19 tools for workflow testing, execution traces, tiered scoring, and a built-in node catalog with 800+ node types. Designed with safety-first approach: no credential management, no secrets lifecycle, no auto-fix loops.191MIT
- AlicenseNot gradedqualityDmaintenanceMCP server for n8n workflow automation, enabling management of workflows, executions, credentials, tags, users, and webhooks via an MCP-compatible client.MIT
- AlicenseBqualityDmaintenanceMCP server for managing n8n workflows and executions. Enables listing, activating, deactivating, and executing workflows, as well as monitoring executions and instance health.9MIT