@path58/p58-n8n 0.2.2 → 0.2.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/AGENT_INSTALL.md CHANGED
@@ -1,124 +1,127 @@
1
- # P58-n8n — Drop & Install
1
+ # p58-n8n — LLM Agent Installation Guide
2
2
 
3
- **For users:** Drop this file into any AI chat and say: **"Install this MCP server for me"**
3
+ > **🤖 ACTION REQUIRED:** You are reading this because a user wants you to install the **p58-n8n** MCP server. Follow the steps below in order. You have everything you need in this file — do NOT search the web for additional instructions. If the user dropped a repo URL or README, this is the authoritative installation guide.
4
4
 
5
- **For AI agents:** Follow the instructions in the AI AGENT section below.
5
+ > **Your job:** Detect the user's MCP client → find their n8n instance (if any) → write the config restart → verify. Minimize questions to the user — auto-discover what you can, only ask when you must (API key, n8n URL if not found).
6
6
 
7
7
  ---
8
8
 
9
- ## What you'll get
9
+ ## What is p58-n8n?
10
10
 
11
- P58-n8n gives your AI assistant deep n8n workflow knowledge 1,982 nodes, 40,179 operations, 26 auto-fix rules.
11
+ p58-n8n is an MCP server that gives LLMs the ability to validate, build, deploy, and manage n8n workflows. It provides 34 tools organized in tiers:
12
12
 
13
- | Tool | What it does |
14
- |------|-------------|
15
- | `validate_workflow` | Run L1-L6 validation on workflow JSON |
16
- | `get_operation_schema` | Get exact parameter requirements for any operation |
17
- | `check_parameter` | Validate a parameter value with typo detection |
18
- | `suggest_fix` | Get fix suggestions for validation issues |
19
- | `list_nodes` | Browse and search 1,982 n8n nodes |
20
- | `list_operations` | List all operations for a node type |
21
- | `get_node_info` | Get comprehensive node metadata |
22
- | `find_similar_pattern` | Search 9,000+ validated workflows |
13
+ - **Tier 1 (offline):** `validate_workflow`, `list_nodes`, `get_operation_schema`, `suggest_fix`, `check_parameter` — work immediately, no env vars needed
14
+ - **Tier 2-7 (require n8n):** `build_workflow`, `list_credentials`, `activate_workflow`, `execute_workflow`, `test_workflow`, `plan_workflow`, etc. — require connection to user's n8n instance
23
15
 
24
- ### Supported clients
16
+ ---
25
17
 
26
- | Client | Support | Transport |
27
- |--------|---------|-----------|
28
- | Claude Desktop (Chat + Cowork) | Primary | stdio |
29
- | Claude Code (CLI) | Primary | stdio |
30
- | Gemini CLI | Secondary | stdio |
31
- | ChatGPT Desktop | Not supported | Requires HTTP/SSE |
18
+ ## Installation Decision Tree
19
+
20
+ ```
21
+ Does the user have n8n running?
22
+ ├── YES Full install (N8N_API_URL + N8N_API_KEY)
23
+ │ All 34 tools work: validate, build, deploy, execute
24
+
25
+ └── NO / DON'T KNOW → Minimal install (no env vars)
26
+ Tier 1 tools only: validate, list, check params
27
+ User can add n8n config later
28
+ ```
32
29
 
33
30
  ---
34
31
 
35
- ## AI AGENT: Follow These Instructions
32
+ ## Step 1: Detect the MCP Client
36
33
 
37
- ### STEP 1 Detect Environment
34
+ Determine which AI client the user is using. Check for config files in this order:
38
35
 
39
- Determine your capabilities and the user's platform.
36
+ | Client | Config File Path | OS |
37
+ |--------|-----------------|-----|
38
+ | **Claude Desktop** | `~/Library/Application Support/Claude/claude_desktop_config.json` | macOS |
39
+ | **Claude Desktop** | `%APPDATA%\Claude\claude_desktop_config.json` | Windows |
40
+ | **Claude Desktop** | `~/.config/Claude/claude_desktop_config.json` | Linux |
41
+ | **Claude Code** | Use `claude mcp add` CLI command | All |
42
+ | **Cursor** | `~/.cursor/mcp.json` | All |
43
+ | **Windsurf** | `~/.codeium/windsurf/mcp_config.json` | All |
44
+ | **VS Code (Copilot)** | `.vscode/mcp.json` in workspace | All |
40
45
 
41
- **Can you execute commands?**
42
- ```
43
- Can I run shell commands?
44
- ├─ YES (Claude Code, Cowork mode, Gemini CLI) → Go to STEP 2a (Auto-Install)
45
- └─ NO (Claude Desktop Chat-only) → Go to STEP 2b (Guided Install)
46
- ```
47
-
48
- **Detect platform:**
49
- ```
50
- What OS is the user on?
51
- ├─ macOS → Config paths use ~/Library/Application Support/
52
- ├─ Windows → Config paths use %APPDATA%\
53
- └─ Linux → Config paths use ~/.config/
54
- ```
46
+ **Detection method:** Check if these files exist. If multiple exist, ask the user which client they want to configure.
55
47
 
56
48
  ---
57
49
 
58
- ### STEP 2a Auto-Install (can run commands)
50
+ ## Step 2: Find the User's n8n Instance
59
51
 
60
- **Prerequisites verify first:**
52
+ Try these methods in order:
61
53
 
54
+ ### Method A: Check environment variables
62
55
  ```bash
63
- node --version
64
- # Must be v18.0.0 or higher. If not installed, tell the user to install from https://nodejs.org/
56
+ echo $N8N_API_URL
57
+ echo $N8N_API_BASE_URL
58
+ echo $N8N_HOST
65
59
  ```
66
60
 
67
- **Then install based on which client the user wants:**
68
-
69
- #### Claude Code
61
+ ### Method B: Probe common localhost ports
62
+ ```bash
63
+ # Standard n8n port
64
+ curl -s -o /dev/null -w "%{http_code}" http://localhost:5678/api/v1/workflows 2>/dev/null
65
+ # Returns 401 = n8n is running (auth required) ✅
66
+ # Returns 000 = n8n is not running at this address ❌
67
+ ```
70
68
 
71
- Run this single command:
69
+ ### Method C: Check Docker containers
70
+ ```bash
71
+ docker ps --filter "name=n8n" --format "{{.Ports}}" 2>/dev/null
72
+ # Example output: 0.0.0.0:5678->5678/tcp → n8n at localhost:5678
73
+ ```
72
74
 
75
+ ### Method D: Check running processes
73
76
  ```bash
74
- claude mcp add p58-n8n -- npx -y @path58/p58-n8n
77
+ ps aux | grep -i n8n | grep -v grep
75
78
  ```
76
79
 
77
- Done. Skip to STEP 3.
80
+ ### Method E: Ask the user
81
+ If none of the above work, ask: "What is the URL of your n8n instance? (e.g., http://localhost:5678 or https://n8n.example.com)"
78
82
 
79
- #### Claude Desktop (Cowork mode can write files)
83
+ **IMPORTANT:** The API URL must include the `/api/v1` suffix. Example: `http://localhost:5678/api/v1`
80
84
 
81
- Read the existing config file first, then MERGE the p58-n8n entry. NEVER overwrite the entire file.
85
+ ---
82
86
 
83
- **Config file paths:**
84
- - macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
85
- - Windows: `%APPDATA%\Claude\claude_desktop_config.json`
86
- - Linux: `~/.config/Claude/claude_desktop_config.json`
87
+ ## Step 3: Get the n8n API Key
87
88
 
88
- **If file exists:** Read it, parse the JSON, add this entry inside `mcpServers`:
89
+ The API key cannot be auto-discovered. The user must provide it or create one.
89
90
 
90
- ```json
91
- "p58-n8n": {
92
- "command": "npx",
93
- "args": ["-y", "@path58/p58-n8n"]
94
- }
95
- ```
91
+ **Instructions to give the user:**
92
+ 1. Open n8n in your browser (the URL from Step 2, without `/api/v1`)
93
+ 2. Go to **Settings → API Keys** (or **Settings → n8n API**)
94
+ 3. Click **Create an API key**
95
+ 4. Copy the key — it starts with `eyJ...` (JWT format)
96
+ 5. Share it with me so I can add it to your config
97
+
98
+ **If the user can't find API Keys in Settings:** They may be on n8n Community Edition < 0.225.0 or n8n Cloud with API disabled. API key management requires admin access.
99
+
100
+ ---
96
101
 
97
- **If file doesn't exist:** Create it with:
102
+ ## Step 4: Write the Configuration
98
103
 
104
+ ### For Claude Desktop / Cursor / Windsurf / VS Code (JSON config)
105
+
106
+ Read the existing config file, then add p58-n8n inside the `mcpServers` object. Do NOT overwrite existing MCP servers.
107
+
108
+ **Full config (with n8n):**
99
109
  ```json
100
110
  {
101
111
  "mcpServers": {
102
112
  "p58-n8n": {
103
113
  "command": "npx",
104
- "args": ["-y", "@path58/p58-n8n"]
114
+ "args": ["-y", "@path58/p58-n8n"],
115
+ "env": {
116
+ "N8N_API_URL": "http://localhost:5678/api/v1",
117
+ "N8N_API_KEY": "<paste-api-key-here>"
118
+ }
105
119
  }
106
120
  }
107
121
  }
108
122
  ```
109
123
 
110
- Tell the user to restart Claude Desktop.
111
-
112
- #### Gemini CLI
113
-
114
- There is NO `gemini mcp add` command. Edit the config file directly.
115
-
116
- **Config path:** `~/.gemini/settings.json` (user-level) or `.gemini/settings.json` (project-level)
117
-
118
- **If file exists:** Read it, parse JSON, add the `p58-n8n` entry inside `mcpServers`.
119
-
120
- **If file doesn't exist:** Create it with:
121
-
124
+ **Minimal config (validation only, no n8n needed):**
122
125
  ```json
123
126
  {
124
127
  "mcpServers": {
@@ -130,94 +133,103 @@ There is NO `gemini mcp add` command. Edit the config file directly.
130
133
  }
131
134
  ```
132
135
 
133
- ---
136
+ ### For Claude Code (CLI)
134
137
 
135
- ### STEP 2b — Guided Install (chat-only)
138
+ **Full config:**
139
+ ```bash
140
+ claude mcp add p58-n8n \
141
+ -e N8N_API_URL=http://localhost:5678/api/v1 \
142
+ -e N8N_API_KEY=<paste-api-key-here> \
143
+ -- npx -y @path58/p58-n8n
144
+ ```
136
145
 
137
- Ask the user which client they want to set up, then give them copy-paste instructions.
146
+ **Minimal config:**
147
+ ```bash
148
+ claude mcp add p58-n8n -- npx -y @path58/p58-n8n
149
+ ```
138
150
 
139
- **Ask:** "Which AI client do you want to use P58-n8n with?"
151
+ ---
140
152
 
141
- #### For Claude Desktop
153
+ ## Step 5: Restart the Client
142
154
 
143
- Tell the user:
155
+ The MCP server config is only read at startup. After writing the config:
144
156
 
145
- 1. Open your Claude Desktop config file:
146
- - **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
147
- - **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
148
- - **Linux:** `~/.config/Claude/claude_desktop_config.json`
157
+ | Client | Restart Method |
158
+ |--------|---------------|
159
+ | **Claude Desktop** | Quit completely (Cmd+Q on macOS), then reopen |
160
+ | **Claude Code** | Exit and restart the CLI session |
161
+ | **Cursor** | Restart Cursor (Cmd+Shift+P → Reload Window) |
162
+ | **Windsurf** | Restart Windsurf |
149
163
 
150
- 2. Add this inside the `mcpServers` object (create the file if it doesn't exist):
164
+ **CRITICAL:** On macOS, closing the window is NOT enough for Claude Desktop. The user must Cmd+Q to fully quit.
151
165
 
152
- ```json
153
- {
154
- "mcpServers": {
155
- "p58-n8n": {
156
- "command": "npx",
157
- "args": ["-y", "@path58/p58-n8n"]
158
- }
159
- }
160
- }
161
- ```
166
+ ---
162
167
 
163
- 3. Restart Claude Desktop.
168
+ ## Step 6: Verify Installation
164
169
 
165
- #### For Claude Code
170
+ After restart, run these verification steps:
166
171
 
167
- Tell the user to run:
172
+ ### Check 1: Tool availability
173
+ Ask: "List n8n nodes for sending email"
174
+ - **Expected:** The LLM calls `list_nodes` and returns results
175
+ - **If tools not visible:** Config file has syntax error or wrong path
168
176
 
169
- ```bash
170
- claude mcp add p58-n8n -- npx -y @path58/p58-n8n
171
- ```
177
+ ### Check 2: n8n connectivity (if configured)
178
+ Ask: "Check n8n server health"
179
+ - **Expected:** `connected: true` with server version
180
+ - **If `connected: false`:** Check N8N_API_URL — is n8n actually running at that address?
181
+ - **If `Authentication failed`:** Check N8N_API_KEY — is it valid?
172
182
 
173
- #### For Gemini CLI
183
+ ### Check 3: Full pipeline (if n8n connected)
184
+ Ask: "List my n8n credentials"
185
+ - **Expected:** Returns list of configured credentials
186
+ - **If error:** API key may be expired or n8n needs restart
174
187
 
175
- Tell the user:
188
+ ---
176
189
 
177
- 1. Open `~/.gemini/settings.json` (create if needed)
178
- 2. Add:
190
+ ## Environment Variables Reference
179
191
 
180
- ```json
181
- {
182
- "mcpServers": {
183
- "p58-n8n": {
184
- "command": "npx",
185
- "args": ["-y", "@path58/p58-n8n"]
186
- }
187
- }
188
- }
189
- ```
192
+ | Variable | Required? | Description | How to find |
193
+ |----------|-----------|-------------|-------------|
194
+ | `N8N_API_URL` | For Tier 2-7 tools | n8n instance API URL | See Step 2 above |
195
+ | `N8N_API_KEY` | For Tier 2-7 tools | n8n API authentication key | n8n → Settings → API Keys |
190
196
 
191
- #### For ChatGPT Desktop
197
+ > **Note:** `N8N_API_BASE_URL` is accepted as a fallback for `N8N_API_URL`. If neither is set, defaults to `http://localhost:5678/api/v1`.
192
198
 
193
- Tell the user: **ChatGPT Desktop is not supported.** It requires HTTP/SSE transport for MCP servers, but P58-n8n uses stdio transport. This may be supported in a future version.
199
+ ### Variables NOT needed for standard installation
200
+
201
+ | Variable | Purpose | Who needs it |
202
+ |----------|---------|-------------|
203
+ | `P58_DATABASE_URL` | Extended catalog enrichment | Path58 internal / advanced users only |
204
+ | `NODE_ENV` | Logger behavior | Not needed (server handles this) |
205
+ | `NO_COLOR` | Disable ANSI colors | Not needed (server strips automatically since v0.2.2) |
194
206
 
195
207
  ---
196
208
 
197
- ### STEP 3 — Verify Installation
209
+ ## Troubleshooting
198
210
 
199
- After setup, test with this prompt:
211
+ | Symptom | Cause | Fix |
212
+ |---------|-------|-----|
213
+ | Tools not appearing | Config syntax error | Validate JSON (check trailing commas, unclosed braces) |
214
+ | Tools not appearing | Wrong config file path | Verify OS-specific path from Step 1 |
215
+ | "npx: command not found" | Node.js not installed | Install from https://nodejs.org/ |
216
+ | "Authentication failed" on deploy tools | N8N_API_KEY missing or invalid | Add API key to config, restart client |
217
+ | "Connection refused" on server_health | n8n not running at configured URL | Start n8n or fix N8N_API_URL |
218
+ | All tools timeout | Firewall blocking localhost | Check firewall / VPN settings |
219
+ | Server shows "failed" status | ANSI color issue (pre-v0.2.2) | Update to latest version: `npx -y @path58/p58-n8n@latest` |
200
220
 
201
- > "List available n8n nodes for email"
221
+ ---
202
222
 
203
- **Expected result:** The AI calls `list_nodes` and returns nodes like `n8n-nodes-base.gmail`, `n8n-nodes-base.emailSend`, etc.
223
+ ## Post-Install: What the User Can Do
204
224
 
205
- **If it doesn't work:**
225
+ Once installed, the user can ask their AI assistant to:
206
226
 
207
- ```
208
- Tools not appearing?
209
- ├─ Config file in wrong location → Check OS-specific paths above
210
- ├─ Invalid JSON syntax → Validate with: cat <path> | python3 -m json.tool
211
- ├─ Client not restarted → Close and reopen the AI client
212
- ├─ npx not found → Install Node.js 18+ from https://nodejs.org/
213
- └─ Permission error → Try: sudo npm install -g @path58/p58-n8n
214
-
215
- Server starts but tools don't work?
216
- ├─ Database not accessible → Server needs network access to Supabase
217
- ├─ Timeout errors → Check internet connection
218
- └─ "Module not found" → Run: npm install -g @path58/p58-n8n (reinstall)
219
- ```
227
+ - **"Validate this n8n workflow JSON"** — Tier 1, works immediately
228
+ - **"What parameters does the Slack node need?"** — Tier 1, works immediately
229
+ - **"Build me a workflow that sends Slack when Gmail receives an email"** — Tier 2+, needs n8n
230
+ - **"List my n8n credentials"** Tier 2+, needs n8n
231
+ - **"Deploy and test this workflow"** Tier 2+, needs n8n
220
232
 
221
233
  ---
222
234
 
223
- **Package:** `@path58/p58-n8n` | **License:** MIT | **Built by [Path58](https://path58.com)**
235
+ **Package:** `@path58/p58-n8n` | **npm:** https://www.npmjs.com/package/@path58/p58-n8n | **Version:** 0.2.2+
package/README.md CHANGED
@@ -8,6 +8,8 @@
8
8
 
9
9
  p58-n8n is an MCP server that gives your AI assistant deep knowledge of n8n — **1,545 nodes**, **12,619 operations**, **38,005 parameter rules** — so it can plan, build, validate, fix, and deploy workflows correctly. No manual iteration. No broken JSON.
10
10
 
11
+ > **🤖 AI Agent?** If you are an LLM assistant and a user asked you to install this MCP server, **stop here and read [`AGENT_INSTALL.md`](https://github.com/tsvika58/n8n-workflow-validator/blob/main/AGENT_INSTALL.md)** — it has the complete autonomous installation guide with client detection, n8n auto-discovery, config templates for all clients, and verification steps. Everything you need to install p58-n8n without asking the user unnecessary questions.
12
+
11
13
  ---
12
14
 
13
15
  ## Quick Start (< 2 minutes)
@@ -28,7 +30,10 @@ npm install -g @path58/p58-n8n
28
30
 
29
31
  **Claude Code** (one command):
30
32
  ```bash
31
- claude mcp add p58-n8n -- npx -y @path58/p58-n8n
33
+ claude mcp add p58-n8n \
34
+ -e N8N_API_URL=http://localhost:5678/api/v1 \
35
+ -e N8N_API_KEY=your-n8n-api-key \
36
+ -- npx -y @path58/p58-n8n
32
37
  ```
33
38
 
34
39
  **Claude Desktop** — add to `claude_desktop_config.json`:
@@ -39,17 +44,24 @@ claude mcp add p58-n8n -- npx -y @path58/p58-n8n
39
44
  "command": "npx",
40
45
  "args": ["-y", "@path58/p58-n8n"],
41
46
  "env": {
42
- "P58_DATABASE_URL": "your-supabase-connection-string"
47
+ "N8N_API_URL": "http://localhost:5678/api/v1",
48
+ "N8N_API_KEY": "your-n8n-api-key"
43
49
  }
44
50
  }
45
51
  }
46
52
  }
47
53
  ```
48
54
 
55
+ Get your API key from **n8n → Settings → API Keys**.
56
+
49
57
  Config file location: `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows). Restart Claude Desktop after saving.
50
58
 
59
+ > **Note:** Validation tools (`validate_workflow`, `list_nodes`, etc.) work immediately without any env vars. The `N8N_API_URL` and `N8N_API_KEY` are only needed for deploy, execute, and credential tools.
60
+
51
61
  **Cursor / Windsurf** — see [docs/INSTALLATION.md](docs/INSTALLATION.md) for full multi-client setup.
52
62
 
63
+ **LLM-assisted setup** — if you're an AI agent helping a user install p58-n8n, read [AGENT_INSTALL.md](https://github.com/tsvika58/n8n-workflow-validator/blob/main/AGENT_INSTALL.md) for the autonomous installation guide.
64
+
53
65
  ### 3. Try it
54
66
 
55
67
  ```
@@ -52,6 +52,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
52
52
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
53
53
  mod
54
54
  ));
55
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
55
56
 
56
57
  // node_modules/consola/dist/core.cjs
57
58
  var require_core = __commonJS({
@@ -18433,6 +18434,12 @@ var init_cached_catalog_adapter = __esm({
18433
18434
  });
18434
18435
 
18435
18436
  // dist/mcp/server.js
18437
+ var server_exports = {};
18438
+ __export(server_exports, {
18439
+ TIER_1_TOOLS: () => TIER_1_TOOLS,
18440
+ logStartupSummary: () => logStartupSummary
18441
+ });
18442
+ module.exports = __toCommonJS(server_exports);
18436
18443
  var import_server = require("@modelcontextprotocol/sdk/server/index.js");
18437
18444
  var import_stdio = require("@modelcontextprotocol/sdk/server/stdio.js");
18438
18445
  var import_types22 = require("@modelcontextprotocol/sdk/types.js");
@@ -18441,7 +18448,7 @@ var import_types22 = require("@modelcontextprotocol/sdk/types.js");
18441
18448
  var config = {
18442
18449
  // Server identity
18443
18450
  SERVER_NAME: "p58-n8n",
18444
- SERVER_VERSION: "0.2.2",
18451
+ SERVER_VERSION: "0.2.3",
18445
18452
  // Database configuration (from environment)
18446
18453
  SUPABASE_URL: process.env.SUPABASE_URL,
18447
18454
  SUPABASE_KEY: process.env.SUPABASE_KEY,
@@ -18727,6 +18734,7 @@ var collectConfigSchema = import_zod.z.object({
18727
18734
  config_requirements: import_zod.z.array(configRequirementItemSchema).optional().describe("Config requirements from plan_workflow response (preferred over workflow_json). Pass the configRequirements array directly from plan_workflow output."),
18728
18735
  user_responses: import_zod.z.record(import_zod.z.unknown()).optional().describe('User-provided values keyed by "nodeType:parameterName" (from question.id). Example: { "n8n-nodes-base.googleSheets:spreadsheetId": "1BxiMVs0..." }. Omit to get questions without providing values (first turn of multi-turn collection).')
18729
18736
  });
18737
+ var setupCheckSchema = import_zod.z.object({});
18730
18738
  var toolSchemas = {
18731
18739
  test_workflow: testWorkflowSchema,
18732
18740
  validate_workflow: validateWorkflowSchema,
@@ -18761,7 +18769,8 @@ var toolSchemas = {
18761
18769
  test_credential: testCredentialSchema,
18762
18770
  update_credential: updateCredentialSchema,
18763
18771
  delete_credential: deleteCredentialSchema,
18764
- collect_config: collectConfigSchema
18772
+ collect_config: collectConfigSchema,
18773
+ setup_check: setupCheckSchema
18765
18774
  };
18766
18775
 
18767
18776
  // dist/mcp/tools/validate.js
@@ -38825,6 +38834,16 @@ async function warmCredentialCache() {
38825
38834
  import_logging42.logger.warn("credential-cache: warm-up failed (non-fatal)", { error: String(error) });
38826
38835
  }
38827
38836
  }
38837
+ function getCredentialCacheStatus() {
38838
+ if (!cacheState) {
38839
+ return { loaded: false, count: 0, expires_at: null };
38840
+ }
38841
+ return {
38842
+ loaded: true,
38843
+ count: cacheState.credentials.length,
38844
+ expires_at: new Date(cacheState.expires_at).toISOString()
38845
+ };
38846
+ }
38828
38847
  function clearCredentialCache() {
38829
38848
  cacheState = null;
38830
38849
  }
@@ -44091,6 +44110,161 @@ When values are collected, marks matching factory.gaps entries as resolved for a
44091
44110
  }
44092
44111
  };
44093
44112
 
44113
+ // dist/mcp/tools/handlers/shared/n8n-guard.js
44114
+ var SETUP_GUIDE_URL = "https://github.com/tsvika58/n8n-workflow-validator/blob/main/docs/AGENT_INSTALL.md";
44115
+ var OFFLINE_TOOLS = /* @__PURE__ */ new Set([
44116
+ "validate_workflow",
44117
+ "get_operation_schema",
44118
+ "check_parameter",
44119
+ "suggest_fix",
44120
+ "list_operations",
44121
+ "list_nodes",
44122
+ "get_node_info",
44123
+ "find_similar_pattern",
44124
+ "get_session_metrics",
44125
+ "get_credential_schema",
44126
+ "setup_check"
44127
+ ]);
44128
+ function requiresN8nApiKey(toolName) {
44129
+ return !OFFLINE_TOOLS.has(toolName);
44130
+ }
44131
+ function makeN8nNotConfiguredError() {
44132
+ return {
44133
+ content: [
44134
+ {
44135
+ type: "text",
44136
+ text: JSON.stringify({
44137
+ error: `This tool requires n8n connection. Set N8N_API_URL and N8N_API_KEY in your MCP config. See: ${SETUP_GUIDE_URL}`
44138
+ })
44139
+ }
44140
+ ],
44141
+ isError: true
44142
+ };
44143
+ }
44144
+
44145
+ // dist/mcp/tools/handlers/setup-check.js
44146
+ var SETUP_GUIDE_URL2 = "https://github.com/tsvika58/n8n-workflow-validator/blob/main/docs/AGENT_INSTALL.md";
44147
+ var N8N_PROBE_TIMEOUT_MS = 2e3;
44148
+ var N8N_PROBE_PORTS = [5678, 5679];
44149
+ async function probeN8nUrl(url2) {
44150
+ const controller = new AbortController();
44151
+ const timer = setTimeout(() => controller.abort(), N8N_PROBE_TIMEOUT_MS);
44152
+ try {
44153
+ const response = await fetch(url2, { signal: controller.signal });
44154
+ const needs_api_key = response.status === 401 || response.status === 403;
44155
+ return { url: url2, status: response.status, needs_api_key, reachable: true };
44156
+ } catch (error) {
44157
+ const message = error instanceof Error ? error.message : String(error);
44158
+ return {
44159
+ url: url2,
44160
+ status: null,
44161
+ needs_api_key: false,
44162
+ reachable: false,
44163
+ error: message.includes("abort") ? "timeout" : message
44164
+ };
44165
+ } finally {
44166
+ clearTimeout(timer);
44167
+ }
44168
+ }
44169
+ async function discoverN8nInstances() {
44170
+ const probeUrls = N8N_PROBE_PORTS.map((port) => `http://localhost:${port}/api/v1/workflows`);
44171
+ return Promise.all(probeUrls.map(probeN8nUrl));
44172
+ }
44173
+ function buildToolCounts() {
44174
+ const total = getRegisteredTools().length;
44175
+ const tier1 = OFFLINE_TOOLS.size;
44176
+ return { tier1, tier2_7: total - tier1 };
44177
+ }
44178
+ function collectIssues(apiKeySet, n8nConnected, probes) {
44179
+ const issues = [];
44180
+ if (!apiKeySet) {
44181
+ issues.push("N8N_API_KEY not set \u2014 Tier 2-7 deploy tools unavailable");
44182
+ }
44183
+ const apiUrlSet = Boolean(process.env.N8N_API_URL ?? process.env.N8N_API_BASE_URL);
44184
+ if (!apiUrlSet && probes) {
44185
+ const reachable = probes.filter((p) => p.reachable);
44186
+ if (reachable.length > 0) {
44187
+ const probeUrl = reachable[0].url.replace("/api/v1/workflows", "");
44188
+ issues.push(`N8N_API_URL not set \u2014 n8n detected at ${probeUrl}. Set N8N_API_URL=${probeUrl}/api/v1 in your MCP config.`);
44189
+ } else {
44190
+ issues.push("N8N_API_URL not set \u2014 no n8n instance detected on localhost:5678 or localhost:5679");
44191
+ }
44192
+ }
44193
+ if (apiKeySet && !n8nConnected) {
44194
+ issues.push("N8N_API_KEY is set but n8n is unreachable \u2014 check N8N_API_URL and ensure n8n is running");
44195
+ }
44196
+ return issues;
44197
+ }
44198
+ async function buildReport() {
44199
+ const apiKeySet = Boolean(process.env.N8N_API_KEY);
44200
+ const n8nUrl = process.env.N8N_API_URL ?? process.env.N8N_API_BASE_URL ?? null;
44201
+ const cacheStatus = getCredentialCacheStatus();
44202
+ const n8nConnected = cacheStatus.loaded;
44203
+ const credentialCount = cacheStatus.loaded ? cacheStatus.count : null;
44204
+ let probes;
44205
+ if (!n8nUrl) {
44206
+ probes = await discoverN8nInstances();
44207
+ }
44208
+ const issues = collectIssues(apiKeySet, n8nConnected, probes);
44209
+ const toolCounts = buildToolCounts();
44210
+ const report = {
44211
+ server_version: config.SERVER_VERSION,
44212
+ n8n_configured: apiKeySet,
44213
+ n8n_url: n8nUrl,
44214
+ n8n_connected: n8nConnected,
44215
+ n8n_api_key_set: apiKeySet,
44216
+ credential_count: credentialCount,
44217
+ catalog_ready: true,
44218
+ tools_available: toolCounts,
44219
+ issues,
44220
+ setup_guide: SETUP_GUIDE_URL2
44221
+ };
44222
+ if (probes) {
44223
+ report.n8n_probes = probes.map((p) => ({
44224
+ ...p,
44225
+ url: p.url.replace("/api/v1/workflows", "/api/v1")
44226
+ }));
44227
+ }
44228
+ return report;
44229
+ }
44230
+ async function handleSetupCheck(_args) {
44231
+ try {
44232
+ const report = await buildReport();
44233
+ return {
44234
+ content: [{ type: "text", text: JSON.stringify(report, null, 2) }]
44235
+ };
44236
+ } catch (error) {
44237
+ const message = error instanceof Error ? error.message : String(error);
44238
+ return {
44239
+ content: [{ type: "text", text: JSON.stringify({ error: `setup_check failed: ${message}` }) }],
44240
+ isError: true
44241
+ };
44242
+ }
44243
+ }
44244
+ var setupCheckToolDefinition = {
44245
+ name: "setup_check",
44246
+ description: `Run this first to check what's configured and what's missing.
44247
+
44248
+ Returns a diagnostic report including:
44249
+ - Server version
44250
+ - n8n connection status (configured/connected/unreachable)
44251
+ - n8n URL (from env var or auto-detected)
44252
+ - Credential count (if n8n is connected)
44253
+ - Tool availability by tier
44254
+ - List of issues with actionable guidance
44255
+ - Link to the setup guide
44256
+
44257
+ When N8N_API_URL is not set, automatically probes localhost:5678 and localhost:5679
44258
+ to detect a local n8n installation.
44259
+
44260
+ Use this after installation to verify everything is working, or to diagnose
44261
+ connection problems.`,
44262
+ inputSchema: {
44263
+ type: "object",
44264
+ properties: {}
44265
+ }
44266
+ };
44267
+
44094
44268
  // dist/mcp/tools/index.js
44095
44269
  var toolRegistry = /* @__PURE__ */ new Map();
44096
44270
  var TOOL_ENTRIES = [
@@ -44127,7 +44301,8 @@ var TOOL_ENTRIES = [
44127
44301
  { name: "test_credential", definition: testCredentialToolDefinition, handler: handleTestCredential },
44128
44302
  { name: "update_credential", definition: updateCredentialToolDefinition, handler: handleUpdateCredential },
44129
44303
  { name: "delete_credential", definition: deleteCredentialToolDefinition, handler: handleDeleteCredential },
44130
- { name: "collect_config", definition: collectConfigToolDefinition, handler: handleCollectConfig }
44304
+ { name: "collect_config", definition: collectConfigToolDefinition, handler: handleCollectConfig },
44305
+ { name: "setup_check", definition: setupCheckToolDefinition, handler: handleSetupCheck }
44131
44306
  ];
44132
44307
  function registerTool(tool) {
44133
44308
  if (!hasSchema(tool.name)) {
@@ -44155,6 +44330,9 @@ async function dispatchToolCall(name, args) {
44155
44330
  const tool = toolRegistry.get(name);
44156
44331
  if (!tool)
44157
44332
  return buildUnknownToolResponse(name);
44333
+ if (requiresN8nApiKey(name) && !process.env.N8N_API_KEY) {
44334
+ return makeN8nNotConfiguredError();
44335
+ }
44158
44336
  if (tool.inputSchema && hasSchema(name)) {
44159
44337
  const validation = validateToolInput(name, args);
44160
44338
  if (!validation.success)
@@ -44383,6 +44561,39 @@ function registerShutdownHandlers(serverName, deps) {
44383
44561
  }
44384
44562
 
44385
44563
  // dist/mcp/server.js
44564
+ var TIER_1_TOOLS = /* @__PURE__ */ new Set([
44565
+ "validate_workflow",
44566
+ "get_operation_schema",
44567
+ "check_parameter",
44568
+ "suggest_fix",
44569
+ "list_operations",
44570
+ "list_nodes",
44571
+ "get_node_info",
44572
+ "find_similar_pattern"
44573
+ ]);
44574
+ var SETUP_GUIDE_URL3 = "https://github.com/tsvika58/n8n-workflow-validator/blob/main/docs/AGENT_INSTALL.md";
44575
+ function logStartupSummary(n8nConnected) {
44576
+ const apiKey = process.env.N8N_API_KEY;
44577
+ const n8nUrl = process.env.N8N_API_URL ?? process.env.N8N_API_BASE_URL ?? "http://localhost:5678/api/v1";
44578
+ const totalTools = getRegisteredTools().length;
44579
+ const tier1Count = TIER_1_TOOLS.size;
44580
+ const tier27Count = totalTools - tier1Count;
44581
+ let n8nStatus;
44582
+ if (!apiKey) {
44583
+ n8nStatus = "not configured (set N8N_API_URL and N8N_API_KEY for deploy tools)";
44584
+ } else if (n8nConnected) {
44585
+ n8nStatus = `connected (${n8nUrl})`;
44586
+ } else {
44587
+ n8nStatus = `configured but unreachable (${n8nUrl})`;
44588
+ }
44589
+ const tier27Status = apiKey && n8nConnected ? `${tier27Count} tools ready` : `${tier27Count} tools unavailable (no N8N_API_KEY)`;
44590
+ console.error(`n8n: ${n8nStatus}`);
44591
+ console.error(`catalog: ready`);
44592
+ console.error(`Tier 1: ${tier1Count} tools ready | Tier 2-7: ${tier27Status}`);
44593
+ if (!apiKey) {
44594
+ console.error(`Setup guide: ${SETUP_GUIDE_URL3}`);
44595
+ }
44596
+ }
44386
44597
  var server = new import_server.Server({
44387
44598
  name: config.SERVER_NAME,
44388
44599
  version: config.SERVER_VERSION
@@ -44417,13 +44628,20 @@ async function main() {
44417
44628
  await server.connect(transport);
44418
44629
  const toolCount = getRegisteredTools().length;
44419
44630
  console.error(`${config.SERVER_NAME} v${config.SERVER_VERSION} running on stdio (${toolCount} tools registered)`);
44631
+ logStartupSummary(Boolean(process.env.N8N_API_KEY));
44420
44632
  registerShutdownHandlers(config.SERVER_NAME);
44421
- warmCredentialCache().catch((e) => console.error("Credential cache warm-up failed:", e));
44633
+ void warmCredentialCache().catch(() => {
44634
+ });
44422
44635
  }
44423
44636
  main().catch((error) => {
44424
44637
  console.error("Server failed to start:", error);
44425
44638
  process.exit(1);
44426
44639
  });
44640
+ // Annotate the CommonJS export names for ESM import in node:
44641
+ 0 && (module.exports = {
44642
+ TIER_1_TOOLS,
44643
+ logStartupSummary
44644
+ });
44427
44645
  /*! Bundled license information:
44428
44646
 
44429
44647
  mime-db/index.js:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@path58/p58-n8n",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "The smartest and fastest n8n MCP server — validate, fix, and discover workflows inside your LLM",
5
5
  "keywords": [
6
6
  "mcp",
@@ -13,6 +13,7 @@
13
13
  ],
14
14
  "author": "Path58",
15
15
  "license": "MIT",
16
+ "homepage": "https://github.com/tsvika58/n8n-workflow-validator#readme",
16
17
  "repository": {
17
18
  "type": "git",
18
19
  "url": "git+https://github.com/tsvika58/n8n-workflow-validator.git"