# How to Configure Shell Settings with defaultShell in DesktopCommanderMCP

> Configure defaultShell settings in DesktopCommanderMCP to control your command execution shell. Learn how this setting impacts your workflow with this technical guide.

- Repository: [Eduard Ruzga/DesktopCommanderMCP](https://github.com/wonderwhy-er/DesktopCommanderMCP)
- Tags: how-to-guide
- Published: 2026-07-22

---

**DesktopCommanderMCP uses the `defaultShell` configuration field to determine which shell binary executes commands, falling back to system environment variables if unset.**

DesktopCommanderMCP provides a flexible configuration system that allows you to specify which shell binary handles command execution through the `defaultShell` setting. This configuration is managed by the **Config Manager** and stored in a persistent JSON file. You can modify this setting either through the Settings UI or programmatically via the Config Manager API to customize your command environment.

## Understanding the defaultShell Configuration Field

The `defaultShell` field is formally defined in [`src/config-field-definitions.ts`](https://github.com/wonderwhy-er/DesktopCommanderMCP/blob/main/src/config-field-definitions.ts) at lines 21-25, where it is typed as a **string** and annotated with user-friendly metadata. This definition tells the application that any value stored here should be interpreted as a file path to a shell executable, such as `/bin/bash`, `/bin/zsh`, `cmd.exe`, or `pwsh`.

When the Settings panel renders configuration options, it references these field definitions from `CONFIG_FIELD_DEFINITIONS` to display appropriate labels and descriptions for the shell selection interface.

## System Detection and Fallback Behavior

If you never explicitly set a default shell, DesktopCommanderMCP automatically detects one based on your operating system. The detection logic, implemented in [`uninstall-claude-server.js`](https://github.com/wonderwhy-er/DesktopCommanderMCP/blob/main/uninstall-claude-server.js) at lines 144-151, inspects `process.env.SHELL` on Unix systems and `process.env.ComSpec` on Windows to determine the appropriate fallback binary.

This ensures that new REPL sessions and command executions always spawn a valid shell even without explicit configuration, using the system's preferred command interpreter as a default.

## Programmatically Configuring the Default Shell

You can interact with the `defaultShell` setting directly through the Config Manager API exposed in [`src/config-manager.ts`](https://github.com/wonderwhy-er/DesktopCommanderMCP/blob/main/src/config-manager.ts). The manager provides getter and setter methods that read from and write to the underlying [`config.json`](https://github.com/wonderwhy-er/DesktopCommanderMCP/blob/main/config.json) file.

### Setting the Default Shell via the Config Manager

To change the shell programmatically, import the `configManager` and call `setValue()` with the key `'defaultShell'`:

```typescript
import { configManager } from './config-manager';

// Switch to Zsh for all new sessions
await configManager.setValue('defaultShell', '/bin/zsh');

// Verify the change
const shell = await configManager.getValue('defaultShell');
console.log(`Current default shell: ${shell}`);

```

### Reading the Default Shell for New Sessions

When spawning new processes, retrieve the configured shell using `getValue()` and provide a fallback if the configuration is empty:

```javascript
const { spawn } = require('child_process');
const { configManager } = require('./config-manager');

async function startShell() {
  const shell = await configManager.getValue('defaultShell') || '/bin/sh';
  const child = spawn(shell, [], { stdio: 'inherit' });
  child.on('exit', code => console.log(`Shell exited with code ${code}`));
}

startShell();

```

## Summary

- The `defaultShell` field is defined in [`src/config-field-definitions.ts`](https://github.com/wonderwhy-er/DesktopCommanderMCP/blob/main/src/config-field-definitions.ts) as a string type that accepts paths to shell executables like `/bin/bash` or `pwsh`.
- DesktopCommanderMCP falls back to system environment variables (`process.env.SHELL` on Unix or `process.env.ComSpec` on Windows) when no explicit shell is configured, as implemented in [`uninstall-claude-server.js`](https://github.com/wonderwhy-er/DesktopCommanderMCP/blob/main/uninstall-claude-server.js).
- Use `configManager.setValue('defaultShell', path)` to programmatically update settings and `configManager.getValue('defaultShell')` to retrieve the current configuration.
- Changes persist to [`config.json`](https://github.com/wonderwhy-er/DesktopCommanderMCP/blob/main/config.json) and apply immediately to new command sessions, while existing REPL sessions remain unaffected.

## Frequently Asked Questions

### Where is the defaultShell setting stored in DesktopCommanderMCP?

The `defaultShell` value is stored in the [`config.json`](https://github.com/wonderwhy-er/DesktopCommanderMCP/blob/main/config.json) file managed by the Config Manager in [`src/config-manager.ts`](https://github.com/wonderwhy-er/DesktopCommanderMCP/blob/main/src/config-manager.ts). The field definition in [`src/config-field-definitions.ts`](https://github.com/wonderwhy-er/DesktopCommanderMCP/blob/main/src/config-field-definitions.ts) provides the schema that validates this entry as a string representing a shell path.

### What happens if I don't configure a defaultShell?

If the `defaultShell` configuration is empty, DesktopCommanderMCP automatically detects your system shell by checking `process.env.SHELL` on Unix or `process.env.ComSpec` on Windows, as defined in [`uninstall-claude-server.js`](https://github.com/wonderwhy-er/DesktopCommanderMCP/blob/main/uninstall-claude-server.js) at lines 144-151. This ensures commands execute using your system's default command interpreter.

### Can I use PowerShell or CMD as the defaultShell on Windows?

Yes. The `defaultShell` field accepts any valid shell path, including Windows executables like `cmd.exe` or `pwsh`. Simply set the value to the full path of your preferred Windows shell executable using `configManager.setValue('defaultShell', 'pwsh')`.

### Do changes to defaultShell affect existing REPL sessions?

No. Changes to the `defaultShell` configuration only apply to new shell sessions spawned after the configuration is saved. Existing REPL sessions and running processes retain the shell binary that was active when they started.