windows wsl cursor mcp Client Closed 해결 (How to Fix Cursor AI "Client Closed" Error Connecting to MCP Server)
문제 배경:
에러 메시지: MCP Feature "Client Closed" Fix - Bug Reports
windows wsl 환경에서 cusor에 mcp를 적용하려고 하는데 자꾸
client closed가 나와 작동하지 않았다.
문제 해결:
1. 문제 분석
자료를 검색해보니 cursor는 windows 어플리케이션으로 실행되므로 WSL 내에서가 아니라 windows 환경에서 이러한 도구에 엑세스 할 수 있어야 한다는 것이다.
해결
"mcpServers": {
"server-sequential-thinking": {
"command": "npx",
"args": [
"-y",
"@smithery/cli@latest",
"run",
"@smithery-ai/server-sequential-thinking",
"--client",
"cursor",
"--key",
"@@@"
]
},
}
기존 그대로 이렇게 사용하는 대신
"mcpServers": {
"server-sequential-thinking": {
"command": "cmd",
"args": [
"/c",
"npx",
"-y",
"@smithery/cli@latest",
"run",
"@smithery-ai/server-sequential-thinking",
"--client",
"cursor",
"--key",
"@@@"
]
},
}
이렇게 앞에 cmd /c를 붙이게 하면 대부분의 사람들은 해결될 것이다.
하지만 나의 경우에는 여전히 작동 안했다.
2. 문제 분석
열심히 뒤져봐도 위의 방법 이외에는 없었다
계속 시도해 보면서 이유를 찾아봤는데
우선 다른 mcp 도구를 실행해 보았고 거기서 한 가지 의문점을 발견하게 된다
desktop-commander를 두고
터미널에 직접 명령어를 쳐보고 mcp.json에도 등록해봤는데
터미널에서는 실행이 되고 mcp.json을 등록했을 때는 여전히 Client Closed 발생했다
여기서 괴리감을 찾았고 아래와 같이 해결했다
해결
그 괴리감은 npm의 버전 문제였다.
내 window의 npm 버전은 10.x.x였고 wsl 환경에서의 버전은 11.x.x 였다
당연히 main 버전이 다르니 문제가 생길 수 밖에 없는 구조였다
그래서
1. window 환경의 npm을 업데이트 하기 위해 nvm을 설치 (https://github.com/coreybutler/nvm-windows/releases)
2. node를 최신 버전으로 업데이트
nvm install lts
nvm use lts
3. npm을 최신 버전으로 업데이트
npm install -g npm@latest
을 마치고 cursor를 다시 실행해보니 해결
나는 끝으로 기왕이면 서로 둘다 버전을 맞춰주면 좋다고 생각해서
wsl 환경의 npm도 업데이트 해줬다
지금 해외 커뮤니티 같은 곳에 같은 문제로 고생하는 사람들이 꽤 있는 것 같은데 영어로 번역해서 올려놔봐야겠다.
wsl을 사용하면서 의식적으로 window와 wsl 환경의 npm 버전을 맞추는 사람은 별로 없을 것이기 때문이다.
Problem Background:
I was trying to apply MCP to Cursor in a Windows WSL environment, but kept getting "client closed" errors that prevented it from working.
Problem Solving:
1. Problem Analysis
After researching, I discovered that since Cursor runs as a Windows application, these tools need to be accessed from the Windows environment rather than from within WSL.
Solution
Instead of using the configuration like this:
"mcpServers": {
"server-sequential-thinking": {
"command": "npx",
"args": [
"-y",
"@smithery/cli@latest",
"run",
"@smithery-ai/server-sequential-thinking",
"--client",
"cursor",
"--key",
"@@@"
]
}
}
Adding cmd /c
at the beginning like this resolves the issue for most people:
"mcpServers": {
"server-sequential-thinking": {
"command": "cmd",
"args": [
"/c",
"npx",
"-y",
"@smithery/cli@latest",
"run",
"@smithery-ai/server-sequential-thinking",
"--client",
"cursor",
"--key",
"@@@"
]
}
}
However, this still didn't work for me.
2. Further Analysis
I couldn't find any other solutions despite extensive searching.
While testing, I tried running another MCP tool, desktop-commander, both directly in the terminal and by registering it in mcp.json. Interestingly, it worked in the terminal but still produced "Client Closed" errors when registered in mcp.json.
This discrepancy led me to discover the root cause.
Solution
The issue was an npm version mismatch. My Windows npm version was 10.x.x, while my WSL environment was running npm 11.x.x.
With such different major versions, problems were inevitable. I resolved this by:
- Installing nvm for Windows (https://github.com/coreybutler/nvm-windows/releases)
- Updating Node.js to the latest version:
nvm install lts nvm use lts
- Updating npm to the latest version:
npm install -g npm@latest
After completing these steps and restarting Cursor, the problem was solved!
I also updated the npm version in my WSL environment to match, since I believe it's better to keep versions consistent between both environments.
There seem to be many people struggling with this same issue in international communities. I should translate this solution and share it, as most people using WSL probably wouldn't think to check that their Windows and WSL npm versions match.
참고자료:
https://apidog.com/blog/how-to-fix-cursor-ai-mcp-feature-client-closed-error/