Skip to main content
Glama

ssh_file_info

Retrieve file metadata like size and permissions from remote SSH servers or local systems using connection IDs and file paths.

Instructions

Get file information (size, permissions, etc.)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
connectionIdYesSSH connection ID (use "local" for local files)
filePathYesFile path to get info for

Implementation Reference

  • The handler function that executes the ssh_file_info tool. It parses input using FileInfoSchema, handles local files with fs.stat, and remote files by executing 'stat' command via SSH.
    private async handleSSHFileInfo(args: unknown) {
      const params = FileInfoSchema.parse(args);
      
      try {
        if (params.connectionId === 'local') {
          // Get local file info
          const stats = await fs.stat(params.filePath);
          const fileInfo = {
            path: params.filePath,
            size: stats.size,
            isDirectory: stats.isDirectory(),
            isFile: stats.isFile(),
            modified: stats.mtime.toISOString(),
            created: stats.birthtime.toISOString(),
            permissions: '0' + (stats.mode & parseInt('777', 8)).toString(8)
          };
    
          return {
            content: [
              {
                type: 'text',
                text: `File info for ${params.filePath}:\n${JSON.stringify(fileInfo, null, 2)}`,
              },
            ],
          };
        } else {
          // Get remote file info
          const ssh = connectionPool.get(params.connectionId);
          if (!ssh) {
            throw new McpError(
              ErrorCode.InvalidParams,
              `Connection ID '${params.connectionId}' not found`
            );
          }
    
          const result = await ssh.execCommand(`stat "${params.filePath}"`);
          
          if (result.code !== 0) {
            throw new Error(`stat command failed: ${result.stderr}`);
          }
    
          return {
            content: [
              {
                type: 'text',
                text: `File info for ${params.connectionId}:${params.filePath}:\n${result.stdout}`,
              },
            ],
          };
        }
      } catch (error) {
        throw new McpError(
          ErrorCode.InternalError,
          `Get file info failed: ${error instanceof Error ? error.message : String(error)}`
        );
      }
    }
  • Zod input schema for the ssh_file_info tool defining connectionId and filePath parameters.
    const FileInfoSchema = z.object({
      connectionId: z.string().describe('SSH connection ID (use "local" for local files)'),
      filePath: z.string().describe('File path to get info for')
    });
  • src/index.ts:308-318 (registration)
    Registration of the ssh_file_info tool in the ListTools response, providing name, description, and input schema.
      name: 'ssh_file_info',
      description: 'Get file information (size, permissions, etc.)',
      inputSchema: {
        type: 'object',
        properties: {
          connectionId: { type: 'string', description: 'SSH connection ID (use "local" for local files)' },
          filePath: { type: 'string', description: 'File path to get info for' }
        },
        required: ['connectionId', 'filePath']
      },
    },
  • src/index.ts:495-496 (registration)
    Dispatch to the ssh_file_info handler in the CallToolRequest switch statement.
    case 'ssh_file_info':
      return await this.handleSSHFileInfo(args);
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states it 'gets' information, implying a read-only operation, but doesn't clarify permissions needed, error handling (e.g., for non-existent files), output format, or whether it works for remote vs. local files (hinted in schema but not description). For a tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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 with zero waste. It front-loads the core action ('Get file information') and adds useful detail ('size, permissions, etc.') without unnecessary elaboration. Every word earns its place, making it highly concise and well-structured.

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?

Given the tool's moderate complexity (file operations over SSH), lack of annotations, and no output schema, the description is incomplete. It doesn't explain the return values, error conditions, or dependencies on other tools (e.g., ssh_connect). While the schema covers parameters well, the description fails to provide sufficient context for safe and effective use in this environment.

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%, with clear descriptions for both parameters (connectionId and filePath). The description adds no additional parameter semantics beyond what the schema provides, such as examples or constraints. With high schema coverage, the baseline score of 3 is appropriate, as the schema does the heavy lifting without extra value from the description.

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 verb 'Get' and the resource 'file information', specifying what attributes are retrieved (size, permissions, etc.). It distinguishes from siblings like ssh_list_files (which lists files) and ssh_execute (which runs commands), but doesn't explicitly name alternatives. The purpose is specific and actionable, though sibling differentiation is implicit rather than explicit.

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 (e.g., needing an established SSH connection via ssh_connect), exclusions, or compare it to similar tools like ssh_list_files for directory contents. Usage is implied by the tool name and context, but no explicit guidelines are given.

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/mahathirmuh/mcp-ssh-server'

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