[server-gitlab] Environment Variables Not Properly Expanded in Claude Desktop App
Describe the bug
The Claude desktop app (v0.8.1) fails to properly expand environment variables when executing npm commands through the Model Context Protocol configuration. Specifically, ${APPDATA} is being treated as a literal string in file paths rather than being replaced with the actual environment variable value. This causes npm to fail with ENOENT errors when attempting to execute the GitLab server component.
To Reproduce Steps to reproduce the behavior:
- Install Claude desktop app v0.8.1 on Windows
- Configure the Model Context Protocol with GitLab integration (see config below)
- Launch the application and attempt to use GitLab integration features
- Observe npm errors in logs related to missing paths containing
${APPDATA}
Expected behavior
The application should properly expand environment variables like ${APPDATA} to their actual values before passing them to npm/npx commands. This would allow npm to find the correct directories and successfully execute the required packages.
Logs
npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path C:\Users\[USERNAME]\AppData\Local\AnthropicClaude\app-0.8.1\${APPDATA}
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, lstat 'C:\Users\[USERNAME]\AppData\Local\AnthropicClaude\app-0.8.1\${APPDATA}'
npm ERR! enoent This is related to npm not being able to find a file.
Detailed npm log:
13 timing config:load:file:C:\Users\[USERNAME]\AppData\Local\AnthropicClaude\app-0.8.1\${APPDATA}\npm\etc\npmrc Completed in 0ms
...
21 verbose title npm exec @modelcontextprotocol/server-gitlab
22 verbose argv "exec" "--yes" "--" "@modelcontextprotocol/server-gitlab"
...
37 verbose stack Error: ENOENT: no such file or directory, lstat 'C:\Users\[USERNAME]\AppData\Local\AnthropicClaude\app-0.8.1\${APPDATA}'
...
44 error path C:\Users\[USERNAME]\AppData\Local\AnthropicClaude\app-0.8.1\${APPDATA}
45 error errno -4058
46 error enoent ENOENT: no such file or directory, lstat 'C:\Users\[USERNAME]\AppData\Local\AnthropicClaude\app-0.8.1\${APPDATA}'
MCP Configuration
{
"mcpServers": {
"gitlab": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-gitlab"
],
"env": {
"GITLAB_PERSONAL_ACCESS_TOKEN": "[REDACTED]",
"GITLAB_API_URL": "https://gitlab.onpremise.example.com/api/v4"
}
}
}
}
Additional context
- Windows 10 version: 10.0.26100
- Node.js version: v20.11.1
- npm version: v10.2.4
- Claude desktop app version: 0.8.1
- The issue appears to be in how environment variables are handled when executing the npx command specified in the MCP configuration
- While the MCP configuration correctly defines environment variables for GitLab, the Claude app itself is not properly handling system environment variables (like APPDATA) when launching npm/npx
This bug prevents proper functioning of features that depend on the GitLab server integration through the Model Context Protocol.
i got this same error , how to resolve it
Same issue. I tested both in VS Code and Claude.
- Node.js version: v20.18.0
- npm version: v10.8.2
- Claude desktop app version: 0.8.1
- Sample log file content in
npm-cache\_logs\
0 verbose cli C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js
1 info using [email protected]
2 info using [email protected]
3 silly config load:file:C:\Program Files\nodejs\node_modules\npm\npmrc
4 silly config load:file:C:\Users\[UserName]\.npmrc
5 silly config load:file:C:\Users\[UserName]\AppData\Local\AnthropicClaude\app-0.8.1\${APPDATA}\npm\etc\npmrc
6 verbose title npm exec @modelcontextprotocol/server-gitlab
7 verbose argv "exec" "--yes" "--" "@modelcontextprotocol/server-gitlab"
8 verbose logfile logs-max:10 dir:C:\Users\[UserName]\npm-cache\_logs\2025-03-26T15_23_34_792Z-
9 verbose logfile C:\Users\[UserName]\npm-cache\_logs\2025-03-26T15_23_34_792Z-debug-0.log
10 silly logfile done cleaning log files
11 silly packumentCache heap:4345298944 maxSize:1086324736 maxEntrySize:543162368
12 http fetch GET 200 https://registry.npmmirror.com/@modelcontextprotocol%2fserver-gitlab 173ms (cache revalidated)
13 silly packumentCache heap:4345298944 maxSize:1086324736 maxEntrySize:543162368
14 verbose stack Error: ENOENT: no such file or directory, lstat 'C:\Users\[UserName]\AppData\Local\AnthropicClaude\app-0.8.1\${APPDATA}'
14 verbose stack at async lstat (node:internal/fs/promises:1021:18)
14 verbose stack at async #loadActual (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\load-actual.js:112:20)
14 verbose stack at async exec (C:\Program Files\nodejs\node_modules\npm\node_modules\libnpmexec\lib\index.js:207:26)
14 verbose stack at async Npm.exec (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:207:9)
14 verbose stack at async module.exports (C:\Program Files\nodejs\node_modules\npm\lib\cli\entry.js:74:5)
15 error code ENOENT
16 error syscall lstat
17 error path C:\Users\[UserName]\AppData\Local\AnthropicClaude\app-0.8.1\${APPDATA}
18 error errno -4058
19 error enoent ENOENT: no such file or directory, lstat 'C:\Users\[UserName]\AppData\Local\AnthropicClaude\app-0.8.1\${APPDATA}'
20 error enoent This is related to npm not being able to find a file.
20 error enoent
21 verbose cwd C:\Users\[UserName]\AppData\Local\AnthropicClaude\app-0.8.1
22 verbose os Windows_NT 10.0.22631
23 verbose node v20.18.0
24 verbose npm v10.8.2
25 verbose exit -4058
26 verbose code -4058
27 error A complete log of this run can be found in: C:\Users\[UserName]\npm-cache\_logs\2025-03-26T15_23_34_792Z-debug-0.log
I am seeing the same issue on my end when trying to setup tavily's MCP in Claude Desktop.
I faced the same issue multiple times and something that worked for me was specifying the APPDATA as a part of the env in the claude_desktop_config.json. Something like this:
{
"mcpServers": {
"mcp-puppeteer": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-puppeteer"],
"env": {
"PUPPETEER_LAUNCH_OPTIONS": "{ \"headless\": false, \"executablePath\": \"C:/Program Files/Google/Chrome/Application/chrome.exe\", \"args\": [] }",
"ALLOW_DANGEROUS": "true",
"APPDATA": "C:\\Users\\Yash Thakkar\\AppData\\Roaming\\npm"
}
}
}
}
I will try this. Thanks!
On Windows, just setting a user environment variable APPDATA to C:\Users\[username]\AppData helps
is this going to remain as a feature by design? i think Claude should have access system environment variables or at least allow them one by one.
setting the"APPDATA" to which npm output did the trick for me on mac as well
Thanks for reporting this. This server has been moved to the archived repository at https://github.com/modelcontextprotocol/servers-archived to reduce maintenance overhead, so we can focus our efforts on a smaller set of core servers. Since this server is no longer actively maintained, we recommend checking out the alternatives listed in the Readme.