@wonderwhy-er/desktop-commander 0.1.3 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -23,7 +23,7 @@ This server that allows Claude desktop app to execute long-running terminal comm
23
23
  - Pattern-based replacements
24
24
 
25
25
  ## Installation
26
- First, ensure you've downloaded and installed the [Claude Desktop](https://claude.ai/download app) and you have [npm installed](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm).
26
+ First, ensure you've downloaded and installed the [Claude Desktop app](https://claude.ai/download) and you have [npm installed](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm).
27
27
 
28
28
 
29
29
  ### Option 1: Install from npx
@@ -120,6 +120,19 @@ This project extends the MCP Filesystem Server to enable:
120
120
 
121
121
  Created as part of exploring Claude MCPs: https://youtube.com/live/TlbjFDbl5Us
122
122
 
123
+ ## Contributing
124
+
125
+ If you find this project useful, please consider giving it a ⭐ star on GitHub! This helps others discover the project and encourages further development.
126
+
127
+ We welcome contributions from the community! Whether you've found a bug, have a feature request, or want to contribute code, here's how you can help:
128
+
129
+ - **Found a bug?** Open an issue at [github.com/wonderwhy-er/ClaudeComputerCommander/issues](https://github.com/wonderwhy-er/ClaudeComputerCommander/issues)
130
+ - **Have a feature idea?** Submit a feature request in the issues section
131
+ - **Want to contribute code?** Fork the repository, create a branch, and submit a pull request
132
+ - **Questions or discussions?** Start a discussion in the GitHub Discussions tab
133
+
134
+ All contributions, big or small, are greatly appreciated!
135
+
123
136
  ## License
124
137
 
125
138
  MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wonderwhy-er/desktop-commander",
3
- "version": "0.1.3",
3
+ "version": "0.1.6",
4
4
  "description": "MCP server for terminal operations and file editing",
5
5
  "license": "MIT",
6
6
  "author": "Eduards Ruzga",
@@ -8,13 +8,15 @@
8
8
  "bugs": "https://github.com/wonderwhy-er/ClaudeComputerCommander/issues",
9
9
  "type": "module",
10
10
  "bin": {
11
- "mcp-desktop-commander": "dist/index.js"
11
+ "mcp-desktop-commander": "dist/index.js",
12
+ "mcp-desktop-commander-setup": "setup-claude-server.js"
12
13
  },
13
14
  "files": [
14
- "dist"
15
+ "dist",
16
+ "setup-claude-server.js"
15
17
  ],
16
18
  "scripts": {
17
- "build": "tsc && shx chmod +x dist/*.js",
19
+ "build": "tsc && shx chmod +x dist/*.js setup-claude-server.js",
18
20
  "watch": "tsc --watch",
19
21
  "start": "node dist/index.js",
20
22
  "setup": "npm install && npm run build && node setup-claude-server.js",
@@ -0,0 +1,115 @@
1
+ import { homedir, platform } from 'os';
2
+ import { join } from 'path';
3
+ import { readFileSync, writeFileSync, existsSync, appendFileSync } from 'fs';
4
+ import { fileURLToPath } from 'url';
5
+ import { dirname } from 'path';
6
+
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = dirname(__filename);
9
+
10
+ // Determine OS and set appropriate config path and command
11
+ const isWindows = platform() === 'win32';
12
+ const claudeConfigPath = isWindows
13
+ ? join(process.env.APPDATA, 'Claude', 'claude_desktop_config.json')
14
+ : join(homedir(), 'Library', 'Application Support', 'Claude', 'claude_desktop_config.json');
15
+
16
+ // Setup logging
17
+ const LOG_FILE = join(__dirname, 'setup.log');
18
+
19
+ function logToFile(message, isError = false) {
20
+ const timestamp = new Date().toISOString();
21
+ const logMessage = `${timestamp} - ${isError ? 'ERROR: ' : ''}${message}\n`;
22
+ try {
23
+ appendFileSync(LOG_FILE, logMessage);
24
+ // For setup script, we'll still output to console but in JSON format
25
+ const jsonOutput = {
26
+ type: isError ? 'error' : 'info',
27
+ timestamp,
28
+ message
29
+ };
30
+ process.stdout.write(JSON.stringify(jsonOutput) + '\n');
31
+ } catch (err) {
32
+ // Last resort error handling
33
+ process.stderr.write(JSON.stringify({
34
+ type: 'error',
35
+ timestamp: new Date().toISOString(),
36
+ message: `Failed to write to log file: ${err.message}`
37
+ }) + '\n');
38
+ }
39
+ }
40
+
41
+ // Check if config file exists and create default if not
42
+ if (!existsSync(claudeConfigPath)) {
43
+ logToFile(`Claude config file not found at: ${claudeConfigPath}`);
44
+ logToFile('Creating default config file...');
45
+
46
+ // Create the directory if it doesn't exist
47
+ const configDir = dirname(claudeConfigPath);
48
+ if (!existsSync(configDir)) {
49
+ import('fs').then(fs => fs.mkdirSync(configDir, { recursive: true }));
50
+ }
51
+
52
+ // Create default config
53
+ const defaultConfig = {
54
+ "serverConfig": isWindows
55
+ ? {
56
+ "command": "cmd.exe",
57
+ "args": ["/c"]
58
+ }
59
+ : {
60
+ "command": "/bin/sh",
61
+ "args": ["-c"]
62
+ }
63
+ };
64
+
65
+ writeFileSync(claudeConfigPath, JSON.stringify(defaultConfig, null, 2));
66
+ logToFile('Default config file created. Please update it with your Claude API credentials.');
67
+ }
68
+
69
+ try {
70
+ // Read existing config
71
+ const configData = readFileSync(claudeConfigPath, 'utf8');
72
+ const config = JSON.parse(configData);
73
+
74
+ // Prepare the new server config based on OS
75
+ // Determine if running through npx or locally
76
+ const isNpx = process.env.npm_lifecycle_event === undefined;
77
+
78
+ const serverConfig = isNpx ? {
79
+ "command": "npx",
80
+ "args": [
81
+ "@wonderwhy-er/desktop-commander"
82
+ ]
83
+ } : {
84
+ "command": "node",
85
+ "args": [
86
+ join(__dirname, 'dist', 'index.js')
87
+ ]
88
+ };
89
+
90
+ // Add or update the terminal server config
91
+ if (!config.mcpServers) {
92
+ config.mcpServers = {};
93
+ }
94
+
95
+ config.mcpServers.desktopCommander = serverConfig;
96
+
97
+ // Add puppeteer server if not present
98
+ if (!config.mcpServers.puppeteer) {
99
+ config.mcpServers.puppeteer = {
100
+ "command": "npx",
101
+ "args": ["-y", "@modelcontextprotocol/server-puppeteer"]
102
+ };
103
+ }
104
+
105
+ // Write the updated config back
106
+ writeFileSync(claudeConfigPath, JSON.stringify(config, null, 2), 'utf8');
107
+
108
+ logToFile('Successfully added MCP servers to Claude configuration!');
109
+ logToFile(`Configuration location: ${claudeConfigPath}`);
110
+ logToFile('\nTo use the servers:\n1. Restart Claude if it\'s currently running\n2. The servers will be available in Claude\'s MCP server list');
111
+
112
+ } catch (error) {
113
+ logToFile(`Error updating Claude configuration: ${error}`, true);
114
+ process.exit(1);
115
+ }