All MCP server run.sh scripts now capture the original working directory as CLAUDE_PROJECT_DIR before changing to the script directory. This fixes the branch detection issue where MCP tools detected the plugin repo's branch instead of the user's project branch. This is a follow-up fix to #231 - the original fix relied on CLAUDE_PROJECT_DIR being set by Claude Code, but it isn't. Now we capture it ourselves from PWD at startup time. Closes #231 (proper fix) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
22 lines
716 B
Bash
Executable File
22 lines
716 B
Bash
Executable File
#!/bin/bash
|
|
# Capture original working directory before any cd operations
|
|
# This should be the user's project directory when launched by Claude Code
|
|
export CLAUDE_PROJECT_DIR="${CLAUDE_PROJECT_DIR:-$PWD}"
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
CACHE_VENV="$HOME/.cache/claude-mcp-venvs/leo-claude-mktplace/viz-platform/.venv"
|
|
LOCAL_VENV="$SCRIPT_DIR/.venv"
|
|
|
|
if [[ -f "$CACHE_VENV/bin/python" ]]; then
|
|
PYTHON="$CACHE_VENV/bin/python"
|
|
elif [[ -f "$LOCAL_VENV/bin/python" ]]; then
|
|
PYTHON="$LOCAL_VENV/bin/python"
|
|
else
|
|
echo "ERROR: No venv found. Run: ./scripts/setup-venvs.sh" >&2
|
|
exit 1
|
|
fi
|
|
|
|
cd "$SCRIPT_DIR"
|
|
export PYTHONPATH="$SCRIPT_DIR"
|
|
exec "$PYTHON" -m mcp_server.server "$@"
|