Desktop Commander MCP allows you to leverage Claude's AI capabilities to interact with your file system, execute terminal commands, and manage processes directly from the chat interface. It extends Claude beyond just conversation, turning it into a powerful tool for developers.
To install Desktop Commander MCP, you have several options:
This method provides automatic updates when you restart Claude:
npx @wonderwhy-er/desktop-commander@latest setup
For debugging mode:
npx @wonderwhy-er/desktop-commander@latest setup --debug
To uninstall:
npx @wonderwhy-er/desktop-commander@latest setup --uninstall
Another option with automatic updates:
npx -y @smithery/cli install @wonderwhy-er/desktop-commander --client claude
To uninstall:
npx -y @smithery/cli uninstall @wonderwhy-er/desktop-commander --client claude
Desktop Commander provides tools in several categories:
Execute terminal commands and manage processes:
// Execute a command
execute_command({ "command": "ls -la" })
// Start a process
start_process({ "command": "node" })
// Interact with a running process
interact_with_process({ "sessionId": "123", "input": "console.log('Hello World')" })
// List all running processes
list_processes({})
Read, write, and manage files:
// Read a file
read_file({ "path": "/path/to/file.txt" })
// Read a file from the web
read_file({ "path": "https://example.com/data.json", "isUrl": true })
// Write to a file
write_file({ "path": "/path/to/file.txt", "content": "Hello, world!" })
// List directory contents
list_directory({ "path": "/path/to/directory" })
// Search for files
search_files({ "path": "/path/to/directory", "pattern": "*.js" })
// Search within file contents
search_code({ "path": "/path/to/directory", "pattern": "function getUser" })
Make surgical edits to files:
// Edit a specific block of text
edit_block({
"filepath": "src/main.js",
"search_text": "console.log(\"old message\");",
"replace_text": "console.log(\"new message\");"
})
Alternative format for edit_block:
edit_block({
"filepath": "src/main.js",
"block": `<<<<<<< SEARCH
console.log("old message");
=======
console.log("new message");
>>>>>>> REPLACE`
})
You can customize Desktop Commander's behavior:
// Get current configuration
get_config({})
// Set specific configuration values
set_config_value({ "key": "defaultShell", "value": "/bin/zsh" })
set_config_value({ "key": "allowedDirectories", "value": ["/Users/username/projects"] })
set_config_value({ "key": "fileWriteLineLimit", "value": 100 })
Important security note: The allowedDirectories
setting only restricts filesystem operations, not terminal commands.
For commands that may take a while:
start_process
interact_with_process
to send inputread_process_output
to get new outputforce_terminate
to stop if neededExample workflow:
// Start a Node.js REPL
const response = start_process({ "command": "node" })
const sessionId = response.sessionId
// Send commands to the REPL
interact_with_process({
"sessionId": sessionId,
"input": "console.log('Hello from Node.js')"
})
// Read the latest output
read_process_output({ "sessionId": sessionId })
// When finished, terminate the session
force_terminate({ "sessionId": sessionId })
By default, Desktop Commander collects anonymous telemetry data. To disable this:
All tool calls are logged locally for auditing purposes in:
~/.claude-server-commander/claude_tool_call.log
%USERPROFILE%\.claude-server-commander\claude_tool_call.log
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "desktop-commander" '{"command":"npx","args":["-y","@wonderwhy-er/desktop-commander"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"desktop-commander": {
"command": "npx",
"args": [
"-y",
"@wonderwhy-er/desktop-commander"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"desktop-commander": {
"command": "npx",
"args": [
"-y",
"@wonderwhy-er/desktop-commander"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect