문제 배경:

에러 메시지: 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:

  1. Installing nvm for Windows (https://github.com/coreybutler/nvm-windows/releases)
  2. Updating Node.js to the latest version:
  3. nvm install lts nvm use lts
  4. Updating npm to the latest version:
  5. 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/

처음 환경설정하는 부분부터 막혔다. 

나의 환경은 옛날 zsh를 사용해보자는 목적으로 윈도우에 wsl을 이용해 우분투 환경에서 코딩을 연습하고 있다.

여기서 비롯된건지 mysql 설치를 할 때 갖은 문제들이 발생하는데 해결까지 거의 3일이라는 시간이 걸렸다. 

그동안 설치와 제거를 수 없이 반복해서 다른 분들은 이런 고생을 안하길 바란다. 

 

첫번째 마주한 오류.

dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
 mysql-server-8.0
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

  출처 : https://stackoverflow.com/questions/43446218/dpkg-error-processing-package-mysql-server-dependency-problems

기존의 있던 mysql-server-8.0과 의존성 문제가 있어 에러가 나왔다. 

해결 방법을 검색해 보면 모두 삭제한뒤에 재설치하는 과정이 대부분인데

몇가지 부분을 놓치면 무한 삭제, 설치를 반복하게 돤다.

우선 셀은 zsh로하면

sudo apt-get purge 'mysql*'

과 같은 명령어에서 제대로 작동하지 않기 때문에 bash 셀로 바꿔줘야한다. 

bash 셀로 바꾸고 나면

sudo apt-get clean
sudo apt-get purge 'mysql*'
sudo apt-get update
sudo apt-get install -f
sudo apt-get install mysql-server-8.0
sudo apt-get dist-upgrade

출처 : https://stackoverflow.com/questions/69100145/why-is-showes-error-processing-package-mysql-server-8-0-configure?utm_source=pocket_mylist

과정을 실행한다. 

여기서 두번째 부분 

install -f전에 리눅스 시스템을 재부팅해주어야한다.

이 부분이 안되어도 무한 설치 무한 삭제를 반복하게 된다.

 

리눅스 시스템을 재부팅하려고 검색을 했을 때 나온 명령어는 작동을 하지 않았다.

wsl 환경에서 작동을 하는 리눅스 시스템은 아이러니하게도 윈도우에서 재부팅을 해줘야한다고 한다. 

출처 : https://jootc.com/p/202007093546

Restart-Service LxssManager

이후 계속 진행하다보면 정상적으로 설치된다.

 

설치를 하고 보안 설정을 진행하는 과정에서 한번더 막히게 된다. 

Error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

이 오류는 비교적 쉽게 해결하게 되었다. 

출처 :  https://easy7.tistory.com/482

sudo service mysql restart

이제 마지막 오류를 맞이한다. 

비밀번호 보안 레벨 설정을 마치고 내 비밀번호를 설정하는데 갑자기 이런 오류가 떳다.

... Failed! Error: SET PASSWORD has no significance for user 'root'@'localhost' as the authentication method used doesn't store authentication data in the MySQL server. Please consider using ALTER USER instead if you want to change authentication parameters.

출처 : https://exerror.com/failed-error-set-password-has-no-significance-for-user-rootlocalhost-as-the-authentication-method-used-doesnt-store-authentication-data-in-the-mysql-server/

sudo mysql

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by 'mynewpassword';

 

이 부분을 마친뒤 다시

sudo mysql_secure_installation

보안 레벨 설정을 진행하게되면 무사히 설치를 완료하게 된다. 

+ Recent posts