INNER CODE UNIT · JavaScript
registerToolConditional
bvisible/mcp-ssh-manager · src/index.js:665
function registerToolConditional(toolName, schema, handler) {
if (isToolEnabled(toolName)) {
// Cast: registerTool infers its handler signature from the zod schema, which
// this generic wrapper cannot express while staying one helper for 37 tools.
server.registerTool(toolName, schema, /** @type {any} */ (handler));
logger.debug(`Registered tool: ${toolName}`);
} else {
logger.debug(`Skipped disabled tool: ${toolName}`);
}
}
// Register available tools
registerToolConditional(
'ssh_execute',
{
description: 'Runs a shell command over SSH on a named configured server and returns stdout, stderr, and exit code. Mutates remote state depending on the command; not read-only. Expands command aliases before running. Uses the cwd parameter or, if omitted, the server configured default directory; adapts syntax for Linux versus Windows PowerShell targets. Timeout defaults to 120000 ms and is capped at 300000 ms. Under readonly mode destructive commands like rm or dd are refused; under restricted mode the command must match allow patterns. Output is truncated when very large.',
inputSchema: {
server: z.string().describe('Server name from configuration'),