如何在 Claude Desktop 中安装 MCP 服务器(分步教程)
在 Claude Desktop 中添加 MCP 服务器:macOS 和 Windows 上 claude_desktop_config.json 的位置、配置示例和故障排查。
开始之前
你需要安装 Claude Desktop 应用。大多数服务器还需要 Node.js(用于 npx 命令)或带 uv 的 Python(用于 uvx 命令),具体请看服务器的 README。
1. 打开配置文件
点击系统菜单栏中的 Claude 菜单(不是聊天窗口里的设置),选择 Settings…,然后打开 Developer → Edit Config,会打开 claude_desktop_config.json。macOS 上的路径是 ~/Library/Application Support/Claude/claude_desktop_config.json,Windows 上是 %APPDATA%\Claude\claude_desktop_config.json。
2. 添加服务器
在 mcpServers 下添加一项。下面的示例添加了官方 Filesystem 服务器,并只允许访问一个文件夹:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/you/Documents"]
}
}
}3. 重启并检查
完全退出 Claude Desktop 后重新打开。在聊天输入框中点击 Add files, connectors, and more,打开 Connectors → Manage connectors 并选择你的服务器,即可查看它的工具。如果无法连接,请查看日志(mcp.log 和 mcp-server-名称.log):macOS 在 ~/Library/Logs/Claude,Windows 在 %APPDATA%\Claude\logs。
小贴士
- 使用绝对路径。
- 把 API 密钥放在服务器配置项内的
env对象中。 - Socketlist 上的许多服务器页面都提供了从 README 复制的现成配置。