Files
n8n-mcp/docker
czlonkowski 9cd5e42cb7 fix: resolve Docker integration test failures in CI
Root cause analysis and fixes:

1. **MCP_MODE environment variable tests**
   - Issue: Tests were checking env vars after exec process replacement
   - Fix: Test actual HTTP server behavior instead of env vars
   - Changed tests to verify health endpoint responds in HTTP mode

2. **NODE_DB_PATH configuration tests**
   - Issue: Tests expected env var output but got initialization logs
   - Fix: Check process environment via /proc/1/environ
   - Added proper async handling for container startup

3. **Permission handling tests**
   - Issue: BusyBox sleep syntax and timing race conditions
   - Fix: Use detached containers with proper wait times
   - Check permissions after entrypoint completes

4. **Implementation improvements**
   - Export NODE_DB_PATH in entrypoint for visibility
   - Preserve env vars when switching to nodejs user
   - Add debug output option in n8n-mcp wrapper
   - Handle NODE_DB_PATH case preservation in parse-config.js

5. **Test infrastructure**
   - Created test-helpers.ts with proper async utilities
   - Use health checks instead of arbitrary sleep times
   - Test actual functionality rather than implementation details

These changes ensure tests verify the actual behavior (server running,
health endpoint responding) rather than checking internal implementation
details that aren't accessible after process replacement.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-31 14:08:21 +02:00
..

Docker Usage Guide for n8n-mcp

Running in HTTP Mode

The n8n-mcp Docker container can be run in HTTP mode using several methods:

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

  1. AUTH_TOKEN is required for HTTP mode. Generate a secure token:

    openssl rand -base64 32
    
  2. Environment variables take precedence over config file values

  3. Default mode is stdio if MCP_MODE is not specified

  4. 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.js as 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/