Cursor MCP环境安装和报错解决记录
2026-01-31 22:32:28

环境准备:

1、安装node.js 和 nvm

image-20250524163312243

2、node 版本比较旧了,执行npx -y @modelcontextprotocol/server-memory 就会报错

image-20250524163408025

3、升级node 版本,直接使用最新的。

1
2
3
4
5
6
7
8
9
#安装最新的node 版本
nvm install --lts
#列出已安装的node版本列表
nvm list
#切换node版本
nvm use v22.16.0
#使用use切换node版本只在当前终端生效
#使用下面命名,设置默认node 版本
nvm alias default v22.16.0

添加MCP

1、打开Cursor Settings,Add a new global MCP server

image-20250524164132128

2、在mcp.json中添加个官方的MCP工具:

1
2
3
4
5
6
7
8
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/run/cursorProject/mcp_test"]
}
}
}

3、可能会添加失败,报错:spawn npx ENOENT

1
2
3
4
5
6
7
2025-05-24 14:53:25.103 [error] mory: Client error for command 发生了系统错误 (spawn npx ENOENT)
2025-05-24 14:53:25.104 [error] mory: Error in MCP: 发生了系统错误 (spawn npx ENOENT)
2025-05-24 14:53:25.104 [error] mory: Failed to reload client: 发生了系统错误 (spawn npx ENOENT)
2025-05-24 14:53:25.105 [info] mory: Client closed for command
2025-05-24 14:53:25.105 [error] mory: Error in MCP: Client closed
2025-05-24 14:53:25.108 [info] mory: Handling ListOfferings action
2025-05-24 14:53:25.109 [error] mory: No server info found

4、怎么看报错?

image-20250524165251530

5、解决报错:spawn npx ENOENT

① 打开settings.json

image-20250524171029405

② 添加:”terminal.integrated.shellArgs.osx”: [“-l”]

image-20250524171134480

③ 重启 Cursor,刷新 MCP 服务,报错解决。

报错排查记录

1、spawn npx ENOENT 是什么意思?

ENOENT 是 “Error NO ENTry” 的缩写,表示找不到文件或目录。

spawn npx ENOENT 说明系统在尝试启动 npx 命令时,找不到 npx 可执行文件。

2、为什么终端能正常执行npx 命令,Cursor IDE 却无法执行?

Cursor IDE 没自动加载 shell 的配置文件(如 .zshrc、.bash_profile),从而导致找不到环境变量。

3、”terminal.integrated.shellArgs.osx”: [“-l”] 是什么配置?

让 Cursor IDE 的 终端以 login shell 模式启动,默认的是non-login shell 模式,其不会自动加载 shell 的配置文件(如 .zshrc、.bash_profile)

上一页
2026-01-31 22:32:28
下一页