Skip to main content
Glama

ssh_download_file

Download files from a remote server via SSH to your local machine by specifying remote and local paths.

Instructions

Download a file from the remote server

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
connectionIdYesID of an active SSH connection
remotePathYesPath to the file on the remote server
localPathYesPath where the file should be saved locally

Implementation Reference

  • The handler function that executes the ssh_download_file tool logic using SFTP to download files from remote server.
    private async handleSSHDownload(params: any) {
      const { connectionId, remotePath, localPath } = params;
      
      // Check if the connection exists
      if (!this.connections.has(connectionId)) {
        return {
          content: [{ type: "text", text: `No active SSH connection with ID: ${connectionId}` }],
          isError: true
        };
      }
      
      const { conn } = this.connections.get(connectionId)!;
      
      try {
        // Expand tilde if present in the local path
        const expandedLocalPath = localPath.replace(/^~/, os.homedir());
        
        // Ensure the directory exists
        const dir = path.dirname(expandedLocalPath);
        if (!fs.existsSync(dir)) {
          fs.mkdirSync(dir, { recursive: true });
        }
        
        // Get SFTP client
        const sftp: any = await new Promise((resolve, reject) => {
          conn.sftp((err: Error | undefined, sftp: any) => {
            if (err) {
              reject(new Error(`Failed to initialize SFTP: ${err.message}`));
            } else {
              resolve(sftp);
            }
          });
        });
        
        // Download the file
        await new Promise((resolve, reject) => {
          sftp.fastGet(remotePath, expandedLocalPath, (err: Error | undefined) => {
            if (err) {
              reject(new Error(`Failed to download file: ${err.message}`));
            } else {
              resolve(true);
            }
          });
        });
        
        return {
          content: [{ type: "text", text: `Successfully downloaded ${remotePath} to ${expandedLocalPath}` }]
        };
      } catch (error: any) {
        return {
          content: [{ type: "text", text: `File download failed: ${error.message}` }],
          isError: true
        };
      }
  • Primary input schema definition for ssh_download_file in server capabilities registration.
    ssh_download_file: {
      description: "Download a file from the remote server",
      inputSchema: {
        type: "object",
        properties: {
          connectionId: {
            type: "string",
            description: "ID of an active SSH connection"
          },
          remotePath: {
            type: "string",
            description: "Path to the file on the remote server"
          },
          localPath: {
            type: "string",
            description: "Path where the file should be saved locally"
          }
        },
        required: ["connectionId", "remotePath", "localPath"]
      }
    },
  • src/index.ts:282-283 (registration)
    Registration of the ssh_download_file handler in the main tool dispatcher switch statement.
    case 'ssh_download_file':
      return this.handleSSHDownload(request.params.arguments);
  • Input schema for ssh_download_file in the ListTools response.
    {
      name: 'ssh_download_file',
      description: 'Download a file from the remote server',
      inputSchema: {
        type: 'object',
        properties: {
          connectionId: { type: 'string', description: 'ID of an active SSH connection' },
          remotePath: { type: 'string', description: 'Path to the file on the remote server' },
          localPath: { type: 'string', description: 'Path where the file should be saved locally' }
        },
        required: ['connectionId', 'remotePath', 'localPath']
      }
  • Input schema for ssh_download_file included in the overridden ListTools response from Ubuntu tools module.
      name: 'ssh_download_file',
      description: 'Download a file from the remote server',
      inputSchema: {
        type: 'object',
        properties: {
          connectionId: { type: 'string', description: 'ID of an active SSH connection' },
          remotePath: { type: 'string', description: 'Path to the file on the remote server' },
          localPath: { type: 'string', description: 'Path where the file should be saved locally' }
        },
        required: ['connectionId', 'remotePath', 'localPath']
      }
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action ('Download') but doesn't describe what happens during execution—such as whether it overwrites local files, handles errors, requires specific permissions, or provides progress feedback. This leaves significant gaps for a file transfer operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's function without any unnecessary words. It's front-loaded with the core action, making it easy to parse and understand immediately.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a file download tool with no annotations and no output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., success status, error messages, or file metadata), nor does it cover behavioral aspects like error handling or security considerations, which are critical for SSH operations.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all three parameters (connectionId, remotePath, localPath) with clear descriptions. The description adds no additional meaning beyond what's in the schema, such as file format support or path validation rules, meeting the baseline for high coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Download') and resource ('a file from the remote server'), making the tool's purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like ssh_upload_file or ssh_list_files, which would require mentioning it's specifically for file retrieval rather than upload or listing.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites like needing an active SSH connection (implied by the connectionId parameter but not stated), nor does it differentiate from siblings such as ssh_upload_file for uploading or ssh_list_files for browsing files.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/mixelpixx/SSH-MCP'

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