Skip to main content
Glama
widjis
by widjis

ssh_file_info

Retrieve file metadata like size and permissions from SSH-connected systems to verify file properties and manage remote file systems.

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 via SSH execCommand('stat'). Returns formatted file information including size, type, timestamps, and permissions.
    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 schema defining the input parameters for ssh_file_info: connectionId and filePath. Used for validation in the handler.
    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:307-318 (registration)
    Registration of the ssh_file_info tool in the ListTools response, including name, description, and JSON 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 case in the CallToolRequestSchema handler switch statement that routes to the ssh_file_info handler function.
    case 'ssh_file_info':
      return await this.handleSSHFileInfo(args);
Behavior2/5

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

With no annotations, the description carries full burden but provides minimal behavioral context. It mentions what information is retrieved but doesn't cover error handling, permissions needed, whether it's read-only (implied by 'Get'), or output format. This leaves gaps for a tool interacting with remote systems.

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's front-loaded with the core purpose and includes relevant examples (size, permissions), making it appropriately sized for its function.

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 no annotations and no output schema, the description is incomplete. It doesn't explain the return values (e.g., format of file info), error cases, or dependencies on SSH connections, which are critical for a tool in this context with siblings involving remote 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 parameters are well-documented in the schema. The description adds no additional meaning beyond implying the tool retrieves metadata for a file, which aligns with but doesn't enhance the schema's details on connectionId and filePath.

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 attributes like size and permissions. It distinguishes from siblings like ssh_list_files (which lists files) and ssh_read_output (which reads file content), but doesn't explicitly name alternatives or contrast scope.

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?

No guidance is provided on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an SSH connection first), exclusions, or compare with similar tools like ssh_list_files for metadata at scale.

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

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