Fixing « spawn npx ENOENT » Error When Setting Up Azure DevOps MCP Server in VS Code

The Problem

When trying to set up the Azure DevOps Model Context Protocol (MCP) server in VS Code, you might encounter this frustrating error:

Connection state: Error spawn npx ENOENT

This error indicates that VS Code cannot find or execute the npx command, which is needed to run the @azure-devops/mcp package.

Understanding the Root Cause

The ENOENT error (Error NO ENTry) means the system cannot locate the specified file or command. This typically happens because:

  1. Node.js/npm is not installed on your system
  2. npx is not in VS Code’s PATH environment
  3. Different Node.js versions are being used (system vs. nvm)
  4. Permission issues with the npm global packages

Solution Methods

Method 1: Verify Node.js Installation

First, check if Node.js and npm are properly installed:

node --version
npm --version
which npx

If these commands fail, install Node.js:

# Ubuntu/Debian
sudo apt update
sudo apt install nodejs npm

# Or using snap
sudo snap install node --classic

Method 2: Use Full Path to npx

If npx exists but VS Code can’t find it, use the absolute path in your mcp.json:

# Find npx location
which npx

Then update your configuration:

{
  "servers": {
    "ado": {
      "type": "stdio",
      "command": "/usr/bin/npx",
      "args": ["-y", "@azure-devops/mcp", "${input:ado_org}"]
    }
  }
}

Method 3: Handle nvm Installations

If you’re using nvm (Node Version Manager), the path might be different:

# Check nvm path
echo $NVM_DIR
which npx

Use the nvm-specific path:

{
  "servers": {
    "ado": {
      "type": "stdio",
      "command": "/home/username/.nvm/versions/node/v22.16.0/bin/npx",
      "args": ["-y", "@azure-devops/mcp", "${input:ado_org}"]
    }
  }
}

Method 4: Direct Node.js Execution

For maximum reliability, skip npx entirely and call Node.js directly:

# Install the package globally
npm install -g @azure-devops/mcp

# Find the package location
npm list -g @azure-devops/mcp

Then configure direct execution:

{
  "servers": {
    "ado": {
      "type": "stdio",
      "command": "/path/to/node",
      "args": [
        "/path/to/node_modules/@azure-devops/mcp/dist/index.js",
        "${input:ado_org}"
      ]
    }
  }
}

Method 5 (FINAL WORKING SOLUTION): Simplify with Direct Organization Name

If the input prompting isn’t working, hardcode your organization name:

{
  "servers": {
    "ado": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@azure-devops/mcp", "your-org-name"]
    }
  }
}

Complete Working Configuration

Here’s a final working configuration that should handle most scenarios:

{
  "servers": {
    "ado": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@azure-devops/mcp", "your-organization"]
    }
  }
}

Troubleshooting Tips

  1. Restart VS Code after making configuration changes
  2. Check VS Code’s terminal environment – it might differ from your system terminal
  3. Install packages globally using sudo npm install -g @azure-devops/mcp
  4. Verify package installation with npm list -g @azure-devops/mcp
  5. Check permissions on npm global directories

Success Indicators

When everything works correctly, you should see:

Starting server ado
Connection state: Starting

And if the server starts but needs parameters, you’ll see:

Usage: mcp-server-azuredevops <organization_name>

This indicates the server is running but needs your Azure DevOps organization name.

Conclusion

The spawn npx ENOENT error is typically a PATH or installation issue. Start with the simplest solutions (checking Node.js installation) and progressively move to more specific fixes. The direct organization name approach is often the most reliable for production setups, while the input-based configuration offers more flexibility for multiple organizations.

Remember to replace "your-organization" with your actual Azure DevOps organization name (the part that appears in your Azure DevOps URL: https://dev.azure.com/your-organization/).

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Ce site utilise Akismet pour réduire les indésirables. En savoir plus sur la façon dont les données de vos commentaires sont traitées.