You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mac端无法正常搭建Claude MCP环境,求排查方案

解决Mac桌面端Claude配置MCP Filesystem Server失败的问题

一、npx配置方案修复

问题现象

配置npx启动MCP Filesystem Server时,日志报错command not found: /Users/xxx/Desktop,但直接在终端执行npx @modelcontextprotocol/server-filesystem '/Users/xxx/Desktop'可正常运行。

原因分析

npx的参数传递规则要求用--分隔npx自身参数(如-y)和目标包的运行参数(如目录路径)。如果不添加--,npx会错误地将目录路径识别为要执行的命令,而非传递给@modelcontextprotocol/server-filesystem包。

修复后的配置

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

二、Node配置方案修复

问题现象

直接在终端执行node /usr/local/lib/node_modules/@modelcontextprotocol/server-filesystem/dist/index.js /Users/xxx/Desktop正常,但Claude配置中启动时出现SyntaxError: Unexpected token {错误。

原因分析

Claude启动MCP服务器时使用的Node环境可能与你的终端环境不一致:

  • 可能是Claude内置的Node版本过低,不支持ES模块的import语法;
  • 或者没有明确指定以ES模块模式运行脚本,导致Node将ES模块文件当作CommonJS解析。

修复方案

方案1:指定Node路径并强制启用ES模块

修改配置,添加--input-type=module参数,并使用终端中正常运行的Node路径(可通过which node命令获取):

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

方案2:验证Claude的Node环境

如果方案1无效,可检查Claude是否使用了内置Node版本。若版本过低,可尝试:

  • 将@modelcontextprotocol/server-filesystem包转译为CommonJS格式;
  • 确保Claude配置中使用系统默认的Node路径。

内容的提问来源于stack exchange,提问作者Ganessa

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 19:41:04