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.

1. Create a user-local npm global directory

mkdir -p ~/.npm-global

2. Tell npm to use it

npm config set prefix ~/.npm-global

3. Add it to our PATH, add this line to your ~/.bashrc or ~/.zshrc

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

4. Reload our shell

source ~/.bashrc # or ~/.zshrc

5. Now install Qwen Code without sudo

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

6. Verify

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