mcp-ssh-manager 3.2.0 → 3.2.1
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/package.json +1 -1
- package/src/index.js +43 -19
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-ssh-manager",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.1",
|
|
4
4
|
"description": "MCP SSH Manager: Model Context Protocol server for SSH remote server management. Control SSH connections from Claude Code and OpenAI Codex - execute commands, transfer files, database operations, backups, health monitoring, and DevOps automation. NEW: Tool activation system reduces context usage by 92%",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
package/src/index.js
CHANGED
|
@@ -164,51 +164,75 @@ import { loadToolConfig, isToolEnabled } from './tool-config-manager.js';
|
|
|
164
164
|
const __filename = fileURLToPath(import.meta.url);
|
|
165
165
|
const __dirname = path.dirname(__filename);
|
|
166
166
|
|
|
167
|
-
//
|
|
168
|
-
|
|
167
|
+
// Resolve .env file path with fallback chain:
|
|
168
|
+
// 1. SSH_ENV_PATH env var (explicit override)
|
|
169
|
+
// 2. process.cwd()/.env (standard working directory)
|
|
170
|
+
// 3. ~/.env (home directory, where ssh-manager server add writes)
|
|
171
|
+
// 4. __dirname/../.env (backward compat for local installs)
|
|
172
|
+
function resolveEnvFilePath() {
|
|
173
|
+
if (process.env.SSH_ENV_PATH) {
|
|
174
|
+
return process.env.SSH_ENV_PATH;
|
|
175
|
+
}
|
|
176
|
+
const candidates = [
|
|
177
|
+
path.join(process.cwd(), '.env'),
|
|
178
|
+
path.join(os.homedir(), '.env'),
|
|
179
|
+
path.join(__dirname, '..', '.env'),
|
|
180
|
+
];
|
|
181
|
+
for (const candidate of candidates) {
|
|
182
|
+
if (fs.existsSync(candidate)) {
|
|
183
|
+
return candidate;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
// Default to cwd (consistent with config-loader.js)
|
|
187
|
+
return path.join(process.cwd(), '.env');
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const envFilePath = resolveEnvFilePath();
|
|
169
191
|
dotenv.config({ path: envFilePath });
|
|
170
192
|
|
|
171
193
|
// Initialize logger
|
|
172
194
|
logger.info('MCP SSH Manager starting', {
|
|
173
195
|
logLevel: process.env.SSH_LOG_LEVEL || 'INFO',
|
|
174
|
-
verbose: process.env.SSH_VERBOSE === 'true'
|
|
196
|
+
verbose: process.env.SSH_VERBOSE === 'true',
|
|
197
|
+
envFilePath
|
|
175
198
|
});
|
|
176
199
|
|
|
177
200
|
// Load SSH server configuration
|
|
178
201
|
let servers = {};
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
servers = {};
|
|
202
|
+
try {
|
|
203
|
+
const loadedServers = await configLoader.load({
|
|
204
|
+
envPath: envFilePath,
|
|
205
|
+
tomlPath: process.env.SSH_CONFIG_PATH,
|
|
206
|
+
preferToml: process.env.PREFER_TOML_CONFIG === 'true'
|
|
207
|
+
});
|
|
186
208
|
for (const [name, config] of loadedServers) {
|
|
187
209
|
servers[name] = config;
|
|
188
210
|
}
|
|
189
211
|
logger.info(`Loaded ${loadedServers.size} SSH server configurations from ${configLoader.configSource}`);
|
|
190
|
-
}
|
|
212
|
+
} catch (error) {
|
|
191
213
|
logger.error('Failed to load server configuration', { error: error.message });
|
|
192
|
-
}
|
|
214
|
+
}
|
|
193
215
|
|
|
194
216
|
// Initialize hooks system
|
|
195
|
-
|
|
217
|
+
try {
|
|
218
|
+
await initializeHooks();
|
|
219
|
+
} catch (error) {
|
|
196
220
|
logger.error('Failed to initialize hooks', { error: error.message });
|
|
197
|
-
}
|
|
221
|
+
}
|
|
198
222
|
|
|
199
223
|
// Load tool configuration
|
|
200
224
|
let toolConfig = null;
|
|
201
|
-
|
|
202
|
-
toolConfig =
|
|
203
|
-
const summary =
|
|
225
|
+
try {
|
|
226
|
+
toolConfig = await loadToolConfig();
|
|
227
|
+
const summary = toolConfig.getSummary();
|
|
204
228
|
logger.info(`Tool configuration loaded: ${summary.mode} mode, ${summary.enabledCount}/${summary.totalTools} tools enabled`);
|
|
205
229
|
if (summary.mode === 'all') {
|
|
206
230
|
logger.info('💡 Tip: Run "ssh-manager tools configure" to reduce context usage in Claude Code');
|
|
207
231
|
}
|
|
208
|
-
}
|
|
232
|
+
} catch (error) {
|
|
209
233
|
logger.error('Failed to load tool configuration', { error: error.message });
|
|
210
234
|
logger.info('Using default configuration (all tools enabled)');
|
|
211
|
-
}
|
|
235
|
+
}
|
|
212
236
|
|
|
213
237
|
// Map to store active connections
|
|
214
238
|
const connections = new Map();
|