ssh_connect
Connect to an SSH server using a configured profile for remote administration, command execution, and file transfers with security safeguards.
Instructions
Conecta a un servidor SSH usando un perfil configurado
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| profile | Yes | Nombre del perfil del servidor (ej: produccion, staging) |
Implementation Reference
- src/index.ts:110-154 (handler)The handler logic for "ssh_connect" which initiates an SSH connection to a specified profile.
private async handleConnect(args: any): Promise<CallToolResult> { if (this.sshClient) { throw new Error( `Ya hay una conexión activa al perfil "${this.currentProfile}". Desconecta primero con ssh_disconnect.` ); } const profileName = args.profile as string; const profile = getProfile(profileName); return new Promise<CallToolResult>((resolve, reject) => { const client = new Client(); client.on("ready", () => { this.sshClient = client; this.currentProfile = profileName; this.connectedAt = new Date(); this.commandHistory = []; this.recordCounter = 0; this.audit("ssh_connect", `profile=${profileName}`, "ok"); resolve({ content: [ { type: "text", text: `Conectado a "${profileName}" (${profile.username}@${profile.host}:${profile.port})`, }, ], }); }); client.on("error", (err) => { this.audit("ssh_connect", `profile=${profileName}`, "error"); reject(new Error(`Error conectando a "${profileName}": ${err.message}`)); }); client.connect({ host: profile.host, port: profile.port, username: profile.username, password: profile.password, }); }); } - src/tools.ts:12-25 (registration)Definition and registration of the "ssh_connect" tool, including its schema.
{ name: "ssh_connect", description: "Conecta a un servidor SSH usando un perfil configurado", inputSchema: { type: "object", properties: { profile: { type: "string", description: "Nombre del perfil del servidor (ej: produccion, staging)", }, }, required: ["profile"], }, },