#!/bin/bash
# Helper script to run the Open Context MCP Server via Docker
# Use this with Claude Code: /mcp add clew ./start_mcp.sh

# Ensure the image exists (optional, but good practice)
if [[ "$(docker images -q clew-mcp-server:test 2> /dev/null)" == "" ]]; then
  echo "Building MCP Server image..." >&2
  docker build -t clew-mcp-server:test ./packages/clew-mcp >&2
fi

# Run the server
# -i: Interact (keep stdin open for MCP communication)
# --rm: Remove container after exit
# --network: Connect to the API network
# -e: Point to the API service name
docker run -i --rm \
  --network clew-engine_clew-network \
  -e CONTEXT_ENGINE_API_URL=http://api:8000 \
  clew-mcp-server:test
