iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🐷

How to Fix MCP Server Startup Issues on Google Antigravity with WSL

に公開

Introduction

While using Google Antigravity, I encountered an issue where the MCP server would not start, resulting in the following error:

I hope this helps anyone facing the same problem.

Environment

  • Windows 11
  • WSL2 (Ubuntu)
  • Node.js (installed via nvm on WSL)
  • Google Antigravity

Cause

Antigravity, which runs on Windows, is attempting to directly reference the path to Node.js installed via nvm on the WSL side, causing it to fail.
The key point is that although %PATH% is a Windows environment variable, the path is formatted in Linux style (starting with /home/...). Since Antigravity is running on the Windows side, it cannot directly execute paths from WSL.

Solution

Configure it to execute npx after loading nvm via WSL.

Key Points

  • Set the command to "wsl" to execute through WSL.
  • Load nvm using "source ~/.nvm/nvm.sh" before executing npx.
  • By connecting them with "&&", npx will only run after nvm has been successfully loaded.

*Please adjust the ~/.nvm/nvm.sh part according to your environment.

{
  "mcpServers": {
    "your-mcp-server": {
      "command": "wsl",
      "args": ["bash", "-c", "source ~/.nvm/nvm.sh && npx -y @your/mcp-package"]
    }
  }
}

Alternative Solution

If you prefer to solve this without using WSL, you can also install Node.js on the Windows side.

  1. Install the Windows version from nodejs.org.
  2. Restart Antigravity.

This approach is simpler, but it means managing Node.js separately on WSL and Windows, so you can choose whichever you prefer.

Discussion