fix(mcp): capture CLAUDE_PROJECT_DIR from PWD before cd
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>
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
#!/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/netbox/.venv"
|
||||
LOCAL_VENV="$SCRIPT_DIR/.venv"
|
||||
|
||||
Reference in New Issue
Block a user