/ 目录 / 演练场 / Desktop Commander
● 社区 wonderwhy-er ⚡ 即开即用

Desktop Commander

作者 wonderwhy-er · wonderwhy-er/DesktopCommanderMCP

给 Claude 一个真正的终端——跨整个文件系统的文件操作、代码编辑、进程管理和 shell 执行,并配有权限控制。

Desktop Commander 是一个 MCP server,能将 Claude Desktop 变成编码 agent,无需 Claude Code 或 Cursor。它暴露了文件系统读写、精准文本编辑、终端命令执行、长运行进程管理,以及基于配置的目录白名单。作为付费 agentic IDE 的免费替代方案,已被数十万开发者使用。

为什么要用

核心特性

实时演示

实际使用效果

desktop-commander-mcp.replay ▶ 就绪
0/0

安装

选择你的客户端

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "desktop-commander-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@wonderwhy-er/desktop-commander"
      ]
    }
  }
}

打开 Claude Desktop → Settings → Developer → Edit Config。保存后重启应用。

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "desktop-commander-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@wonderwhy-er/desktop-commander"
      ]
    }
  }
}

Cursor 使用与 Claude Desktop 相同的 mcpServers 格式。项目级配置优先于全局。

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "desktop-commander-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@wonderwhy-er/desktop-commander"
      ]
    }
  }
}

点击 Cline 侧栏中的 MCP Servers 图标,然后选 "Edit Configuration"。

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "desktop-commander-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@wonderwhy-er/desktop-commander"
      ]
    }
  }
}

格式与 Claude Desktop 相同。重启 Windsurf 生效。

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "desktop-commander-mcp",
      "command": "npx",
      "args": [
        "-y",
        "@wonderwhy-er/desktop-commander"
      ]
    }
  ]
}

Continue 使用服务器对象数组,而非映射。

~/.config/zed/settings.json
{
  "context_servers": {
    "desktop-commander-mcp": {
      "command": {
        "path": "npx",
        "args": [
          "-y",
          "@wonderwhy-er/desktop-commander"
        ]
      }
    }
  }
}

加入 context_servers。Zed 保存后热重载。

claude mcp add desktop-commander-mcp -- npx -y @wonderwhy-er/desktop-commander

一行命令搞定。用 claude mcp list 验证,claude mcp remove 卸载。

使用场景

实战用法: Desktop Commander

将 Claude Desktop 作为免费编码 agent 使用,无需 Cursor 或 Claude Code

👤 想要 agentic 编码体验但不想为 IDE 订阅付费的开发者 ⏱ ~20 min beginner

何时使用: 你已经有 Claude Desktop,希望它真正编辑你的仓库,而不仅仅是粘贴代码片段。

前置条件
  • 已安装 Claude Desktop — 从 claude.ai/download 下载
  • 工作目录已加白名单 — 首次运行时会提示选择 Claude 可操作的目录
步骤
  1. 安装并锁定工作区
    Install desktop-commander. Limit it to ~/Code/myproject — nothing outside.✓ 已复制
    → 配置中 allowed_directories 已限制;Claude 中出现工具列表
  2. 驱动一次真实变更
    Open ~/Code/myproject. Find every TODO comment, group by file, propose fixes for the top 5.✓ 已复制
    → ripgrep 级速度的扫描,带行号的优先级列表
  3. 通过 edit_block 应用更改
    Apply the proposed fixes using edit_block. Don't rewrite whole files — just the necessary diffs.✓ 已复制
    → 每次编辑显示 old_string/new_string 块;之后 git diff 干净

结果: Claude Desktop 现在能像付费 IDE 助手一样,向你的仓库写入真实代码更改。

注意事项
  • 忘记设置 allowed_directories——Claude 会扫描你的主目录 — 编辑 ~/.claude-server-commander/config.json 并重启 Claude Desktop
搭配使用: github · filesystem

运行开发服务器并捕获输出,不阻塞对话

👤 调试多进程环境的开发者 ⏱ ~25 min intermediate

何时使用: 你需要 Claude 启动一个服务器,在另一个终端运行测试,同时追踪日志。

步骤
  1. 在后台启动服务器
    Start npm run dev as a background process. Show me the PID.✓ 已复制
    → 进程已启动,返回 PID,输出流已捕获
  2. 对其运行测试
    While that's running, execute the e2e suite and surface any failures.✓ 已复制
    → 测试独立运行;服务器继续输出
  3. 按需查看日志
    Show the last 100 lines of stdout from PID 12345. Anything red?✓ 已复制
    → 日志切片,错误高亮显示

结果: 完全由 Claude 编排的多进程调试会话。

注意事项
  • 对话结束后后台进程仍在运行 — 完成后使用 kill_process 工具,或重启 Claude Desktop

在一次会话中跨数百个文件进行批量重构

👤 进行全代码库迁移(如重命名、废弃)的开发者 ⏱ ~60 min intermediate

何时使用: 你的 IDE 助手在超过 50 个文件的变更时卡死;你想要一次统一编排的操作。

步骤
  1. 确定变更范围
    Find every import of oldLib. Group by file and tell me how many changes per file.✓ 已复制
    → 影响范围的直方图
  2. 先在单个文件上测试
    Apply the migration to the smallest-impact file as a smoke test.✓ 已复制
    → 单文件迁移完成;测试通过
  3. 分批次推进
    Now apply to the next 20 files. After each batch, run lint and tell me if anything breaks.✓ 已复制
    → 每批次进度报告及健康检查

结果: 全代码库迁移完成,每批次都有可验证的检查点。

注意事项
  • edit_block 因空白字符差异失败 — 对较复杂的模式使用 search-replace 模式;检查行尾模式
搭配使用: github

组合

与其他 MCP 搭配,撬动十倍杠杆

desktop-commander-mcp + github

本地编辑后创建 PR

desktop-commander-mcp + filesystem

对比不同沙盒化的文件系统访问

工具

此 MCP 暴露的能力

工具输入参数何时调用成本
execute_command command: str, timeout_ms?: int 任何 shell 操作——git、npm、构建脚本 0
edit_block file_path, old_string, new_string 精准编辑——不重写整个文件 0
read_file path 读取源码以获取上下文 0
write_file path, content 创建新文件 0
search_files path, pattern 按名称或 glob 查找文件 0
search_code pattern, path? 跨文件的内容搜索 0
list_processes () 查看会话中正在运行的进程 0

成本与限制

运行它的成本

API 配额
不适用——本地运行
每次调用 Token 数
不定——大文件消耗 token 较多
费用
免费(MIT 协议)
提示
只需几行时,用 search_code 替代 read_file

安全

权限、密钥、影响范围

最小权限: filesystem-read filesystem-write shell-exec
凭据存储: 无——全部本地运行
数据出站: 无——所有调用均在本地
切勿授予: Unrestricted root directory access

故障排查

常见错误与修复

edit_block 报权限拒绝

将目录添加到 ~/.claude-server-commander/config.json 的 allowed_directories 中

验证: cat 配置文件并重启 Claude Desktop
进程已启动但无输出

使用 read_output 加 PID;输出默认是缓冲的,不会直接流到对话

edit_block 报"old_string not found"

空白字符或行尾偏移——先重新读取文件以复制精确的字节

替代方案

Desktop Commander 对比其他方案

替代方案何时用它替代权衡
Claude Code (CLI)你想要 Anthropic 官方的带规划能力的 agentic 循环Claude Code 更成熟,但需要独立订阅;Desktop Commander 免费
filesystem (official MCP)只需只读或沙盒化文件访问,无需 shell 执行功能面更小,不支持命令执行

更多

资源

📖 阅读 GitHub 上的官方 README

🐙 查看未解决的 issue

🔍 浏览全部 400+ MCP 服务器和 Skills