
Claude Desktop Commander MCP
允许 Claude 桌面应用程序通过 MCP 在您的计算机上执行终端命令和编辑文件,功能包括命令执行、进程管理和基于差异的文件编辑。
Tools
execute_command
Execute a terminal command with timeout. Command will continue running in background if it doesn't complete within timeout.
read_output
Read new output from a running terminal session.
force_terminate
Force terminate a running terminal session.
list_sessions
List all active terminal sessions.
list_processes
List all running processes. Returns process information including PID, command name, CPU usage, and memory usage.
kill_process
Terminate a running process by PID. Use with caution as this will forcefully terminate the specified process.
block_command
Add a command to the blacklist. Once blocked, the command cannot be executed until unblocked.
unblock_command
Remove a command from the blacklist. Once unblocked, the command can be executed normally.
list_blocked_commands
List all currently blocked commands.
read_file
Read the complete contents of a file from the file system. Handles various text encodings and provides detailed error messages if the file cannot be read. Only works within allowed directories.
read_multiple_files
Read the contents of multiple files simultaneously. Each file's content is returned with its path as a reference. Failed reads for individual files won't stop the entire operation. Only works within allowed directories.
write_file
Completely replace file contents. Best for large changes (>20% of file) or when edit_block fails. Use with caution as it will overwrite existing files. Only works within allowed directories.
create_directory
Create a new directory or ensure a directory exists. Can create multiple nested directories in one operation. Only works within allowed directories.
list_directory
Get a detailed listing of all files and directories in a specified path. Results distinguish between files and directories with [FILE] and [DIR] prefixes. Only works within allowed directories.
move_file
Move or rename files and directories. Can move files between directories and rename them in a single operation. Both source and destination must be within allowed directories.
search_files
Recursively search for files and directories matching a pattern. Searches through all subdirectories from the starting path. Only searches within allowed directories.
get_file_info
Retrieve detailed metadata about a file or directory including size, creation time, last modified time, permissions, and type. Only works within allowed directories.
list_allowed_directories
Returns the list of directories that this server is allowed to access.
edit_block
Apply surgical text replacements to files. Best for small changes (<20% of file size). Multiple blocks can be used for separate changes. Will verify changes after application. Format: filepath, then <<<<<<< SEARCH, content to find, =======, new content, >>>>>>> REPLACE.
README
Desktop Commander MCP
使用 AI 搜索、更新、管理文件并运行终端命令
简而言之,两个关键点:终端命令和基于差异的文件编辑。
<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:通过 Smithery 安装
要通过 Smithery 自动为 Claude Desktop 安装 Desktop Commander:
npx -y @smithery/cli install @wonderwhy-er/desktop-commander --client claude
选项 3:手动添加到 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 正在运行,请重启它
选项 4:本地检出
- 克隆并构建:
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
: 文件操作(支持直接在 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
处理长时间运行的命令
对于可能需要一段时间的命令:
execute_command
在超时后返回初始输出- 命令在后台继续运行
- 使用带有 PID 的
read_output
获取新输出 - 如果需要,使用
force_terminate
停止
调试
如果您需要调试服务器,可以以调试模式安装它:
# 使用 npx
npx @wonderwhy-er/desktop-commander@latest setup --debug
# 或者如果本地安装
npm run setup:debug
这将:
- 配置 Claude 以使用单独的 "desktop-commander" 服务器
- 使用
--inspect-brk=9229
标志启用 Node.js 检查器协议 - 在调试器连接之前,在启动时暂停执行
- 启用额外的调试环境变量
要连接调试器:
- 在 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
已完成
- 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 上的出版物
This Developer Ditched Windsurf, Cursor Using Claude with MCPs
社区
加入我们的 Discord 服务器 以获得帮助、分享反馈并与其他用户联系。
用户评价
https://www.youtube.com/watch?v=ly3bed99Dy8&lc=UgyyBt6_ShdDX_rIOad4AaABAg
https://www.youtube.com/watch?v=ly3bed99Dy8&lc=UgztdHvDMqTb9jiqnf54AaABAg
https://www.youtube.com/watch?v=ly3bed99Dy8&lc=UgyQFTmYLJ4VBwIlmql4AaABAg
https://www.youtube.com/watch?v=ly3bed99Dy8&lc=Ugy4-exy166_Ma7TH-h4AaABAg
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
推荐服务器

Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。