Skip to main content
Glama

mcp-optimizer

fix_macos_uvx.shโ€ข5.71 kB
#!/bin/bash # Final OR-Tools fix for uvx on macOS - robust and dynamic # No hardcoded versions, smart library detection set -e echo "๐ŸŽฏ Final macOS uvx OR-Tools fix (dynamic detection)" # Function to find homebrew path find_homebrew_path() { if [[ -d "/opt/homebrew" ]]; then echo "/opt/homebrew" elif [[ -d "/usr/local" ]]; then echo "/usr/local" else echo "โŒ Homebrew not found" return 1 fi } # Function to detect hardcoded paths from existing OR-Tools cache detect_hardcoded_paths() { echo "๐Ÿ” Detecting hardcoded paths from OR-Tools cache..." local found_paths=() # Look in uvx cache for OR-Tools .so files local cache_pattern="/Users/$USER/.cache/uv/archive-v0/*/lib/python*/site-packages/ortools" for ortools_dir in $cache_pattern; do if [[ -d "$ortools_dir" ]]; then echo " ๐Ÿ“ฆ Found OR-Tools cache: $(dirname "$ortools_dir")" # Find .so files and extract their dependencies local so_files=($(find "$ortools_dir" -name "*.so" 2>/dev/null | head -5)) for so_file in "${so_files[@]}"; do if [[ -f "$so_file" ]]; then # Extract hardcoded libscip paths using otool local deps=$(otool -L "$so_file" 2>/dev/null | grep -o '/[^[:space:]]*corentinl[^[:space:]]*/libscip[^[:space:]]*.dylib' || true) if [[ -n "$deps" ]]; then while IFS= read -r dep; do [[ -n "$dep" ]] && found_paths+=("$dep") done <<< "$deps" fi fi done fi done # Remove duplicates and return unique paths if [[ ${#found_paths[@]} -gt 0 ]]; then printf '%s\n' "${found_paths[@]}" | sort -u else # Fallback to common patterns if no cache found echo "/Users/corentinl/work/stable/temp_python3.13/lib/libscip.9.2.dylib" echo "/Users/corentinl/work/stable/temp_python3.12/lib/libscip.9.2.dylib" echo "/Users/corentinl/work/stable/temp_python3.11/lib/libscip.9.2.dylib" fi } # Main execution echo "๐Ÿ“ Step 1: Environment detection" HOMEBREW_PATH=$(find_homebrew_path) if [[ $? -ne 0 ]]; then echo "โŒ Homebrew required but not found" exit 1 fi echo "โœ… Homebrew: $HOMEBREW_PATH" echo "" echo "๐Ÿ“ฆ Step 2: Dependencies check" # Check and install dependencies quietly for package in or-tools scip; do if ! brew list "$package" &>/dev/null; then echo "Installing $package..." brew install "$package" >/dev/null 2>&1 || echo "โš ๏ธ $package installation issues" else echo "โœ… $package already installed" fi done echo "" echo "๐Ÿ” Step 3: Library discovery" # Find SCIP libraries SCIP_LIBS=($(find "$HOMEBREW_PATH/lib" -name "*libscip*.dylib" 2>/dev/null | sort)) if [[ ${#SCIP_LIBS[@]} -eq 0 ]]; then echo "โŒ No SCIP libraries found" exit 1 fi echo "Available SCIP libraries:" for lib in "${SCIP_LIBS[@]}"; do echo " ๐Ÿ“š $(basename "$lib")" done # Select best library (prefer versioned) PRIMARY_LIB="${SCIP_LIBS[0]}" for lib in "${SCIP_LIBS[@]}"; do if [[ "$(basename "$lib")" =~ ^libscip\.[0-9]+\.[0-9]+\.dylib$ ]]; then PRIMARY_LIB="$lib" break fi done echo "โœ… Primary library: $(basename "$PRIMARY_LIB")" echo "" echo "๐ŸŽฏ Step 4: Hardcoded path detection" readarray -t HARDCODED_PATHS < <(detect_hardcoded_paths) echo "Detected hardcoded paths:" for path in "${HARDCODED_PATHS[@]}"; do echo " ๐Ÿ”— $path" done echo "" echo "๐Ÿ”ง Step 5: Symbolic link creation" links_created=0 skipped=0 for hardcoded_path in "${HARDCODED_PATHS[@]}"; do # Skip empty lines [[ -z "$hardcoded_path" ]] && continue target_dir=$(dirname "$hardcoded_path") # Check if already exists if [[ -L "$hardcoded_path" ]] || [[ -f "$hardcoded_path" ]]; then echo "โœ… Exists: $(basename "$hardcoded_path")" ((skipped++)) continue fi # Create directory if needed if [[ ! -d "$target_dir" ]]; then echo "๐Ÿ“ Creating: $target_dir" if ! sudo mkdir -p "$target_dir" 2>/dev/null; then echo "โš ๏ธ Cannot create directory: $target_dir" continue fi fi # Create symbolic link echo "๐Ÿ”— Creating: $(basename "$hardcoded_path") -> $(basename "$PRIMARY_LIB")" if sudo ln -sf "$PRIMARY_LIB" "$hardcoded_path" 2>/dev/null; then ((links_created++)) else echo "โš ๏ธ Cannot create symlink: $hardcoded_path" fi done echo "" echo "โœ… Links created: $links_created, skipped: $skipped" echo "" echo "๐Ÿงช Step 6: Quick verification" # Quick test without hanging echo "Testing uvx functionality..." if command -v uvx >/dev/null 2>&1; then echo "โœ… uvx command available" # Test is now manual to avoid hanging echo "๐Ÿ“‹ Manual test recommended: uvx mcp-optimizer --help" else echo "โš ๏ธ uvx command not found" fi echo "" echo "๐ŸŽ‰ Final macOS uvx fix completed!" echo "" echo "๐Ÿ“Š Summary:" echo " ๐Ÿ  Homebrew: $HOMEBREW_PATH" echo " ๐Ÿ“š SCIP libraries: ${#SCIP_LIBS[@]} available" echo " ๐ŸŽฏ Hardcoded paths: ${#HARDCODED_PATHS[@]} processed" echo " ๐Ÿ”— Symlinks created: $links_created" echo " ๐Ÿ“ฆ Primary library: $(basename "$PRIMARY_LIB")" echo "" echo "๐Ÿ’ก Usage examples:" echo " uvx mcp-optimizer --help" echo " uvx mcp-optimizer --transport stdio" echo " uvx --python python3.12 mcp-optimizer --transport stdio" echo "" echo "๐ŸŽฏ This provides dynamic OR-Tools support without hardcoded versions!"

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dmitryanchikov/mcp-optimizer'

If you have feedback or need assistance with the MCP directory API, please join our Discord server