How to Install Desktop Commander Using npx: Complete Setup Guide
Run npx @wonderwhy-er/desktop-commander@latest setup to automatically download, build, and register the MCP server with Claude Desktop.
Desktop Commander is a Model Context Protocol (MCP) server that exposes terminal and file system capabilities to AI assistants. According to the wonderwhy-er/DesktopCommanderMCP source code, the package is distributed via npm as @wonderwhy-er/desktop-commander and can be executed directly using npx without requiring a global installation. This approach ensures you always run the latest version while keeping your system clean.
Understanding the npx Installation Architecture
When you invoke npx with the Desktop Commander package, npm downloads the latest release from the registry and resolves the executable defined in the package's bin field. In package.json, three distinct binaries are declared:
desktop-commander→dist/index.js(the MCP server runtime)setup→dist/setup-claude-server.js(installation logic)remove→dist/uninstall-claude-server.js(removal logic)
These entries are located in the bin section of package.json.
Installation Commands
The setup binary is the primary entry point for installing Desktop Commander into Claude Desktop or any MCP-compatible client.
Standard Installation
Execute the following command to install the latest version:
npx @wonderwhy-er/desktop-commander@latest setup
This command triggers a sequence of operations defined in setup-claude-server.js:
- Dependency resolution: npm fetches the latest tarball from the registry.
- Build process: The script installs dependencies and compiles TypeScript sources using
tsc. - Configuration: It writes an MCP server entry into
claude_desktop_config.json. - Auto-update: Because the command uses
npx, Claude Desktop will automatically fetch updates on each restart.
Debug Mode Installation
To expose a Node.js inspector for troubleshooting on port 9229, append the --debug flag:
npx @wonderwhy-er/desktop-commander@latest setup --debug
Uninstalling Desktop Commander
To remove the MCP entry from Claude Desktop, use the remove binary:
npx @wonderwhy-er/desktop-commander@latest remove
This executes dist/uninstall-claude-server.js, which cleans up the configuration from claude_desktop_config.json.
Manual Configuration Alternative
If you prefer to configure Claude Desktop manually rather than using the setup script, add the following JSON to your claude_desktop_config.json file:
{
"mcpServers": {
"desktop-commander": {
"command": "npx",
"args": [
"-y",
"@wonderwhy-er/desktop-commander@latest"
]
}
}
}
This configuration ensures the server always runs the latest release without requiring manual updates.
How the Setup Script Works
The setup-claude-server.js script (compiled to dist/setup-claude-server.js) performs several critical installation steps. First, it verifies the environment and installs Node.js dependencies. Then it executes the TypeScript compiler (tsc) to build the project from source. Finally, it locates the Claude Desktop configuration directory and appends the Desktop Commander MCP entry to claude_desktop_config.json, enabling the terminal and file system tools to appear in your AI assistant interface.
Because the installation uses npx rather than a fixed path, the command field in the configuration remains dynamic. This design means Claude Desktop automatically pulls the latest version from npm on every startup, eliminating the need for manual upgrade procedures.
Summary
- Use
npx @wonderwhy-er/desktop-commander@latest setupto perform a complete installation that builds the TypeScript source and registers the MCP with Claude Desktop. - Add
--debugto the setup command to enable Node.js inspector mode on port 9229 for troubleshooting. - Execute
npx @wonderwhy-er/desktop-commander@latest removeto uninstall and clean up configuration files. - Manual installation requires adding the npx command structure to
claude_desktop_config.jsonunder themcpServerskey. - Auto-updates are built-in because the configuration points to
@latestvia npx.
Frequently Asked Questions
What does the Desktop Commander setup script do?
The setup script (dist/setup-claude-server.js) installs dependencies, compiles the TypeScript source code using tsc, and writes a configuration entry to claude_desktop_config.json. This registers Desktop Commander as an MCP server that Claude Desktop can launch on startup, enabling terminal and file system access through AI assistants.
How do I enable debug mode when installing Desktop Commander?
Append the --debug flag to the standard setup command: npx @wonderwhy-er/desktop-commander@latest setup --debug. This exposes a Node.js inspector on port 9229, allowing you to attach debugging tools like Chrome DevTools or VS Code to troubleshoot the MCP server initialization.
Can I install Desktop Commander without using npx?
Yes, though npx is the recommended method. You can clone the repository, run npm install and npm run build manually, then add the absolute path to dist/index.js in your claude_desktop_config.json. However, this approach requires manual updates when new versions are released, whereas the npx method handles updates automatically.
How do I completely remove Desktop Commander from Claude Desktop?
Run npx @wonderwhy-er/desktop-commander@latest remove to execute the uninstall script (dist/uninstall-claude-server.js). This removes the MCP server entry from claude_desktop_config.json and prevents Claude Desktop from attempting to launch the server on subsequent starts.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →