Search code examples
node.jsmacosclaudeanthropic

Cannot build Claude MCP environment on Mac as expected


I am able to use the mcp-server-sqlite setup with uvx from the Mac desktop Claude app which works as expected. However, neither of the following is working.

Setting up with npx

claude_desktop_config.json

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "/Users/xxx/Desktop"
      ]
    }
  }
}
==> /Users/xxx/Library/Logs/Claude/mcp-server-filesystem.log <==
command not found: /Users/xxx/Desktop

But the following commands are working.

npx @modelcontextprotocol/server-filesystem '/Users/xxx/Desktop'           
Secure MCP Filesystem Server running on stdio
Allowed directories: [ '/users/xxx/desktop' ]

Setting up with node

claude_desktop_config.json

{
  "mcpServers": {
    "filesystem": {
      "command": "node",
      "args": [
        "/usr/local/lib/node_modules/@modelcontextprotocol/server-filesystem/dist/index.js",
        "/Users/xxx/Desktop"
      ]
    }
  }
}
==> /Users/xxx/Library/Logs/Claude/mcp-server-filesystem.log <==
/usr/local/lib/node_modules/@modelcontextprotocol/server-filesystem/dist/index.js:2
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
       ^

SyntaxError: Unexpected token {
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

But the following commands are working.

node /usr/local/lib/node_modules/@modelcontextprotocol/server-filesystem/dist/index.js /Users/xxx/Desktop
Secure MCP Filesystem Server running on stdio
Allowed directories: [ '/users/xxx/desktop' ]

Perhaps I am missing some setting. What should I do? Any tips would be appreciated to help me.


Solution

  • I tried the following setup however it did not work.

    % which npx
    /usr/local/bin/npx
    
    {
      "mcpServers": {
        "filesystem": {
          "command": "/usr/local/bin/npx",
          "args": [
            "-y",
            "@modelcontextprotocol/server-filesystem",
            "/Users/xxx/Desktop"
          ]
        }
      }
    }
    

    However, I tried the following setup and this worked. Perhaps this was a path issue.

    % which node
    /usr/local/bin/node
    
    {
      "mcpServers": {
        "filesystem": {
          "command": "/usr/local/bin/node",
          "args": [
            "/usr/local/lib/node_modules/@modelcontextprotocol/server-filesystem/dist/index.js",
            "/Users/xxx/Desktop"
          ]
        }
      }
    }