CLI + MCP server ที่รับ natural language description แล้วให้ Claude (claude-sonnet-4-6 ผ่าน OpenRouter) generate n8n workflow JSON ที่ valid พร้อม push ขึ้น n8n instance บน Hostinger ได้โดยตรง รวมถึง self-healing failed executions อัตโนมัติ
~/Desktop/Claude Code Data/n8n claude gen/~/Documents/SmartWiki/Apps/operations/n8n-Workflow-Generator.mdgenerate.js / heal.js / mcp-server.js
│
├── src/n8n-introspect.js ← real credentials + workflow context
├── src/generator.js ← OpenRouter (claude-sonnet-4-6) + prompt
├── src/healer.js ← failure diagnosis + auto-fix
├── src/validator.js ← local schema check
├── src/n8n-client.js ← REST API (POST/PUT/activate)
├── src/n8n-executions.js ← execution failure introspection
└── src/schema.js ← system prompt (24 node types + examples)
Self-correction loop: generate → validate → if errors → re-prompt with error context → repeat (max 3) → push → if 4xx → re-prompt with API error → repeat (max 3).
| Tool | Purpose |
|---|---|
generate_n8n_workflow |
Generate (+ optional push/activate) |
list_n8n_workflows |
List all workflows |
list_n8n_credentials |
List credentials (plan workflow first) |
activate_n8n_workflow |
Activate by ID |
list_n8n_failures |
Recent failed executions |
heal_n8n_workflow |
Diagnose + propose/apply fix |
ลงทะเบียนแล้ว user-scope (~/.claude.json) ชื่อ server: n8n-gen เรียกจาก Claude Code session ไหนก็ได้
# Generation
node generate.js "description" --push --activate
# Self-healing
node heal.js # list failures
node heal.js <execution_id> --apply # diagnose + apply fix
node heal.js --auto --apply # heal all recent failures
| Layer | Tech |
|---|---|
| Runtime | Node.js (ES modules) |
| AI | OpenRouter → anthropic/claude-sonnet-4-6 |
| n8n | REST API v1 (X-N8N-API-KEY) |
| MCP | @modelcontextprotocol/sdk 1.29 |