28 Commits

Author SHA1 Message Date
czlonkowski
3fec6813f3 feat: implement n8n integration improvements and protocol version negotiation
- Add intelligent protocol version negotiation (2024-11-05 for n8n, 2025-03-26 for standard clients)
- Fix memory leak potential with async cleanup and connection close handling
- Enhance error sanitization for production environments
- Add schema validation for n8n nested output workaround
- Improve Docker security with unpredictable UIDs/GIDs
- Create n8n-friendly tool descriptions to reduce schema validation errors
- Add comprehensive protocol negotiation test suite

Addresses code review feedback:
- Protocol version inconsistency resolved
- Memory management improved
- Error information leakage fixed
- Docker security enhanced

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-01 14:23:48 +02:00
czlonkowski
7606566c4c fix: resolve root cause of user switching failure in Docker
This fixes the fundamental issue causing persistent test failures.

Root Cause:
- The entrypoint script's user switching was broken
- Used 'exec $*' which fails when no arguments provided
- Used 'printf %q' which doesn't exist in Alpine Linux
- User switching wasn't actually working properly

Fixes:
1. Added su-exec package to Dockerfile
   - Proper tool for switching users in containers
   - Handles signal propagation correctly
   - No intermediate shell process

2. Rewrote user switching logic
   - Uses su-exec with fallback to su
   - Fixed command injection vulnerability in su fallback
   - Properly handles case when no arguments provided
   - Exports environment variables before switching

3. Added security improvements
   - Restricted permissions on AUTH_TOKEN_FILE
   - Added comments explaining su-exec benefits

This explains why tests kept failing - we were testing around a broken implementation rather than fixing the actual broken code.
2025-07-31 15:27:34 +02:00
czlonkowski
71cd20bf95 fix: address security issues and improve Docker implementation
Security Fixes:
- Add command injection prevention in n8n-mcp wrapper with whitelist validation
- Fix race condition in database initialization with proper lock directory creation
- Add flock availability check with fallback behavior
- Implement comprehensive input sanitization in parse-config.js

Improvements:
- Add debug logging support to parse-config.js (DEBUG_CONFIG=true)
- Improve test cleanup error handling with proper error tracking
- Increase integration test timeouts for CI compatibility
- Update test assertions to check environment variables instead of processes

All critical security vulnerabilities identified by code review have been addressed.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-31 13:04:25 +02:00
czlonkowski
903a49d3b0 fix: add Docker configuration file support (fixes #105)
This commit adds comprehensive support for JSON configuration files in Docker containers,
addressing the issue where the Docker image fails to start in server mode and ignores
configuration files.

## Changes

### Docker Configuration Support
- Added parse-config.js to safely parse JSON configs and export as shell variables
- Implemented secure shell quoting to prevent command injection
- Added dangerous environment variable blocking for security
- Support for all JSON data types with proper edge case handling

### Docker Server Mode Fix
- Added support for "n8n-mcp serve" command in entrypoint
- Properly transforms serve command to HTTP mode
- Fixed missing n8n-mcp binary issue in Docker image

### Security Enhancements
- POSIX-compliant shell quoting without eval
- Blocked dangerous variables (PATH, LD_PRELOAD, etc.)
- Sanitized configuration keys to prevent invalid shell variables
- Protection against shell metacharacters in values

### Testing
- Added 53 comprehensive tests for Docker configuration
- Unit tests for parsing, security, and edge cases
- Integration tests for Docker entrypoint behavior
- Security-focused tests for injection prevention

### Documentation
- Updated Docker README with config file mounting examples
- Enhanced troubleshooting guide with config file issues
- Added version bump to 2.8.2

### Additional Files
- Included deployment-engineer and technical-researcher agent files

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-31 11:48:31 +02:00
czlonkowski
ee9efd7849 fix: resolve Docker build failures by copying tsconfig.build.json
- Updated Dockerfile to copy all tsconfig*.json files (includes tsconfig.build.json)
- Updated Dockerfile.railway with same fix
- Changed standard Dockerfile to use 'tsc -p tsconfig.build.json' for consistency
- This fixes the missing file errors preventing Docker builds in CI

The issue was that tsconfig.build.json was added for the testing infrastructure
but the Docker COPY commands were not updated to include it.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-30 10:13:14 +02:00
czlonkowski
23d12b4808 chore: upgrade Docker base images to Node.js 22 LTS Alpine (v2.7.22)
- Updated all Dockerfiles from node:20-alpine to node:22-alpine
- Addresses known vulnerabilities in older Alpine images
- Provides better long-term support with Node.js 22 LTS (until April 2027)
- Updated documentation to reflect new base image version
- Tested and verified compatibility with all dependencies

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-28 09:23:23 +02:00
czlonkowski
6e52afd5af fix: Docker container cleanup on session end (Issue #66)
- Added proper SIGTERM/SIGINT signal handlers to stdio-wrapper.ts
- Removed problematic trap commands from docker-entrypoint.sh
- Added STOPSIGNAL directive to Dockerfile for explicit signal handling
- Implemented graceful shutdown in MCP server with database cleanup
- Added stdin close detection for proper cleanup when Claude Desktop closes the pipe
- Containers now properly exit with the --rm flag, preventing accumulation
- Added --init flag to all Docker configuration examples
- Updated documentation with container lifecycle management best practices
- Bumped version to 2.7.20

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-18 18:51:24 +02:00
moonwalk
9e9a9856f4 Made deployable on Railway (#53)
* Rename Dockerfile to __Dockerfile

* Update and rename __Dockerfile to Dockerfile

* Update Dockerfile

* Update Dockerfile

* Update Dockerfile

* Update Dockerfile

* Update Dockerfile

* Update Dockerfile

* Update Dockerfile

* Rename Dockerfile to Dockerfile.railway

* Create Docherfile

* Rename Docherfile to Dockerfile

* Create railway.json

* Update README.md
2025-07-16 10:27:21 +02:00
czlonkowski
3e3017ede8 fix: force Docker to use updated database with trigger fixes
- Added cache-busting comment to invalidate Docker's build cache
- Previous builds were using cached COPY layer with old database from 13:18
- This ensures Docker copies the new database (15:38) with is_trigger=true fixes
- Affects: webhook, cron, interval, emailReadImap nodes

The Docker build cache was serving an old database without the trigger detection fix,
causing these nodes to incorrectly show isTrigger: false in the MCP tool.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-06 16:07:16 +02:00
czlonkowski
a0e3aed8e2 fix: Docker build by including n8n-workflow dependency
The Docker build was failing because TypeScript compilation requires n8n-workflow
and uuid packages that weren't being installed. Also removed the deletion of src/n8n
directory as it contains TypeScript files needed during compilation.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-27 12:34:30 +02:00
czlonkowski
928b71f2fe fix: add missing runtime dependencies for Docker image
- Add axios (^1.10.0) for n8n API client
- Add zod (^3.25.32) for workflow validation
- Update runtime package version to 2.6.2
- Update Dockerfile comment to reflect minimal (not zero) dependencies

Fixes Docker runtime error: "Cannot find module 'axios'"
introduced by n8n management tools in v2.6.0

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-26 15:01:23 +02:00
czlonkowski
f3aefd18d1 fix: add axios to Docker builder dependencies for TypeScript compilation
- TypeScript needs axios to compile template-fetcher.ts
- Runtime doesn't need axios since templates are in pre-built database
- Maintains minimal runtime dependencies

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-20 00:15:20 +02:00
czlonkowski
98b7e83739 fix: resolve TypeScript compilation errors in Docker build
The build was failing because TypeScript couldn't find module imports.
Fixed by:
1. Installing minimal dependencies needed for compilation (MCP SDK, dotenv, express)
2. Excluding n8n node implementation files that aren't needed for MCP server
   - Removed src/n8n directory (n8n node implementation)
   - Removed src/utils/bridge.ts and src/utils/mcp-client.ts (n8n-specific utils)

These files are only used for n8n integration, not for the MCP server runtime.

Results:
- Build succeeds with only 102 packages (vs 2294 before)
- TypeScript compiles without errors
- Faster builds and smaller image

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-18 23:37:48 +02:00
czlonkowski
8777c82235 fix: prevent npm from installing all n8n dependencies during Docker build
The build was taking 10 minutes because npm install was installing ALL
2294 packages from package-lock.json instead of just TypeScript.

Changed approach:
- Don't copy package*.json to builder stage
- Create empty package.json to prevent lock file issues
- Install only the 3 required packages explicitly

Results:
- Builder stage: 2294 packages → 13 packages
- Build time: ~374s → ~10s per platform
- Total build time: 10 minutes → ~2 minutes

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-18 23:32:48 +02:00
czlonkowski
c95313f343 feat: optimize Docker build to exclude n8n dependencies
Major optimization that reduces Docker image size by 87% and build time by 10x:

- Remove ALL n8n dependencies from runtime Docker image
- Add package.runtime.json with only 5 essential runtime deps
- Optimize Dockerfile to build TypeScript without n8n packages
- Add BuildKit optimizations with cache mounts
- Update documentation to highlight the improvements

Results:
- Image size: ~1.5GB → ~200MB (87% reduction)
- Build time: ~12 minutes → ~1-2 minutes
- No n8n version conflicts at runtime
- Better security with minimal attack surface

The key insight is that since we always rebuild the database locally
before deployment, the Docker runtime never needs n8n packages.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-18 23:09:18 +02:00
czlonkowski
75952f94ca fix: Docker stdio communication for Claude Desktop compatibility
Fixed the initialization timeout issue with minimal changes:

1. Added stdout flush after server connection to combat Docker buffering
2. Fixed docker-entrypoint.sh to not output to stdout in stdio mode
3. Added process.stdin.resume() to keep server alive
4. Added IS_DOCKER environment variable for future use
5. Updated README to prioritize Docker with correct -i flag configuration

The core issue was Docker's block buffering preventing immediate JSON-RPC
responses. The -i flag maintains stdin connection, and explicit flushing
ensures responses reach Claude Desktop immediately.

Also fixed "Shutting down..." message that was breaking JSON-RPC protocol
by redirecting it to stderr in stdio mode.

Docker is now the recommended installation method as originally intended.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-17 00:30:54 +02:00
czlonkowski
3e037898c8 fix: simplify Docker build to resolve multi-platform failures
## Root cause
- Docker buildx memory options were incorrectly formatted
- Database build during Docker image creation was failing on multi-platform builds
- n8n native dependencies caused issues across different architectures

## Solution
- Removed invalid buildx driver-opts configuration
- Eliminated database build stage from Dockerfile
- Now using pre-built nodes.db file (11MB) from repository
- Fixed .dockerignore to include nodes.db in build context
- Added .dockerignore to version control (was incorrectly gitignored)

## Benefits
- Faster builds (no n8n package installation during build)
- More reliable multi-platform builds (amd64 + arm64)
- Simpler Dockerfile (3 stages instead of 4)

Database can still be rebuilt locally using 'npm run rebuild' when needed.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-16 16:05:25 +02:00
czlonkowski
c1485d8f1b fix: resolve GitHub Actions workflow failures
## Fixed dependency updater workflow
- Added explicit workspace directory handling
- Improved error handling with clear error messages
- Fixed update summary file reading with error suppression
- Added error output for debugging failures

## Fixed Docker build workflow
- Added memory constraints (8GB/16GB swap) to prevent OOM
- Fixed Dockerfile to use npm scripts instead of direct node execution
- Added fallback mechanism: optimized rebuild → regular rebuild → error
- Added buildx ID reference and no-cache filter for db-builder stage

These changes should resolve both workflow failures and make the CI/CD pipeline more robust.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-16 15:59:03 +02:00
czlonkowski
4ef03da245 fix: resolve Docker build failures in GitHub Actions
- Added ca-certificates package for proper SSL certificate validation
- Configured git to handle SSL and initialization properly
- Added --depth 1 for faster cloning and reduced network issues
- Improved error handling to continue build even if docs clone fails
- Fixed su-exec issue by using Alpine's native su command
- Redirected git clone stderr to avoid polluting build logs

These changes address the exit code 128 git errors occurring in GitHub Actions
Docker builds while maintaining backwards compatibility.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-16 00:54:30 +02:00
czlonkowski
88dd66bb7a refactor: make optimized Dockerfile the default - remove full variant
- Rename Dockerfile.optimized to Dockerfile (now the default)
- Keep old Dockerfile as Dockerfile.old for reference
- Update GitHub Actions to use default Dockerfile
- Remove build-full job - only one image variant now
- Remove docker-compose.optimized.yml and other variants
- Update all documentation to reflect single image approach

The optimized 283MB image is now the only n8n-MCP Docker image.
This simplifies the user experience and provides the best solution
for all use cases.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-14 14:00:36 +02:00
czlonkowski
8878c99c3b feat: optimize Docker build with multi-stage deps and npm retry config 2025-06-13 23:47:09 +02:00
czlonkowski
b8b5e674dc fix: update npm ci flag from --only=production to --omit=dev and remove nginx build job 2025-06-13 21:11:43 +02:00
czlonkowski
d6f38dc1c4 docs: reorganize documentation files and update Docker build process 2025-06-13 17:20:31 +02:00
czlonkowski
12bef3d98e feat: add comprehensive Docker support with multi-stage builds and compose configurations 2025-06-13 16:12:40 +02:00
czlonkowski
6851d2f253 feat: add node extraction scripts and Docker setup for n8n modules 2025-06-09 00:33:17 +02:00
czlonkowski
1dd6b8e55f Clean up legacy documentation and scripts
- Remove all references to workflow execution/management features
- Delete legacy scripts for bidirectional n8n integration
- Update documentation to focus on node documentation serving only
- Remove old docker-compose files for workflow management
- Add simplified docker-compose.yml for documentation server
- Update CHANGELOG.md to reflect v2.0.0 and v2.1.0 changes
- Update Dockerfile to use v2 paths and database

The project is now clearly focused on serving n8n node documentation
to AI assistants, with no workflow execution capabilities.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-08 07:54:53 +00:00
czlonkowski
078b67ff35 Implement SQLite database with full-text search for n8n node documentation
Major features implemented:
- SQLite storage service with FTS5 for fast node search
- Database rebuild mechanism for bulk node extraction
- MCP tools: search_nodes, extract_all_nodes, get_node_statistics
- Production Docker deployment with persistent storage
- Management scripts for database operations
- Comprehensive test suite for all functionality

Database capabilities:
- Stores node source code and metadata
- Full-text search by node name or content
- No versioning (stores latest only as per requirements)
- Supports complete database rebuilds
- ~4.5MB database with 500+ nodes indexed

Production features:
- Automated deployment script
- Docker Compose production configuration
- Database initialization on first run
- Volume persistence for data
- Management utilities for operations

Documentation:
- Updated README with complete instructions
- Production deployment guide
- Clear troubleshooting section
- API reference for all new tools

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-07 21:12:17 +00:00
czlonkowski
1f8140c45c Implement n8n-MCP integration
This commit adds a complete integration between n8n workflow automation and the Model Context Protocol (MCP):

Features:
- MCP server that exposes n8n workflows as tools, resources, and prompts
- Custom n8n node for connecting to MCP servers from workflows
- Bidirectional bridge for data format conversion
- Token-based authentication and credential management
- Comprehensive error handling and logging
- Full test coverage for core components

Infrastructure:
- TypeScript/Node.js project setup with proper build configuration
- Docker support with multi-stage builds
- Development and production docker-compose configurations
- Installation script for n8n custom node deployment

Documentation:
- Detailed README with usage examples and API reference
- Environment configuration templates
- Troubleshooting guide

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-07 15:43:02 +00:00