Skip to content

Instantly share code, notes, and snippets.

@MohamedElashri
Last active March 19, 2026 14:37
Show Gist options
  • Select an option

  • Save MohamedElashri/c97806f6e474045ccae38e7f1ef9f3f1 to your computer and use it in GitHub Desktop.

Select an option

Save MohamedElashri/c97806f6e474045ccae38e7f1ef9f3f1 to your computer and use it in GitHub Desktop.
qwen mcp setup

The official script to install qwen code require root, but we can use this workaround to install qwen code without root.

Follow the steps to install Qwen Code without root, and incorporating the nvm-based Node.js upgrade (because we have very old node version)

Install Qwen Code Without Root

Step 1: Install nvm

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash

If curl is unavailable, use wget:

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash

Step 2: Reload your shell

source ~/.bashrc   # or ~/.zshrc

Step 3: Install Node.js 20 (LTS)

Qwen Code requires Node.js ≥ 20. Install and set it as default:

nvm install 20
nvm use 20
nvm alias default 20

Step 4: Create a user-local npm global directory

mkdir -p ~/.npm-global
npm config set prefix ~/.npm-global

Step 5: Add it to your PATH

Add this line to your ~/.bashrc or ~/.zshrc:

export PATH="$HOME/.npm-global/bin:$PATH"

Then reload:

source ~/.bashrc   # or ~/.zshrc

Step 6: Install Qwen Code

npm install -g @qwen-code/qwen-code@latest

Step 7: Verify

node --version   # should be v20.x.x or higher
qwen --version

Prerequisites

First, create the virtual environment using uv and install both MCP servers into it. The default path used here is ~/.local/envs/.venv_mcpadjust this path if you want your env somewhere else.

# Create the virtual environment
uv venv ~/.local/envs/.venv_mcp

# Install both MCP servers into it
uv pip install --python ~/.local/envs/.venv_mcp root-mcp cerngitlab-mcp

After this, both servers are available as executables inside ~/.local/envs/.venv_mcp/bin/.

Qwen Code Configuration

Qwen Code reads MCP servers from mcpServers in settings.json. You have two scopes: qwenlm.github

  • Project scope (only current project): .qwen/settings.json in your project root
  • User scope (all projects): ~/.qwen/settings.json

Create or edit your chosen settings.json and add the following:

{
  "mcpServers": {
    "root-mcp": {
      "command": "/home/YOUR_USERNAME/.local/envs/.venv_mcp/bin/root-mcp",
      "args": ["--data-path", "/path/to/your/root/files"],
      "timeout": 30000
    },
    "cerngitlab": {
      "command": "/home/YOUR_USERNAME/.local/envs/.venv_mcp/bin/cerngitlab-mcp",
      "args": []
    }
  }
}

Adjustments to make:

  • Replace /home/YOUR_USERNAME/ with your actual home directory (run echo $HOME to find it). On Linux this is typically /home/yourname, on macOS /Users/yourname.
  • Replace /path/to/your/root/files with the directory containing your .root files.
  • If you placed the env in a different location than ~/.local/envs/.venv_mcp, update the paths accordingly.
  • If you want the servers available globally across all projects, write to ~/.qwen/settings.json instead.

Optional: CERN GitLab Token

By default cerngitlab-mcp only accesses public repositories. To unlock private repos and additional tools like search_code and search_issues, add your CERN GitLab token:

"cerngitlab": {
  "command": "/home/YOUR_USERNAME/.local/envs/.venv_mcp/bin/cerngitlab-mcp",
  "args": [],
  "env": {
    "CERNGITLAB_TOKEN": "glpat-xxxxxxxxxxxx"
  }
}

Generate a token at https://gitlab.cern.ch/-/user_settings/personal_access_tokens with the read_api scope. You can also reference an existing shell variable instead of hardcoding: "CERNGITLAB_TOKEN": "$CERNGITLAB_TOKEN".


Verify

Restart Qwen Code in your project directory, then run:

qwen mcp list

Both root-mcp and cerngitlab should appear as connected. If a server shows "Disconnected", double-check that the command path is the exact absolute path to the binary inside your venv, you can verify with:

ls ~/.local/envs/.venv_mcp/bin/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment