Skip to main content
Glama

fast_read_file

Read files with auto-chunking support, allowing you to specify byte offsets, line ranges, or use continuation tokens for large files.

Instructions

Reads a file (with auto-chunking support)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesFile path to read
start_offsetNoStarting byte offset
max_sizeNoMaximum size to read
line_startNoStarting line number
line_countNoNumber of lines to read
encodingNoText encodingutf-8
continuation_tokenNoContinuation token from a previous call
auto_chunkNoEnable auto-chunking

Implementation Reference

  • The main execution logic for the fast_read_file tool. Supports reading by byte offset or line range, with size limits, truncation, path validation, and metadata return.
    async function handleReadFile(args: any) {
      const { path: filePath, start_offset = 0, max_size, line_start, line_count, encoding = 'utf-8' } = args;
      
      const safePath_resolved = safePath(filePath);
      const stats = await fs.stat(safePath_resolved);
      
      if (!stats.isFile()) {
        throw new Error('Path is not a file');
      }
      
      const maxReadSize = max_size ? Math.min(max_size, CLAUDE_MAX_CHUNK_SIZE) : CLAUDE_MAX_CHUNK_SIZE;
      
      if (line_start !== undefined) {
        const linesToRead = line_count ? Math.min(line_count, CLAUDE_MAX_LINES) : CLAUDE_MAX_LINES;
        const fileContent = await fs.readFile(safePath_resolved, encoding as BufferEncoding);
        const lines = fileContent.split('\n');
        const selectedLines = lines.slice(line_start, line_start + linesToRead);
        
        return {
          content: selectedLines.join('\n'),
          mode: 'lines',
          start_line: line_start,
          lines_read: selectedLines.length,
          total_lines: lines.length,
          file_size: stats.size,
          file_size_readable: formatSize(stats.size),
          encoding: encoding,
          path: safePath_resolved
        };
      }
      
      const fileHandle = await fs.open(safePath_resolved, 'r');
      const buffer = Buffer.alloc(maxReadSize);
      const { bytesRead } = await fileHandle.read(buffer, 0, maxReadSize, start_offset);
      await fileHandle.close();
      
      const content = buffer.subarray(0, bytesRead).toString(encoding as BufferEncoding);
      const result = truncateContent(content);
      
      return {
        content: result.content,
        mode: 'bytes',
        start_offset: start_offset,
        bytes_read: bytesRead,
        file_size: stats.size,
        file_size_readable: formatSize(stats.size),
        encoding: encoding,
        truncated: result.truncated,
        has_more: start_offset + bytesRead < stats.size,
        path: safePath_resolved
      };
    }
  • Input schema validation for fast_read_file tool parameters.
    inputSchema: {
      type: 'object',
      properties: {
        path: { type: 'string', description: '읽을 파일 경로' },
        start_offset: { type: 'number', description: '시작 바이트 위치' },
        max_size: { type: 'number', description: '읽을 최대 크기' },
        line_start: { type: 'number', description: '시작 라인 번호' },
        line_count: { type: 'number', description: '읽을 라인 수' },
        encoding: { type: 'string', description: '텍스트 인코딩', default: 'utf-8' }
      },
      required: ['path']
    }
  • api/server.ts:107-122 (registration)
    Tool registration in MCP_TOOLS array, exposed via tools/list endpoint.
    {
      name: 'fast_read_file',
      description: '파일을 읽습니다 (청킹 지원)',
      inputSchema: {
        type: 'object',
        properties: {
          path: { type: 'string', description: '읽을 파일 경로' },
          start_offset: { type: 'number', description: '시작 바이트 위치' },
          max_size: { type: 'number', description: '읽을 최대 크기' },
          line_start: { type: 'number', description: '시작 라인 번호' },
          line_count: { type: 'number', description: '읽을 라인 수' },
          encoding: { type: 'string', description: '텍스트 인코딩', default: 'utf-8' }
        },
        required: ['path']
      }
    },
  • api/server.ts:323-325 (registration)
    Dispatch/registration of fast_read_file handler in the tools/call switch statement.
    case 'fast_read_file':
      result = await handleReadFile(args);
      break;
  • Helper function for truncating large file contents to fit response limits, used in fast_read_file handler.
    function truncateContent(content: string, maxSize: number = CLAUDE_MAX_RESPONSE_SIZE) {
      const contentBytes = Buffer.byteLength(content, 'utf8');
      if (contentBytes <= maxSize) {
        return { content, truncated: false };
      }
      
      let truncated = content;
      while (Buffer.byteLength(truncated, 'utf8') > maxSize) {
        truncated = truncated.slice(0, -1);
      }
      
      return {
        content: truncated,
        truncated: true,
        original_size: contentBytes,
        truncated_size: Buffer.byteLength(truncated, 'utf8')
      };
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions 'auto-chunking support', hinting at handling large files, but lacks details on permissions, rate limits, error conditions, or what 'auto-chunking' entails (e.g., chunk size, behavior). For a read operation with 8 parameters, this is insufficient behavioral context.

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 action and includes a relevant feature note. 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 8 parameters, no annotations, and no output schema, the description is incomplete. It doesn't cover return values, error handling, or the interplay of parameters (e.g., offset vs. line-based reading). For a complex tool with rich input options, more context is needed to guide effective use.

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 all parameters are documented in the schema. The description adds minimal value by implying 'auto-chunking' relates to the 'auto_chunk' parameter, but doesn't explain semantics beyond what the schema provides. Baseline 3 is appropriate as the schema does the heavy lifting.

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 ('Reads') and resource ('a file'), making the purpose evident. It also mentions 'auto-chunking support' which adds specificity. However, it doesn't explicitly differentiate from sibling tools like 'fast_read_multiple_files' or 'fast_extract_lines', which would require more detail to score a 5.

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. With many sibling tools like 'fast_read_multiple_files', 'fast_extract_lines', and 'fast_get_file_info', there's no indication of context, prerequisites, or exclusions. This leaves the agent without usage direction.

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/efforthye/fast-filesystem-mcp'

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