Desktop Commander MCP

Desktop Commander MCP

这是一个为 Claude 提供的 MCP 服务器,赋予它终端控制、文件系统搜索和 diff 文件编辑能力。

wonderwhy-er

研究与数据
访问服务器

README

Desktop Commander MCP

使用 AI 搜索、更新、管理文件并运行终端命令

npm 下载量 smithery badge Buy Me A Coffee

Discord

Product Hunt

简而言之,四个关键点:终端命令、基于差异的文件编辑、基于 ripgrep 的文件夹文本搜索、以及从 URL 读取文件的能力。

Desktop Commander MCP <a href="https://glama.ai/mcp/servers/zempur9oh4"> <img width="380" height="200" src="https://glama.ai/mcp/servers/zempur9oh4/badge" alt="Claude Desktop Commander MCP server" /> </a>

目录

这是一个服务器,允许 Claude 桌面应用程序在您的计算机上执行长时间运行的终端命令,并通过模型上下文协议 (MCP) 管理进程。它构建于 MCP 文件系统服务器 之上,以提供额外的搜索和替换文件编辑功能。

特性

  • 执行终端命令并流式传输输出
  • 支持命令超时和后台执行
  • 进程管理(列出和终止进程)
  • 长时间运行命令的会话管理
  • 完整的文件系统操作:
    • 读取/写入文件
    • 创建/列出目录
    • 移动文件/目录
    • 搜索文件
    • 获取文件元数据
    • 代码编辑功能:
    • 对小更改进行精确的文本替换
    • 对重大更改进行完整的文件重写
    • 支持多个文件
    • 基于模式的替换
    • 基于 vscode-ripgrep 的文件夹递归代码或文本搜索

安装

首先,请确保您已下载并安装 Claude 桌面应用程序 并且已 安装 npm

选项 1:通过 npx 安装

只需在终端中运行此命令:

npx @wonderwhy-er/desktop-commander@latest setup

对于调试模式(允许 Node.js 检查器连接):

npx @wonderwhy-er/desktop-commander@latest setup --debug

如果 Claude 正在运行,请重启它。

选项 2:使用 bash 脚本安装程序 (macOS)

对于 macOS 用户,您可以使用我们的自动化 bash 安装程序,它将检查您的 Node.js 版本,如果需要则安装它,并自动配置 Desktop Commander:

curl -fsSL https://raw.githubusercontent.com/wonderwhy-er/DesktopCommanderMCP/refs/heads/main/install.sh | bash

此脚本会自动处理所有依赖项和配置,以实现无缝设置体验。

选项 3:通过 Smithery 安装

要通过 Smithery 自动为 Claude Desktop 安装 Desktop Commander:

npx -y @smithery/cli install @wonderwhy-er/desktop-commander --client claude

选项 4:手动添加到 claude_desktop_config

将此条目添加到您的 claude_desktop_config.json:

  • 在 Mac 上:~/Library/Application\ Support/Claude/claude_desktop_config.json
  • 在 Windows 上:%APPDATA%\Claude\claude_desktop_config.json
  • 在 Linux 上:~/.config/Claude/claude_desktop_config.json
{
  "mcpServers": {
    "desktop-commander": {
      "command": "npx",
      "args": [
        "-y",
        "@wonderwhy-er/desktop-commander"
      ]
    }
  }
}

如果 Claude 正在运行,请重启它。

选项 5:本地检出

  1. 克隆并构建:
git clone https://github.com/wonderwhy-er/ClaudeComputerCommander.git
cd ClaudeComputerCommander
npm run setup

如果 Claude 正在运行,请重启它。

setup 命令将:

  • 安装依赖项
  • 构建服务器
  • 配置 Claude 的桌面应用程序
  • 如果需要,将 MCP 服务器添加到 Claude 的配置

更新 Desktop Commander

通过 npx(选项 1)或 Smithery(选项 2)安装时,Desktop Commander 将在您每次重启 Claude 时自动更新到最新版本。无需手动更新过程。

对于手动安装,您可以再次运行 setup 命令进行更新。

使用

该服务器提供以下工具类别:

终端工具

  • execute_command:运行具有可配置超时的命令
  • read_output:从长时间运行的命令获取输出
  • force_terminate:停止正在运行的命令会话
  • list_sessions:查看活动命令会话
  • list_processes:查看系统进程
  • kill_process:按 PID 终止进程
  • block_command/unblock_command:管理命令黑名单

文件系统工具

  • read_file/write_file:从本地文件系统或 URL 读取文件(支持直接在 Claude 中查看 PNG、JPEG、GIF 和 WebP 图像)
  • create_directory/list_directory:目录管理
  • move_file:移动/重命名文件
  • search_files:基于模式的文件搜索
  • get_file_info:文件元数据
  • search_code:基于递归 ripgrep 的文本和代码搜索

编辑工具

  • edit_block:应用精确的文本替换(最适合小于文件大小 20% 的更改)
  • write_file:完整的文件重写(最适合大于 20% 的大型更改或 edit_block 失败时)

搜索/替换块格式:

filepath.ext
<<<<<<< SEARCH
要查找的内容
=======
新内容
>>>>>>> REPLACE

示例:

src/main.js
<<<<<<< SEARCH
console.log("old message");
=======
console.log("new message");
>>>>>>> REPLACE

URL 支持

  • read_file 现在可以从本地文件和 URL 获取内容
  • 示例:使用 isUrl: true 参数的 read_file 从 Web 资源读取
  • 处理来自远程源的文本和图像内容
  • 图像(本地或来自 URL)以可视方式显示在 Claude 的界面中,而不是作为文本
  • Claude 可以看到并分析实际的图像内容
  • URL 请求的默认超时时间为 30 秒

处理长时间运行的命令

对于可能需要一段时间的命令:

  1. execute_command 在超时后返回,并带有初始输出
  2. 命令在后台继续执行
  3. 使用带有 PID 的 read_output 获取新输出
  4. 如果需要,使用 force_terminate 停止

调试

如果您需要调试服务器,可以以调试模式安装它:

# 使用 npx
npx @wonderwhy-er/desktop-commander@latest setup --debug

# 或者如果本地安装
npm run setup:debug

这将:

  1. 配置 Claude 以使用单独的 "desktop-commander" 服务器
  2. 使用 --inspect-brk=9229 标志启用 Node.js 检查器协议
  3. 在调试器连接之前,在启动时暂停执行
  4. 启用额外的调试环境变量

要连接调试器:

  • 在 Chrome 中,访问 chrome://inspect 并查找 Node.js 实例
  • 在 VS Code 中,使用“附加到 Node 进程”调试配置
  • 其他 IDE/工具可能具有类似的 Node.js 调试“附加”选项

重要的调试注意事项:

  • 服务器将在启动时暂停,直到调试器连接(由于 --inspect-brk 标志)
  • 如果您在调试期间没有看到活动,请确保您已连接到正确的 Node.js 进程
  • 可能会运行多个 Node 进程;连接到端口 9229 上的进程
  • 调试服务器在 Claude 的 MCP 服务器列表中标识为 "desktop-commander-debug"

故障排除:

  • 如果 Claude 在尝试使用调试服务器时超时,则您的调试器可能未正确连接
  • 正确连接后,该进程将在命中第一个断点后继续执行
  • 连接后,您可以在 IDE 中添加其他断点

模型上下文协议集成

该项目扩展了 MCP 文件系统服务器以启用:

  • Claude Desktop 中的本地服务器支持
  • 完整的系统命令执行
  • 进程管理
  • 文件操作
  • 具有搜索/替换块的代码编辑

作为探索 Claude MCP 的一部分创建:https://youtube.com/live/TlbjFDbl5Us

已完成

  • 07-04-2025 添加了 URL 支持 - read_file 命令现在可以从 URL 获取内容
  • 28-03-2025 修复了 "Watching /" JSON 错误 - 实现了自定义 stdio 传输来处理非 JSON 消息并防止服务器崩溃
  • 25-03-2025 更好的代码搜索 (已合并) - 通过上下文感知的搜索结果增强了代码探索

正在进行的工作和待办事项

以下功能目前正在开发或计划中:

  • 更好的配置 (进行中) - 改进了允许的路径、命令和 shell 环境的设置
  • Windows 环境修复 (进行中) - 解决特定于 Windows 平台的问题
  • Linux 改进 (进行中) - 增强与各种 Linux 发行版的兼容性
  • 支持 WSL - Windows Subsystem for Linux 集成
  • 支持 SSH - 远程服务器命令执行
  • 安装故障排除指南 - 针对设置问题的全面帮助

网站

请访问我们的官方网站 https://desktopcommander.app/ 获取最新信息、文档和更新。

媒体

通过以下资源了解有关此项目的更多信息:

文章

Claude with MCPs replaced Cursor & Windsurf. How did that happen? - 详细探讨了具有模型上下文协议功能的 Claude 如何改变开发人员的工作流程。

视频

Claude Desktop Commander Video Tutorial - 观看如何有效地设置和使用 Commander。

AnalyticsIndiaMag 上的发布

analyticsindiamag.png This Developer Ditched Windsurf, Cursor Using Claude with MCPs

社区

加入我们的 Discord 服务器 以获得帮助、分享反馈并与其他用户联系。

用户评价

It's a life saver! I paid Claude + Cursor currently which I always feel it's kind of duplicated. This solves the problem ultimately. I am so happy. Thanks so much. Plus today Claude has added the web search support. With this MCP + Internet search, it writes the code with the latest updates. It's so good when Cursor doesn't work sometimes or all the fast requests are used. https://www.youtube.com/watch?v=ly3bed99Dy8&lc=UgyyBt6_ShdDX_rIOad4AaABAg

This is the first comment I've ever left on a youtube video, THANK YOU! I've been struggling to update an old Flutter app in Cursor from an old pre null-safety version to a current version and implemented null-safety using Claude 3.7. I got most of the way but had critical BLE errors that I spent days trying to resolve with no luck. I tried Augment Code but it didn't get it either. I implemented your MCP in Claude desktop and was able to compare the old and new codebase fully, accounting for the updates in the code, and fix the issues in a couple of hours. A word of advice to people trying this, be sure to stage changes and commit when appropriate to be able to undo unwanted changes. Amazing! https://www.youtube.com/watch?v=ly3bed99Dy8&lc=UgztdHvDMqTb9jiqnf54AaABAg

Great! I just used Windsurf, bought license a week ago, for upgrading old fullstack socket project and it works many times good or ok but also many times runs away in cascade and have to revert all changes losing hundereds of cascade tokens. In just a week down to less than 100 tokens and do not want to buy only 300 tokens for 10$. This Claude MCP ,bought claude Pro finally needed but wanted very good reason to also have next to ChatGPT, and now can code as much as I want not worrying about token cost.
Also this is much more than code editing it is much more thank you for great video! https://www.youtube.com/watch?v=ly3bed99Dy8&lc=UgyQFTmYLJ4VBwIlmql4AaABAg

it is a great tool, thank you, I like using it, as it gives claude an ability to do surgical edits, making it more like a human developer. https://www.youtube.com/watch?v=ly3bed99Dy8&lc=Ugy4-exy166_Ma7TH-h4AaABAg

You sir are my hero. You've pretty much summed up and described my experiences of late, much better than I could have. Cursor and Windsurf both had me frustrated to the point where I was almost yelling at my computer screen. Out of whimsy, I thought to myself why not just ask Claude directly, and haven't looked back since.
Claude first to keep my sanity in check, then if necessary, engage with other IDEs, frameworks, etc. I thought I was the only one, glad to see I'm not lol.
33
1 https://medium.com/@pharmx/you-sir-are-my-hero-62cff5836a3e

贡献

如果您发现此项目有用,请考虑在 GitHub 上给它一个 ⭐ 星!这有助于其他人发现该项目并鼓励进一步开发。

我们欢迎来自社区的贡献!无论您是发现了一个错误、有一个功能请求,还是想贡献代码,都可以通过以下方式提供帮助:

  • 发现了一个错误?github.com/wonderwhy-er/ClaudeComputerCommander/issues 上打开一个 issue
  • 有一个功能想法? 在 issues 部分提交一个功能请求
  • 想贡献代码? Fork 存储库,创建一个分支,然后提交一个 pull request
  • 问题或讨论? 在 GitHub Discussions 选项卡中开始讨论

所有贡献,无论大小,都非常感谢!

如果您发现此工具对您的工作流程有价值,请考虑 支持该项目

常见问题解答

以下是一些常见问题的解答。有关更全面的常见问题解答,请参阅我们的 详细常见问题解答文档

什么是 Claude Desktop Commander?

它是一个 MCP 工具,使 Claude Desktop 能够访问您的文件系统和终端,从而将 Claude 变成一个多功能的助手,用于编码、自动化、代码库探索等等。

这与 Cursor/Windsurf 有何不同?

与专注于 IDE 的工具不同,Claude Desktop Commander 提供了一种以解决方案为中心的方法,该方法适用于您的整个操作系统,而不仅仅是在编码环境中。Claude 读取完整的文件而不是分块读取,可以同时跨多个项目工作,并一次性执行更改,而无需不断审查。

我需要为 API 积分付费吗?

不需要。此工具适用于 Claude Desktop 的标准 Pro 订阅(每月 20 美元),而不是 API 调用,因此除了订阅费之外,您不会产生额外的费用。

Desktop Commander 会自动更新吗?

是的,通过 npx 或 Smithery 安装时,Desktop Commander 会在您重启 Claude 时自动更新到最新版本。无需手动更新过程。

最常见的用例是什么?

  • 探索和理解复杂的代码库
  • 生成图表和文档
  • 自动化系统中的任务
  • 同时处理多个项目
  • 通过精确控制进行精确的代码更改

我在安装或使用该工具时遇到问题。在哪里可以获得帮助?

加入我们的 Discord 服务器 以获得社区支持,查看 GitHub issues 以了解已知问题,或查看 完整常见问题解答 以获取故障排除提示。您还可以访问我们的 网站常见问题解答部分 以获得更友好的用户体验。如果您遇到新问题,请考虑 打开一个 GitHub issue 并提供有关您的问题的详细信息。

数据收集

在安装和设置期间,Desktop Commander 会收集匿名使用数据,以帮助改进该工具。这包括:

  • 操作系统信息
  • Node.js 和 NPM 版本
  • 安装方法和 shell 环境
  • 错误消息(如果在设置期间发生)

此数据使用 PostHog 分析收集,并与机器生成的唯一 ID 相关联。不收集任何个人信息。这有助于我们了解该工具的使用方式并识别常见问题。

我们目前正在努力在即将发布的版本中为此数据收集添加内置的退出选项。目前,如果您希望退出,可以在防火墙设置中阻止与 eu.i.posthog.com 的网络连接。

许可证

MIT

推荐服务器

Crypto Price & Market Analysis MCP Server

Crypto Price & Market Analysis MCP Server

一个模型上下文协议 (MCP) 服务器,它使用 CoinCap API 提供全面的加密货币分析。该服务器通过一个易于使用的界面提供实时价格数据、市场分析和历史趋势。 (Alternative, slightly more formal and technical translation): 一个模型上下文协议 (MCP) 服务器,利用 CoinCap API 提供全面的加密货币分析服务。该服务器通过用户友好的界面,提供实时价格数据、市场分析以及历史趋势数据。

精选
TypeScript
MCP PubMed Search

MCP PubMed Search

用于搜索 PubMed 的服务器(PubMed 是一个免费的在线数据库,用户可以在其中搜索生物医学和生命科学文献)。 我是在 MCP 发布当天创建的,但当时正在度假。 我看到有人在您的数据库中发布了类似的服务器,但还是决定发布我的服务器。

精选
Python
mixpanel

mixpanel

连接到您的 Mixpanel 数据。 从 Mixpanel 分析查询事件、留存和漏斗数据。

精选
TypeScript
Sequential Thinking MCP Server

Sequential Thinking MCP Server

这个服务器通过将复杂问题分解为顺序步骤来促进结构化的问题解决,支持修订,并通过完整的 MCP 集成来实现多条解决方案路径。

精选
Python
Nefino MCP Server

Nefino MCP Server

为大型语言模型提供访问德国可再生能源项目新闻和信息的能力,允许按地点、主题(太阳能、风能、氢能)和日期范围进行筛选。

官方
Python
Vectorize

Vectorize

将 MCP 服务器向量化以实现高级检索、私有深度研究、Anything-to-Markdown 文件提取和文本分块。

官方
JavaScript
Mathematica Documentation MCP server

Mathematica Documentation MCP server

一个服务器,通过 FastMCP 提供对 Mathematica 文档的访问,使用户能够从 Wolfram Mathematica 检索函数文档和列出软件包符号。

本地
Python
kb-mcp-server

kb-mcp-server

一个 MCP 服务器,旨在实现便携性、本地化、简易性和便利性,以支持对 txtai “all in one” 嵌入数据库进行基于语义/图的检索。任何 tar.gz 格式的 txtai 嵌入数据库都可以被加载。

本地
Python
Research MCP Server

Research MCP Server

这个服务器用作 MCP 服务器,与 Notion 交互以检索和创建调查数据,并与 Claude Desktop Client 集成以进行和审查调查。

本地
Python
Cryo MCP Server

Cryo MCP Server

一个API服务器,实现了模型补全协议(MCP),用于Cryo区块链数据提取,允许用户通过任何兼容MCP的客户端查询以太坊区块链数据。

本地
Python