Skip to main content
Glama

fs_read

Read files from remote servers over SSH to access content for automation, analysis, or management tasks.

Instructions

Reads a file from the remote system

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesSSH session ID
pathYesFile path to read
encodingNoFile encoding (default: utf8)

Implementation Reference

  • The handler function 'readFile' that implements the 'fs_read' tool logic.
    export async function readFile(
      sessionId: string,
      path: string,
      encoding: string = 'utf8'
    ): Promise<string> {
      logger.debug('Reading file', { sessionId, path, encoding });
      
      const session = sessionManager.getSession(sessionId);
      if (!session) {
        throw new Error(`Session ${sessionId} not found or expired`);
      }
      
      try {
        const data = await session.sftp.get(path);
        const result = Buffer.isBuffer(data) ? data.toString(encoding as any) : String(data);
        logger.debug('File read successfully', { sessionId, path, size: result.length });
        return result;
      } catch (error) {
        logger.error('Failed to read file', { sessionId, path, error });
        throw wrapError(
          error,
          ErrorCode.EFS,
          `Failed to read file ${path}. Check if the file exists and is readable.`
        );
      }
    }
  • Zod schema for input validation for the 'fs_read' tool.
    export const FSReadSchema = z.object({
      sessionId: z.string().min(1),
      path: z.string().min(1),
      encoding: z.string().optional().default('utf8')
    });
  • src/mcp.ts:179-190 (registration)
    Registration of the 'fs_read' tool in the MCP server setup.
      name: 'fs_read',
      description: 'Reads a file from the remote system',
      inputSchema: {
        type: 'object',
        properties: {
          sessionId: { type: 'string', description: 'SSH session ID' },
          path: { type: 'string', description: 'File path to read' },
          encoding: { type: 'string', description: 'File encoding (default: utf8)' }
        },
        required: ['sessionId', 'path']
      }
    },
  • The case block in 'setupToolHandlers' that routes the 'fs_read' request to the 'readFile' handler.
    case 'fs_read': {
      const params = FSReadSchema.parse(args);
      const result = await readFile(params.sessionId, params.path, params.encoding);
      logger.info('File read', { sessionId: params.sessionId, path: params.path });
      return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states it 'reads a file' but doesn't describe what happens on errors (e.g., file not found, permission issues), whether it reads entire files or supports streaming, or any performance/rate limit considerations. For a file operation tool with zero annotation coverage, this leaves significant behavioral gaps.

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 wasted words. It's appropriately sized for a straightforward read operation and front-loads the core purpose 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?

Given the tool's moderate complexity (file reading with SSH session context) and lack of both annotations and output schema, the description is insufficient. It doesn't explain what the tool returns (file content? success status?), error behaviors, or dependencies on other tools like ssh_open_session. For a remote file operation, this leaves too many contextual gaps.

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?

The input schema has 100% description coverage, so all parameters (sessionId, path, encoding) are documented in the schema. The description adds no additional parameter semantics beyond what's already in the schema, which meets the baseline expectation when schema coverage is high.

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 ('Reads') and resource ('a file from the remote system'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like fs_stat (which reads metadata) or fs_list (which reads directory contents), missing full sibling distinction.

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 when to choose fs_read over fs_stat for file content versus metadata, or when to use it in conjunction with ssh_open_session for session management. No explicit when/when-not instructions are provided.

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

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