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>
1.9 KiB
1.9 KiB
Docker Usage Guide for n8n-mcp
Running in HTTP Mode
The n8n-mcp Docker container can be run in HTTP mode using several methods:
Method 1: Using Environment Variables (Recommended)
docker run -d -p 3000:3000 \
--name n8n-mcp-server \
-e MCP_MODE=http \
-e AUTH_TOKEN=your-secure-token-here \
ghcr.io/czlonkowski/n8n-mcp:latest
Method 2: Using docker-compose
# Create a .env file
cat > .env << EOF
MCP_MODE=http
AUTH_TOKEN=your-secure-token-here
PORT=3000
EOF
# Run with docker-compose
docker-compose up -d
Method 3: Using a Configuration File
Create a config.json file:
{
"MCP_MODE": "http",
"AUTH_TOKEN": "your-secure-token-here",
"PORT": "3000",
"LOG_LEVEL": "info"
}
Run with the config file:
docker run -d -p 3000:3000 \
--name n8n-mcp-server \
-v $(pwd)/config.json:/app/config.json:ro \
ghcr.io/czlonkowski/n8n-mcp:latest
Method 4: Using the n8n-mcp serve Command
docker run -d -p 3000:3000 \
--name n8n-mcp-server \
-e AUTH_TOKEN=your-secure-token-here \
ghcr.io/czlonkowski/n8n-mcp:latest \
n8n-mcp serve
Important Notes
-
AUTH_TOKEN is required for HTTP mode. Generate a secure token:
openssl rand -base64 32 -
Environment variables take precedence over config file values
-
Default mode is stdio if MCP_MODE is not specified
-
Health check endpoint is available at
http://localhost:3000/health
Troubleshooting
Container exits immediately
- Check logs:
docker logs n8n-mcp-server - Ensure AUTH_TOKEN is set for HTTP mode
"n8n-mcp: not found" error
- This has been fixed in the latest version
- Use the full command:
node /app/dist/mcp/index.jsas a workaround
Config file not working
- Ensure the file is valid JSON
- Mount as read-only:
-v $(pwd)/config.json:/app/config.json:ro - Check that the config parser is present:
docker exec n8n-mcp-server ls -la /app/docker/