#!/bin/sh

# Shell script for invoking the Wing MCP testing server.
# This allows Claude Code and other MCP clients to use Wing's test runner
# and coverage analysis from an installed copy of Wing.
#
# Copyright (c) 2000-2025, Archaeopteryx Software, Inc.  All rights reserved.

# Unalias commands we rely on being the defaults
alias dirname=xxx
unalias dirname

# Find WINGHOME unless caller has passed it in
if [ "${WINGHOME}" = "" ]; then
    BOOTSTRAP_DIR=`dirname "$0"`
    WINGHOME=`dirname "${BOOTSTRAP_DIR}"`; export WINGHOME
fi

# Location of Python interpreter to use, if not already set
TARGET_PYTHON="python3.12"
WING_PLATFORM="linux-x64"
if [ "${WINGPYTHON}" = "" ]; then
    WINGPYTHON="${WINGHOME}/bin/__os__/${WING_PLATFORM}/runtime-${TARGET_PYTHON}/bin/${TARGET_PYTHON}"
fi

# Run Python without site, ignoring environment
PYTHON_ARGS="-SEs"

# Run the MCP testing server
if [ -f "${WINGHOME}/bootstrap/run-mcp-testing.py" ]; then
  exec "${WINGPYTHON}" ${PYTHON_ARGS} "${WINGHOME}/bootstrap/run-mcp-testing.py" "$@"
fi

echo "run-mcp-testing: Error: run-mcp-testing.py not found.  Please check your Wing installation" >&2
exit 1
