From 12aed85f87a95706f2dc86f9ee3412253c3df045 Mon Sep 17 00:00:00 2001 From: Ryan Parmeter Date: Mon, 10 Nov 2025 18:02:41 -0700 Subject: [PATCH] fix: Prioritize Homebrew paths on macOS for binary discovery MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Problem On macOS with Homebrew, the binary discovery was returning /usr/local/bin/gitea-mcp (the first path in the search list) as a fallback, even though the actual binary was at /opt/homebrew/bin/gitea-mcp-server. Since Homebrew is the recommended installation method for macOS and installs the binary as 'gitea-mcp-server', it should be checked first. ## Solution Reorganize the search path order to prioritize Homebrew locations on macOS: 1. On macOS: Check /opt/homebrew/bin first (Homebrew paths) 2. Then: Check /usr/local/bin and /usr/bin (system paths) 3. Then: Check home directory paths 4. Finally: Check PATH environment variable ## Impact - macOS users with Homebrew installation now have auto-discovery work correctly - No need to manually set gitea_mcp_binary_path - Still works on Linux and other systems (Homebrew paths only added on macOS) ## Testing - ✅ Confirmed: /opt/homebrew/bin/gitea-mcp-server exists on M4 Mac - ✅ Confirmed: No /usr/local/bin/gitea-mcp on test Mac - 🔄 Ready for testing with auto-discovery on macOS --- src/mcp_server_gitea.rs | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/mcp_server_gitea.rs b/src/mcp_server_gitea.rs index 97eb128..e343997 100644 --- a/src/mcp_server_gitea.rs +++ b/src/mcp_server_gitea.rs @@ -268,12 +268,22 @@ fn resolve_binary_path(explicit_path: &Option) -> Result { } // Build list of common binary paths to try - let mut search_paths = vec![ - PathBuf::from("/usr/local/bin/gitea-mcp"), - PathBuf::from("/usr/local/bin/gitea-mcp-server"), - PathBuf::from("/usr/bin/gitea-mcp"), - PathBuf::from("/usr/bin/gitea-mcp-server"), - ]; + // Note: On macOS, Homebrew paths are checked first since that's the recommended + // installation method and Homebrew installs as 'gitea-mcp-server' + let mut search_paths = vec![]; + + // macOS M-series (ARM64) Homebrew locations - check first on macOS + #[cfg(target_os = "macos")] + { + search_paths.push(PathBuf::from("/opt/homebrew/bin/gitea-mcp")); + search_paths.push(PathBuf::from("/opt/homebrew/bin/gitea-mcp-server")); + } + + // Standard system paths (work on Linux, macOS, Windows) + search_paths.push(PathBuf::from("/usr/local/bin/gitea-mcp")); + search_paths.push(PathBuf::from("/usr/local/bin/gitea-mcp-server")); + search_paths.push(PathBuf::from("/usr/bin/gitea-mcp")); + search_paths.push(PathBuf::from("/usr/bin/gitea-mcp-server")); // Add home directory paths if let Ok(home) = std::env::var("HOME") { @@ -285,13 +295,6 @@ fn resolve_binary_path(explicit_path: &Option) -> Result { search_paths.push(PathBuf::from(&home).join(".cargo/bin/gitea-mcp-server")); } - // macOS M-series (ARM64) Homebrew locations - #[cfg(target_os = "macos")] - { - search_paths.push(PathBuf::from("/opt/homebrew/bin/gitea-mcp")); - search_paths.push(PathBuf::from("/opt/homebrew/bin/gitea-mcp-server")); - } - // Windows locations #[cfg(target_os = "windows")] {