Fix MCP server infinite respawn loop on upgrade/install failure#15995
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the MCP launch script (eng/common/mcp/azure-sdk-mcp.ps1) to prevent an infinite respawn loop when upgrade/install steps fail (e.g., GitHub rate limiting, 504s, transient network issues) by falling back to an already-installed azsdk binary when running in -Run (MCP) mode.
Changes:
- If
azsdkisn’t found onPATH, also probe the default install directory (~/binviaGet-CommonInstallDirectory) for an existing binary. - In
-Runmode, ifazsdk upgrade --checkfails but an existing binary is present, log a warning and run the existing binary instead of attempting reinstall. - In
-Runmode, if installation throws, fall back to an existing binary in the install directory (when present) rather than exiting with code 1.
|
The following pipelines have been queued for testing: |
When the upgrade check or installation fails (due to GitHub API rate limiting, 504 timeouts, or network errors), fall back to the existing binary instead of exiting with an error. This prevents the MCP client from respawning the process in a tight loop that can spawn hundreds of pwsh processes. Changes: - Check ~/bin (default install dir) when binary is not on PATH - Use azsdkCmd.Path instead of package name for upgrade check - On upgrade check failure in -Run mode, fall back to existing binary - On Install-Standalone-Tool failure in MCP mode, fall back to existing binary if available at the known install directory Fixes #15973 Fixes #15953 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
dadd766 to
d1df74b
Compare
|
The following pipelines have been queued for testing: |
Problem
When the MCP server launch script (
azure-sdk-mcp.ps1) fails to check for upgrades or download updates — due to GitHub API rate limiting (403), gateway timeouts (504), or network errors — it exits with a non-zero code. The MCP client (VS Code, Copilot CLI) immediately respawns the process, creating an infinite loop that can spawn hundreds ofpwshprocesses and choke the machine.Additionally, when the binary is installed at
~/bin(the default) but that directory isn't on$PATH, the script doesn't find the existing binary and always attempts a fresh install.Fix
Fall back to the existing binary when upgrade or install fails in
-Run(MCP) mode:Check default install directory: When
Get-Commanddoesn't findazsdkon PATH, also check~/bin(the default install directory fromGet-CommonInstallDirectory).Upgrade check failure fallback: When
azsdk upgrade --checkreturns a non-zero exit code (rate limit, network error) but the binary already exists, log a warning and run the existing binary instead of falling through toInstall-Standalone-Tool.Install failure fallback: When
Install-Standalone-Toolthrows in MCP mode, check if an existing binary is available at the known install directory and fall back to it instead ofexit 1.Validation
exit 1)Fixes #15973
Fixes #15953