Files
n8n-mcp/docker/n8n-mcp
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

45 lines
1.4 KiB
Bash

#!/bin/sh
# n8n-mcp wrapper script for Docker
# Transforms "n8n-mcp serve" to proper start command
# Validate arguments to prevent command injection
validate_args() {
for arg in "$@"; do
case "$arg" in
# Allowed arguments - extend this list as needed
--port=*|--host=*|--verbose|--quiet|--help|-h|--version|-v)
# Valid arguments
;;
*)
# Allow empty arguments
if [ -z "$arg" ]; then
continue
fi
# Reject any other arguments for security
echo "Error: Invalid argument: $arg" >&2
echo "Allowed arguments: --port=<port>, --host=<host>, --verbose, --quiet, --help, --version" >&2
exit 1
;;
esac
done
}
if [ "$1" = "serve" ]; then
# Transform serve command to start with HTTP mode
export MCP_MODE="http"
shift # Remove "serve" from arguments
# Validate remaining arguments
validate_args "$@"
# For testing purposes, output the environment variable if requested
if [ "$DEBUG_ENV" = "true" ]; then
echo "MCP_MODE=$MCP_MODE" >&2
fi
exec node /app/dist/mcp/index.js "$@"
else
# For non-serve commands, pass through without validation
# This allows flexibility for other subcommands
exec node /app/dist/mcp/index.js "$@"
fi