#!/bin/bash
# Wrapper script to run MCP server in container (Podman/Docker)
# This script is called by Claude Desktop and handles stdio communication
# Get the directory where this script is located
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Load environment variables from .env file
if [ -f "$SCRIPT_DIR/.env" ]; then
export $(grep -v '^#' "$SCRIPT_DIR/.env" | xargs)
fi
# Detect container runtime (podman or docker)
if command -v podman &> /dev/null; then
CONTAINER_CMD="podman"
elif command -v docker &> /dev/null; then
CONTAINER_CMD="docker"
else
echo "Error: Neither podman nor docker found. Please install one of them." >&2
exit 1
fi
# Run the container with stdio communication
# Using --rm to automatically remove container when it exits
# Using -i for interactive mode (stdin)
# Using --network host to access local Hue Bridge
$CONTAINER_CMD run --rm -i \
--network host \
-e HUE_BRIDGE_IP="${HUE_BRIDGE_IP}" \
-e HUE_API_KEY="${HUE_API_KEY}" \
hue-mcp-server:latest