> ## Documentation Index
> Fetch the complete documentation index at: https://docs.waytomcp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 面向 Claude Desktop 用户

> 开始在 Claude for Desktop 中使用预构建的服务器。

在本教程中，您将扩展 [Claude for Desktop](https://claude.ai/download) 的功能，使其能够读取计算机的文件系统、写入新文件、移动文件，甚至搜索文件。

<Frame>
  <img src="https://mintcdn.com/datalite/Wxs4Dp_Rbe4p9MYx/images/quickstart-filesystem.png?fit=max&auto=format&n=Wxs4Dp_Rbe4p9MYx&q=85&s=28642339e6a8783e211c33fb79bb61dd" width="1732" height="2060" data-path="images/quickstart-filesystem.png" />
</Frame>

不用担心 —— 在执行这些操作之前，它会征求您的许可！

## 1. 下载 Claude for Desktop

首先下载 [Claude for Desktop](https://claude.ai/download)，选择 macOS 或 Windows。（Linux 目前不支持 Claude for Desktop。）

按照安装说明进行操作。

如果您已经安装了 Claude for Desktop，请确保它是最新版本，方法是点击计算机上的 Claude 菜单并选择“检查更新...”。

<Accordion title="为什么选择 Claude for Desktop 而不是 Claude.ai？">
  由于服务器是本地运行的，MCP 目前仅支持桌面主机。远程主机正在积极开发中。
</Accordion>

## 2. 添加文件系统 MCP 服务器

为了添加此文件系统功能，我们将安装一个预构建的 [文件系统 MCP 服务器](https://github.com/modelcontextprotocol/servers/tree/main/src/filesystem) 到 Claude for Desktop。这是 Anthropic 和社区创建的众多[服务器](https://github.com/modelcontextprotocol/servers/tree/main)之一。

首先，打开计算机上的 Claude 菜单并选择“设置...”。请注意，这些不是应用程序窗口中的 Claude 账户设置。

在 Mac 上应该是这样的：

<Frame style={{ textAlign: 'center' }}>
  <img src="https://mintcdn.com/datalite/Wxs4Dp_Rbe4p9MYx/images/quickstart-menu.png?fit=max&auto=format&n=Wxs4Dp_Rbe4p9MYx&q=85&s=1c30a425672f22b7b01edf63b3098975" width="400" data-path="images/quickstart-menu.png" />
</Frame>

点击设置窗格左侧栏中的“开发者”，然后点击“编辑配置”：

<Frame>
  <img src="https://mintcdn.com/datalite/Wxs4Dp_Rbe4p9MYx/images/quickstart-developer.png?fit=max&auto=format&n=Wxs4Dp_Rbe4p9MYx&q=85&s=f9b28ebaba6b53dce71fc9e584c520da" width="1688" height="534" data-path="images/quickstart-developer.png" />
</Frame>

这将在以下位置创建一个配置文件：

* macOS：`~/Library/Application Support/Claude/claude_desktop_config.json`
* Windows：`%APPDATA%\Claude\claude_desktop_config.json`

如果文件不存在，它将创建该文件并在文件系统中显示它。

在任何文本编辑器中打开配置文件。将文件内容替换为以下内容：

<Tabs>
  <Tab title="MacOS/Linux">
    ```json theme={null}
    {
      "mcpServers": {
        "filesystem": {
          "command": "npx",
          "args": [
            "-y",
            "@modelcontextprotocol/server-filesystem",
            "/Users/username/Desktop",
            "/Users/username/Downloads"
          ]
        }
      }
    }
    ```
  </Tab>

  <Tab title="Windows">
    ```json theme={null}
    {
      "mcpServers": {
        "filesystem": {
          "command": "npx",
          "args": [
            "-y",
            "@modelcontextprotocol/server-filesystem",
            "C:\\Users\\username\\Desktop",
            "C:\\Users\\username\\Downloads"
          ]
        }
      }
    }
    ```
  </Tab>
</Tabs>

确保将 `username` 替换为您的计算机用户名。路径应指向您希望 Claude 能够访问和修改的有效目录。它设置为适用于桌面和下载文件夹，但您也可以添加更多路径。

您还需要在计算机上安装 [Node.js](https://nodejs.org) 才能正常运行。要验证您是否安装了 Node，请在计算机上打开命令行。

* 在 macOS 上，从应用程序文件夹中打开终端
* 在 Windows 上，按 Windows + R，输入“cmd”，然后按 Enter

进入命令行后，通过输入以下命令验证您是否安装了 Node：

```bash theme={null}
node --version
```

如果出现“command not found”或“node is not recognized”错误，请从 [nodejs.org](https://nodejs.org/) 下载 Node。

<Tip>
  **配置文件如何工作？**

  此配置文件告诉 Claude for Desktop 每次启动应用程序时要启动哪些 MCP 服务器。在本例中，我们添加了一个名为“filesystem”的服务器，它将使用 Node 的 `npx` 命令安装并运行 `@modelcontextprotocol/server-filesystem`。此服务器在[此处](https://github.com/modelcontextprotocol/servers/tree/main/src/filesystem)描述，它将允许您在 Claude for Desktop 中访问您的文件系统。
</Tip>

<Warning>
  **命令权限**

  Claude for Desktop 将以您用户账户的权限运行配置文件中的命令，并访问您的本地文件。仅在您理解并信任来源的情况下添加命令。
</Warning>

## 3. 重新启动 Claude

更新配置文件后，您需要重新启动 Claude for Desktop。

重新启动后，您应该会在输入框的右下角看到一个锤子 <img src="https://mintcdn.com/datalite/Wxs4Dp_Rbe4p9MYx/images/claude-desktop-mcp-hammer-icon.svg?fit=max&auto=format&n=Wxs4Dp_Rbe4p9MYx&q=85&s=90c3e0caaa59f640ba2a3e35ec0681ba" style={{display: 'inline', margin: 0, height: '1.3em'}} width="32" height="32" data-path="images/claude-desktop-mcp-hammer-icon.svg" /> 图标：

<Frame>
  <img src="https://mintcdn.com/datalite/Wxs4Dp_Rbe4p9MYx/images/quickstart-hammer.png?fit=max&auto=format&n=Wxs4Dp_Rbe4p9MYx&q=85&s=3a7af33deb603586f98caf1874277665" width="1476" height="570" data-path="images/quickstart-hammer.png" />
</Frame>

点击锤子图标后，您应该会看到文件系统 MCP 服务器附带的工具：

<Frame style={{ textAlign: 'center' }}>
  <img src="https://mintcdn.com/datalite/Wxs4Dp_Rbe4p9MYx/images/quickstart-tools.png?fit=max&auto=format&n=Wxs4Dp_Rbe4p9MYx&q=85&s=e2e8789dd40d34a8d83e2083641cc75c" width="400" data-path="images/quickstart-tools.png" />
</Frame>

如果您的服务器未被 Claude for Desktop 识别，请继续阅读[故障排除](#troubleshooting)部分以获取调试提示。

## 4. 试试看！

您现在可以与 Claude 对话并询问它有关文件系统的问题。它应该知道何时调用相关工具。

您可以尝试询问 Claude 的一些问题：

* 你能写一首诗并保存到我的桌面吗？
* 我的下载文件夹中有哪些与工作相关的文件？
* 你能将桌面上的所有图片移动到一个名为“Images”的新文件夹中吗？

根据需要，Claude 将调用相关工具并在执行操作之前征求您的许可：

<Frame style={{ textAlign: 'center' }}>
  <img src="https://mintcdn.com/datalite/Wxs4Dp_Rbe4p9MYx/images/quickstart-approve.png?fit=max&auto=format&n=Wxs4Dp_Rbe4p9MYx&q=85&s=4fa9b7993980401b7471fa7961bef499" width="500" data-path="images/quickstart-approve.png" />
</Frame>

## 故障排除

<AccordionGroup>
  <Accordion title="服务器未显示在 Claude 中 / 锤子图标缺失">
    1. 完全重新启动 Claude for Desktop
    2. 检查您的 `claude_desktop_config.json` 文件语法
    3. 确保 `claude_desktop_config.json` 中包含的文件路径有效，并且它们是绝对路径而不是相对路径
    4. 查看[日志](#getting-logs-from-claude-for-desktop)以了解服务器未连接的原因
    5. 在命令行中，尝试手动运行服务器（替换 `username` 为 `claude_desktop_config.json` 中的内容），查看是否出现错误：

    <Tabs>
      <Tab title="MacOS/Linux">
        ```bash theme={null}
        npx -y @modelcontextprotocol/server-filesystem /Users/username/Desktop /Users/username/Downloads
        ```
      </Tab>

      <Tab title="Windows">
        ```bash theme={null}
        npx -y @modelcontextprotocol/server-filesystem C:\Users\username\Desktop C:\Users\username\Downloads
        ```
      </Tab>
    </Tabs>
  </Accordion>

  <Accordion title="从 Claude for Desktop 获取日志">
    Claude.app 与 MCP 相关的日志写入以下位置的日志文件：

    * macOS：`~/Library/Logs/Claude`

    * Windows：`%APPDATA%\Claude\logs`

    * `mcp.log` 将包含有关 MCP 连接和连接失败的一般日志。

    * 名为 `mcp-server-SERVERNAME.log` 的文件将包含来自指定服务器的错误（stderr）日志。

    您可以运行以下命令以列出最近的日志并跟踪任何新日志（在 Windows 上，它只会显示最近的日志）：

    <Tabs>
      <Tab title="MacOS/Linux">
        ```bash theme={null}
        # 检查 Claude 的日志以查找错误
        tail -n 20 -f ~/Library/Logs/Claude/mcp*.log
        ```
      </Tab>

      <Tab title="Windows">
        ```bash theme={null}
        type "%APPDATA%\Claude\logs\mcp*.log"
        ```
      </Tab>
    </Tabs>
  </Accordion>

  <Accordion title="工具调用静默失败">
    如果 Claude 尝试使用工具但失败：

    1. 检查 Claude 的日志以查找错误
    2. 验证您的服务器是否构建并运行无误
    3. 尝试重新启动 Claude for Desktop
  </Accordion>

  <Accordion title="这些方法都不起作用。我该怎么办？">
    请参阅我们的[调试指南](/docs/tools/debugging)以获取更好的调试工具和更详细的指导。
  </Accordion>

  <Accordion title="Windows 上的 ENOENT 错误和 `${APPDATA}` 路径">
    如果配置的服务器无法加载，并且您在其日志中看到路径中引用了 `${APPDATA}` 的错误，您可能需要在 `claude_desktop_config.json` 中的 `env` 键中添加 `%APPDATA%` 的扩展值：

    ```json theme={null}
    {
      "brave-search": {
        "command": "npx",
        "args": ["-y", "@modelcontextprotocol/server-brave-search"],
        "env": {
          "APPDATA": "C:\\Users\\user\\AppData\\Roaming\\",
          "BRAVE_API_KEY": "..."
        }
      }
    }
    ```

    进行此更改后，再次启动 Claude Desktop。

    <Warning>
      **NPM 应全局安装**

      如果 NPM 未全局安装，`npx` 命令可能会继续失败。如果 NPM 已全局安装，您将在系统上找到 `%APPDATA%\npm`。如果没有，您可以通过运行以下命令全局安装 NPM：

      ```bash theme={null}
      npm install -g npm
      ```
    </Warning>
  </Accordion>
</AccordionGroup>

## 后续步骤

<CardGroup cols={2}>
  <Card title="探索其他服务器" icon="grid" href="/examples">
    查看我们的官方 MCP 服务器和实现库
  </Card>

  <Card title="构建您自己的服务器" icon="code" href="/quickstart/server">
    现在构建您自己的自定义服务器以在 Claude for Desktop 和其他客户端中使用
  </Card>
</CardGroup>
