DesktopCommanderMCP icon indicating copy to clipboard operation
DesktopCommanderMCP copied to clipboard

Server transport closed unexpectedly, this is likely due to the process exiting early

Open jasoncodes42 opened this issue 8 months ago • 4 comments

Doesn't seem to connect

Image
jasons-mbp-2:Claude jason$ cat mcp-server-desktop-commander.log
2025-04-18T19:42:21.892Z [desktop-commander] [info] Initializing server...
2025-04-18T19:42:22.134Z [desktop-commander] [info] Server started and connected successfully
2025-04-18T19:42:22.140Z [desktop-commander] [info] Message from client: {"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"claude-ai","version":"0.1.0"}},"jsonrpc":"2.0","id":0}
Debugger listening on ws://127.0.0.1:9229/11454fda-961e-4a53-bc9c-ff30db58ae71
For help, see: https://nodejs.org/en/docs/inspector
2025-04-18T19:43:22.136Z [desktop-commander] [info] Message from client: {"jsonrpc":"2.0","method":"notifications/cancelled","params":{"requestId":0,"reason":"Error: MCP error -32001: Request timed out"}}
2025-04-18T19:43:22.137Z [desktop-commander] [info] Client transport closed
2025-04-18T19:43:22.138Z [desktop-commander] [info] Server transport closed
2025-04-18T19:43:22.139Z [desktop-commander] [info] Client transport closed
2025-04-18T19:43:22.139Z [desktop-commander] [info] Server transport closed unexpectedly, this is likely due to the process exiting early. If you are developing this MCP server you can add output to stderr (i.e. `console.error('...')` in JavaScript, `print('...', file=sys.stderr)` in python) and it will appear in this log.
2025-04-18T19:43:22.139Z [desktop-commander] [error] Server disconnected. For troubleshooting guidance, please visit our [debugging documentation](https://modelcontextprotocol.io/docs/tools/debugging) {"context":"connection"}
2025-04-18T19:43:22.141Z [desktop-commander] [info] Server transport closed
2025-04-18T19:43:22.141Z [desktop-commander] [info] Client transport closed
jasons-mbp-2:Claude jason$ cat mcp.log
2025-04-18T19:42:21.893Z [info] [desktop-commander] Initializing server...
2025-04-18T19:42:22.134Z [info] [desktop-commander] Server started and connected successfully
2025-04-18T19:42:22.140Z [info] [desktop-commander] Message from client: {"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"claude-ai","version":"0.1.0"}},"jsonrpc":"2.0","id":0}
2025-04-18T19:43:22.136Z [info] [desktop-commander] Message from client: {"jsonrpc":"2.0","method":"notifications/cancelled","params":{"requestId":0,"reason":"Error: MCP error -32001: Request timed out"}}
2025-04-18T19:43:22.137Z [info] [desktop-commander] Client transport closed
2025-04-18T19:43:22.138Z [info] [desktop-commander] Server transport closed
2025-04-18T19:43:22.139Z [info] [desktop-commander] Client transport closed
2025-04-18T19:43:22.139Z [info] [desktop-commander] Server transport closed unexpectedly, this is likely due to the process exiting early. If you are developing this MCP server you can add output to stderr (i.e. `console.error('...')` in JavaScript, `print('...', file=sys.stderr)` in python) and it will appear in this log.
2025-04-18T19:43:22.139Z [error] [desktop-commander] Server disconnected. For troubleshooting guidance, please visit our [debugging documentation](https://modelcontextprotocol.io/docs/tools/debugging)
2025-04-18T19:43:22.141Z [info] [desktop-commander] Server transport closed
2025-04-18T19:43:22.142Z [info] [desktop-commander] Client transport closed
jasons-mbp-2:Claude jason$

jasoncodes42 avatar Apr 18 '25 19:04 jasoncodes42

Do you have NVM?

wonderwhy-er avatar Apr 19 '25 07:04 wonderwhy-er

yes. I managed to get the filesystem one working with this config:

{
  "mcpServers": {
    "filesystem": {
      "command": "/Users/jason/.nvm/versions/node/v22.14.0/bin/node",
      "args": [
        "/Users/jason/.nvm/versions/node/v22.14.0/bin/npx",
        "@modelcontextprotocol/server-filesystem",
        "/Users/jason/icode"
      ]
    }
  }
}

So I'm trying desktop commander with the same approach:

{
  "mcpServers": {
    "desktop-commander": {
      "command": "/Users/jason/.nvm/versions/node/v22.14.0/bin/node",
      "args": [
        "/Users/jason/.nvm/versions/node/v22.14.0/bin/npx",
        "@wonderwhy-er/desktop-commander"
      ]
    }
  }
}

but now see:

2025-04-19T23:02:03.367Z [desktop-commander] [info] Initializing server...
2025-04-19T23:02:03.664Z [desktop-commander] [info] Server started and connected successfully
2025-04-19T23:02:03.670Z [desktop-commander] [info] Message from client: {"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"claude-ai","version":"0.1.0"}},"jsonrpc":"2.0","id":0}
x rg
file:///Users/jason/.npm/_npx/75004/lib/node_modules/@wonderwhy-er/desktop-commander/dist/utils.js:6
    const versionModule = await import('./version.js');
                          ^^^^^

SyntaxError: Unexpected reserved word
    at Loader.moduleStrategy (internal/modules/esm/translators.js:140:18)
2025-04-19T23:02:09.432Z [desktop-commander] [info] Server transport closed
2025-04-19T23:02:09.432Z [desktop-commander] [info] Client transport closed
2025-04-19T23:02:09.433Z [desktop-commander] [info] Server transport closed unexpectedly, this is likely due to the process exiting early. If you are developing this MCP server you can add output to stderr (i.e. `console.error('...')` in JavaScript, `print('...', file=sys.stderr)` in python) and it will appear in this log.
2025-04-19T23:02:09.433Z [desktop-commander] [error] Server disconnected. For troubleshooting guidance, please visit our [debugging documentation](https://modelcontextprotocol.io/docs/tools/debugging) {"context":"connection"}
2025-04-19T23:02:09.434Z [desktop-commander] [info] Client transport closed

jasoncodes42 avatar Apr 19 '25 23:04 jasoncodes42

But when I run it in a shell directly:

jasons-mbp-2:~ jason$ /Users/jason/.nvm/versions/node/v22.14.0/bin/node /Users/jason/.nvm/versions/node/v22.14.0/bin/npx @wonderwhy-er/desktop-commander
Loading schemas.ts
Loading server.ts
Setting up request handlers...
[desktop-commander] Initialized FilteredStdioServerTransport
Loading configuration...
(node:75644) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Configuration loaded successfully
Connecting server...
Server connected successfully

jasoncodes42 avatar Apr 19 '25 23:04 jasoncodes42

@jason51553262 this solved it for me following your example:

npm install -g @wonderwhy-er/desktop-commander

My claude_desktop_config.json:

{
  "mcpServers": {
    "desktop-commander": {
      "command": "/Users/kenert/.nvm/versions/node/v22.15.0/bin/node",
      "args": [
        "/Users/kenert/.nvm/versions/node/v22.15.0/bin/npx",
        "@wonderwhy-er/desktop-commander"
      ]
    }
  }
}

Kenert avatar Apr 25 '25 11:04 Kenert