/ 目錄 / 演練場 / Desktop Commander
● 社群 wonderwhy-er ⚡ 即開即用

Desktop Commander

作者 wonderwhy-er · wonderwhy-er/DesktopCommanderMCP

給 Claude 一個真正的終端機——透過權限閘控,在整個檔案系統上進行檔案操作、程式碼編輯、行程管理與 Shell 指令。

Desktop Commander 是一個 MCP 伺服器,讓 Claude Desktop 無需 Claude Code 或 Cursor 即可成為編程代理。它提供檔案系統讀寫、精準文字編輯、終端機指令執行、長時間行程管理,以及以設定驅動的目錄白名單。數十萬開發者將其作為付費代理式 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 用作免費編程代理,無需 Cursor 或 Claude Code

👤 想要代理式編程但不想付 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 因空白字元差異而失敗 — 對較複雜的模式使用搜尋取代模式;檢查換行符號模式
搭配使用: 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 第一方帶規劃功能的代理迴圈Claude Code 更精緻但需要自己的訂閱;Desktop Commander 免費
filesystem (official MCP)只需唯讀或沙箱檔案存取,不需要 Shell 執行功能面較小,無指令執行

更多

資源

📖 閱讀 GitHub 上的官方 README

🐙 查看未解決的 issue

🔍 瀏覽全部 400+ MCP 伺服器和 Skills