Skip to main content
Glama
d3v1an
by d3v1an

ssh_upload

Upload a local file to a remote server using SFTP for secure file transfer and remote administration.

Instructions

Sube un archivo local al servidor remoto via SFTP

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
localPathYesRuta del archivo local a subir
remotePathYesRuta destino en el servidor remoto

Implementation Reference

  • The handler for `ssh_upload` which uses `sftp.fastPut` to upload files, handles rollback info creation, and updates audit logs.
    private async handleUpload(args: any): Promise<CallToolResult> {
      this.requireConnection();
      const { localPath, remotePath } = args as { localPath: string; remotePath: string };
    
      // Capturar estado previo antes de subir
      let previousContent: string | undefined;
      let previousExisted = true;
      try {
        previousContent = await this.execCommand(`cat ${escapeShellArg(remotePath)}`);
      } catch {
        previousExisted = false;
      }
    
      const sftp = await this.getSftp();
    
      return new Promise<CallToolResult>((resolve, reject) => {
        sftp.fastPut(localPath, remotePath, (err) => {
          if (err) {
            this.audit("ssh_upload", `${localPath} -> ${remotePath}`, "error");
            reject(new Error(`Error subiendo archivo: ${err.message}`));
          } else {
            this.audit("ssh_upload", `${localPath} -> ${remotePath}`, "ok");
    
            const reverseInfo: ReverseInfo = previousExisted
              ? {
                  type: "file_restore",
                  description: `Restaurar contenido previo de ${remotePath}`,
                  remotePath,
                  previousContent,
                  previousExisted: true,
                }
              : {
                  type: "file_delete",
                  description: `Eliminar ${remotePath} (no existía antes)`,
                  remotePath,
                  previousExisted: false,
                };
    
            this.recordOperation(
              "ssh_upload",
              { localPath, remotePath },
              `Archivo subido: ${localPath} -> ${remotePath}`,
              true,
              reverseInfo
            );
    
            resolve({
              content: [
                { type: "text", text: `Archivo subido: ${localPath} -> ${remotePath}` },
              ],
            });
          }
        });
      });
    }
  • The schema definition for the `ssh_upload` tool.
      name: "ssh_upload",
      description: "Sube un archivo local al servidor remoto via SFTP",
      inputSchema: {
        type: "object",
        properties: {
          localPath: {
            type: "string",
            description: "Ruta del archivo local a subir",
          },
          remotePath: {
            type: "string",
            description: "Ruta destino en el servidor remoto",
          },
        },
        required: ["localPath", "remotePath"],
      },
    },
  • src/index.ts:67-68 (registration)
    Registration of the `ssh_upload` tool handler in the main request handler switch case.
    case "ssh_upload":
      return await this.handleUpload(args);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/d3v1an/ssh-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server