Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ For debugging mode (allows Node.js inspector connection):
```
npx @wonderwhy-er/desktop-commander@latest setup --debug
```

**Command line options during setup:**
- `--debug`: Enable debugging mode for Node.js inspector
- `--no-onboarding`: Disable onboarding prompts for new users

Comment on lines +90 to +93

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

🧩 Analysis chain

Confirm: does setup honor --no-onboarding?

Docs list --no-onboarding under “Command line options during setup”, but the server entrypoint short-circuits on setup and the PR wires the flag for runtime only. Verify runSetup actually persists this flag (e.g., into Claude config args); otherwise, move this bullet to the runtime CLI section.


🏁 Script executed:

#!/bin/bash
# Check if setup pipeline consumes or persists --no-onboarding
rg -nC3 -S '\-\-no-onboarding|noOnboarding|disableOnboarding' --type ts --type tsx

Length of output: 27


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Searching for '--no-onboarding' or related identifiers..."
rg -nC3 -S '\-\-no-onboarding|noOnboarding|disableOnboarding' -g '!*node_modules/*' -g '!*dist/*' -g '!*build/*' || true

echo -e "\nSearching for runSetup definitions/usages..."
rg -nC3 -S '(\brunSetup\b|function\s+runSetup\b|export\s+function\s+runSetup\b|const\s+runSetup\b|async\s+function\s+runSetup\b)' -g '!*node_modules/*' -g '!*dist/*' -g '!*build/*' || true

echo -e "\nSearching for CLI parsers (commander|yargs|minimist|meow|caporal)..."
rg -nC3 -S '\b(commander|yargs|meow|minimist|caporal)\b' -g '!*node_modules/*' -g '!*dist/*' -g '!*build/*' || true

echo -e "\nSearching for process.argv usages..."
rg -nC3 -S 'process\.argv' -g '!*node_modules/*' -g '!*dist/*' -g '!*build/*' || true

if [ -f README.md ]; then
  echo -e "\nREADME.md lines 90-93:"
  nl -ba README.md | sed -n '90,93p' || true
fi

if [ -f package.json ]; then
  echo -e "\npackage.json scripts:"
  jq -r '.scripts' package.json || true
fi

exit 0

Length of output: 2395


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Repo root:"
ls -la || true

echo -e "\nFind files with 'setup-claude' in the name:"
find . -type f -iname "*setup-claude*" -print || true

echo -e "\nSearch for 'onboard' (onboarding, onboard) and '--no-onboarding' usages (exclude common build dirs):"
grep -RIn --binary-files=without-match --exclude-dir={node_modules,.git,dist,build} -e 'onboard' -e '--no-onboarding' -e 'noOnboarding' -e 'disableOnboarding' || true

echo -e "\nSearch for 'setup' script usages and 'process.argv' (to find flag parsing):"
grep -RIn --binary-files=without-match --exclude-dir={node_modules,.git,dist,build} -e 'process.argv' -e '\\bsetup\\b' -e 'runSetup' -e 'setup-claude-server' || true

echo -e "\nIf setup-claude-server.js exists at repo root or in dist, print first 300 lines:"
for f in setup-claude-server.js dist/setup-claude-server.js; do
  if [ -f "$f" ]; then
    echo "---- $f ----"
    sed -n '1,300p' "$f" || true
  else
    echo "$f: not found"
  fi
done

echo -e "\nShow README.md lines 90-93 (if present):"
if [ -f README.md ]; then
  sed -n '90,93p' README.md || true
else
  echo "README.md not found"
fi

Length of output: 26979


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== src/index.ts ==="
sed -n '1,240p' src/index.ts || true

echo -e "\n=== src/npm-scripts/setup.ts ==="
sed -n '1,400p' src/npm-scripts/setup.ts || true

echo -e "\n=== src/utils/usageTracker.ts (360-420) ==="
sed -n '360,420p' src/utils/usageTracker.ts || true

echo -e "\n=== grep for 'no-onboarding' / 'disableOnboarding' / 'onboard' in key files ==="
grep -nC2 --binary-files=without-match -e '--no-onboarding' -e 'disableOnboarding' -e 'onboard' setup-claude-server.js src/npm-scripts/setup.ts src/index.ts src/utils/usageTracker.ts || true

Length of output: 16029


Action: --no-onboarding is not honored during setup — update docs or persist the flag.

Verified: README lists --no-onboarding under setup (README.md lines 90–93) but code short-circuits on setup before parsing that flag (src/index.ts calls runSetup and returns). runSetup (src/npm-scripts/setup.ts) imports/executes setup-claude-server.js without passing args, and setup-claude-server.js contains no handling for --no-onboarding. Runtime handling exists (src/index.ts sets global.disableOnboarding; src/utils/usageTracker.ts reads it), so the flag only takes effect when starting the server, not during setup.

  • Fix options or docs: either move the README bullet to the runtime CLI section, or make setup persist/consume the flag (pass CLI args into setup-claude-server.js or write the flag into config during setup). Files to update: README.md (90–93), src/index.ts, src/npm-scripts/setup.ts, setup-claude-server.js (and optionally src/utils/usageTracker.ts).
🤖 Prompt for AI Agents
In README.md lines 90–93 and related setup flow (src/index.ts,
src/npm-scripts/setup.ts, setup-claude-server.js, optionally
src/utils/usageTracker.ts): the --no-onboarding flag is documented as a setup
option but is ignored during setup because runSetup returns before parsing args
and setup-claude-server.js is invoked without args; either update the README to
move/remove that bullet or make the flag persist/consumed during setup by
passing CLI args from src/index.ts through src/npm-scripts/setup.ts into
setup-claude-server.js and/or writing the flag into the config/storage used by
usageTracker so global.disableOnboarding is set during setup; modify README.md
(move the flag to runtime CLI section if choosing docs), and if implementing
behavior change, update src/index.ts to forward process.argv to runSetup, update
src/npm-scripts/setup.ts to forward args to the child/require of
setup-claude-server.js, and add handling in setup-claude-server.js to read the
flag and persist it to the same config/flag that src/utils/usageTracker.ts
reads.

Restart Claude if running.

**✅ Auto-Updates:** Yes - automatically updates when you restart Claude
Expand Down Expand Up @@ -652,6 +657,44 @@ set_config_value({ "key": "fileWriteLineLimit", "value": 25 })

4. **Always verify configuration after changes**: Use `get_config({})` to confirm your changes were applied correctly.

## Command Line Options

Desktop Commander supports several command line options for customizing behavior:

### Disable Onboarding

By default, Desktop Commander shows helpful onboarding prompts to new users (those with fewer than 10 tool calls). You can disable this behavior:

```bash
# Disable onboarding for this session
node dist/index.js --no-onboarding

# Or if using npm scripts
npm run start:no-onboarding

# For npx installations, modify your claude_desktop_config.json:
{
"mcpServers": {
"desktop-commander": {
"command": "npx",
"args": [
"-y",
"@wonderwhy-er/desktop-commander@latest",
"--no-onboarding"
]
}
}
}
```

**When onboarding is automatically disabled:**
- When the MCP client name is set to "desktop-commander"
- When using the `--no-onboarding` flag
- After users have used onboarding prompts or made 10+ tool calls

**Debug information:**
The server will log when onboarding is disabled: `"Onboarding disabled via --no-onboarding flag"`

## Using Different Shells

You can specify which shell to use for command execution:
Expand Down
9 changes: 9 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ async function runServer() {
return;
}

// Parse command line arguments for onboarding control
const DISABLE_ONBOARDING = process.argv.includes('--no-onboarding');
if (DISABLE_ONBOARDING) {
logToStderr('info', 'Onboarding disabled via --no-onboarding flag');
}

// Set global flag for onboarding control
(global as any).disableOnboarding = DISABLE_ONBOARDING;

Comment on lines +26 to +34

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

🧩 Analysis chain

Set the global flag without any; optional env support

Use the typed global and drop the any cast. Optionally support an env var for headless/packaged runs.

 // Parse command line arguments for onboarding control
-const DISABLE_ONBOARDING = process.argv.includes('--no-onboarding');
+const DISABLE_ONBOARDING =
+  process.argv.includes('--no-onboarding')
+  // Optional: allow env override (document if adopted)
+  || process.env.DC_DISABLE_ONBOARDING === '1'
+  || process.env.DC_DISABLE_ONBOARDING === 'true';

 if (DISABLE_ONBOARDING) {
   logToStderr('info', 'Onboarding disabled via --no-onboarding flag');
 }

 // Set global flag for onboarding control
-(global as any).disableOnboarding = DISABLE_ONBOARDING;
+global.disableOnboarding = DISABLE_ONBOARDING;

Verification script (ensures no remaining unsafe casts and that the flag is wired once):


🏁 Script executed:

#!/bin/bash
rg -nC2 -S '\(global as any\)\.disableOnboarding|global\.disableOnboarding|disableOnboarding' --type ts

Length of output: 749


Use the typed global (remove any) and add optional env override

src/types.ts already declares global.disableOnboarding; replace all casts and set the flag from args or an env var in src/index.ts, and update usages elsewhere.

Locations:

  • src/types.ts (declare global: disableOnboarding at line ~6)
  • src/index.ts (assignment at line 33) — suggested change below
  • src/utils/usageTracker.ts (check at line 386) — change if ((global as any).disableOnboarding)if (global.disableOnboarding)

Suggested diff for src/index.ts:

 // Parse command line arguments for onboarding control
-const DISABLE_ONBOARDING = process.argv.includes('--no-onboarding');
+const DISABLE_ONBOARDING =
+  process.argv.includes('--no-onboarding')
+  // Optional: allow env override (document if adopted)
+  || process.env.DC_DISABLE_ONBOARDING === '1'
+  || process.env.DC_DISABLE_ONBOARDING === 'true';

 if (DISABLE_ONBOARDING) {
   logToStderr('info', 'Onboarding disabled via --no-onboarding flag');
 }

 // Set global flag for onboarding control
-(global as any).disableOnboarding = DISABLE_ONBOARDING;
+global.disableOnboarding = DISABLE_ONBOARDING;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Parse command line arguments for onboarding control
const DISABLE_ONBOARDING = process.argv.includes('--no-onboarding');
if (DISABLE_ONBOARDING) {
logToStderr('info', 'Onboarding disabled via --no-onboarding flag');
}
// Set global flag for onboarding control
(global as any).disableOnboarding = DISABLE_ONBOARDING;
// Parse command line arguments for onboarding control
const DISABLE_ONBOARDING =
process.argv.includes('--no-onboarding')
// Optional: allow env override (document if adopted)
|| process.env.DC_DISABLE_ONBOARDING === '1'
|| process.env.DC_DISABLE_ONBOARDING === 'true';
if (DISABLE_ONBOARDING) {
logToStderr('info', 'Onboarding disabled via --no-onboarding flag');
}
// Set global flag for onboarding control
global.disableOnboarding = DISABLE_ONBOARDING;

try {
logToStderr('info', 'Loading configuration...');
await configManager.loadConfig();
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FilteredStdioServerTransport } from './custom-stdio.js';

declare global {
var mcpTransport: FilteredStdioServerTransport | undefined;
var disableOnboarding: boolean | undefined;
}

export interface ProcessInfo {
Expand Down
16 changes: 16 additions & 0 deletions src/utils/usageTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,22 @@ class UsageTracker {
* Check if user should see onboarding invitation - SIMPLE VERSION
*/
async shouldShowOnboarding(): Promise<boolean> {
// Check if onboarding is disabled via command line argument
if ((global as any).disableOnboarding) {
return false;
}

// Check if client is desktop-commander (disable for this client)
try {
const { currentClient } = await import('../server.js');
if (currentClient?.name === 'desktop-commander') {
return false;
}
} catch (error) {
// If we can't import server, continue with other checks
console.log('[ONBOARDING DEBUG] Could not check client name, continuing...');
}

const stats = await this.getStats();
const onboardingState = await this.getOnboardingState();
const now = Date.now();
Expand Down