Skip to main content
Glama

ssh_upload

Upload files from local system to remote SSH server using MCP SSH Manager. Specify server name, local file path, and remote destination path for secure file transfer.

Instructions

Upload file to remote SSH server

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
serverYesServer name
localPathYesLocal file path
remotePathYesRemote destination path

Implementation Reference

  • Registration of the 'ssh_upload' tool as part of the essential core SSH operations group in the centralized tool registry.
    // Core group (5 tools) - Essential SSH operations core: [ 'ssh_list_servers', 'ssh_execute', 'ssh_upload', 'ssh_download', 'ssh_sync' ],
  • The putFile method in SSHManager class provides the core implementation for uploading files to remote servers. It handles path resolution for '~' (expands to user's home directory), initializes SFTP if needed, checks local file existence, and uses ssh2's fastPut for efficient transfer.
    async putFile(localPath, remotePath) { // SFTP doesn't resolve ~ automatically, we need to get the real path let resolvedRemotePath = remotePath; if (remotePath.includes('~')) { try { const homeDir = await this.resolveHomePath(); // Replace ~ with the actual home directory // Handle both ~/path and ~ alone if (remotePath === '~') { resolvedRemotePath = homeDir; } else if (remotePath.startsWith('~/')) { resolvedRemotePath = homeDir + remotePath.substring(1); } else { // If ~ is not at the beginning, don't replace it resolvedRemotePath = remotePath; } } catch (err) { // If we can't resolve home, throw a more descriptive error throw new Error(`Failed to resolve home directory for path: ${remotePath}. ${err.message}`); } } const sftp = await this.getSFTP(); return new Promise((resolve, reject) => { // Check if local file exists and is readable if (!fs.existsSync(localPath)) { reject(new Error(`Local file does not exist: ${localPath}`)); return; } sftp.fastPut(localPath, resolvedRemotePath, (err) => { if (err) reject(err); else resolve(); }); }); }
  • putFiles helper method for batch uploading multiple files, calling putFile for each and collecting results with optional stop-on-error.
    async putFiles(files, options = {}) { const sftp = await this.getSFTP(); const results = []; for (const file of files) { try { await this.putFile(file.local, file.remote); results.push({ ...file, success: true }); } catch (error) { results.push({ ...file, success: false, error: error.message }); if (options.stopOnError) break; } } return results; }

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/bvisible/mcp-ssh-manager'

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