Home / MCP / Desktop Commander MCP Server

Desktop Commander MCP Server

Provides long-running command execution, process management, and file editing via MCP for Claude Desktop

javascript
Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
    "mcpServers": {
        "desktop_commander": {
            "command": "npx",
            "args": [
                "-y",
                "@wonderwhy-er/desktop-commander"
            ]
        }
    }
}

You deploy and use the Desktop Commander MCP server to let Claude Desktop execute long-running terminal commands, manage processes, and perform file operations through the Model Context Protocol. This MCP server enables direct, programmatic control over your local machine’s terminal and filesystem from Claude, with output streaming, session management, and code editing capabilities.

How to use

You interact with the server through an MCP client integrated in Claude Desktop. Use the Terminal Tools to run commands with timeouts, stream outputs, and manage sessions. Use the Filesystem Tools to read and write files, create and list directories, move files, and search for content. Use the Edit Tools to apply surgical text replacements or rewrite entire files when needed. As you run long-running commands, you can poll for output and terminate sessions if necessary. All actions are exposed as MCP endpoints that you call from your client, allowing you to automate workflows and edits across your filesystem and processes.

Terminal Tools

Run commands with a configurable timeout and receive streaming output. List active sessions, view running processes, terminate processes by PID, and manage command access with a blacklist.

Key tools you will use include: execute_command, read_output, force_terminate, list_sessions, list_processes, kill_process, block_command, and unblock_command.

Filesystem Tools

Perform full filesystem operations: read and write files, create and list directories, move files, search for content with patterns, and retrieve file metadata.

Edit Tools

Edit blocks enable surgical changes for small edits, while write_file allows complete file rewrites for larger changes. Use a pattern-based replacement approach when making targeted edits, and apply full rewrites for major updates.

Search/Replace Block Format

Use a block format to describe replacements precisely. The format starts with the file path, followed by a search region, and then the replacement region.

Example:

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

Available tools

execute_command

Run terminal commands with a configurable timeout and streaming output.

read_output

Retrieve incremental output from long-running commands using a running session PID.

force_terminate

Terminate an active command session to stop execution immediately.

list_sessions

List all currently active command sessions for monitoring.

list_processes

Display processes currently running on the system.

kill_process

Terminate a specific process using its PID.

block_command

Blacklist specific commands to prevent their execution.

unblock_command

Remove a command from the blacklist to allow execution again.

read_file

Read the contents of a file.

write_file

Write or overwrite file contents.

create_directory

Create a new directory.

list_directory

List files and subdirectories within a directory.

move_file

Move or rename a file or directory.

search_files

Search for files matching a pattern.

get_file_info

Retrieve file metadata such as size, permissions, and timestamps.

edit_block

Apply surgical text replacements using a search/replace block format.

write_file

Rewrite an entire file when large changes are required.