Skip to content

feat(filesystem): add read_file_lines #2102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

altrao
Copy link

@altrao altrao commented Jun 13, 2025

Description

  • read_file_lines: Reads specific lines from files with offset/limit

Server Details

  • Server: filesystem
  • Changes to: tools

Motivation and Context

Allows partial reading of files by specifying an offset and a limit when the whole file content isn't necessary.

How Has This Been Tested?

Testing completed for read_file_lines:

  1. Basic functionality:
    • Various offsets and limits
  2. Security boundaries:
    • Only works in allowed dir
  3. Edge cases:
    • Empty files
    • Offsets beyond file length
    • Large limits
    • Negative offset
    • Negative limit
    • Special characters in filenames
    • Large files (high line numbers)
    • Different file formats
  4. Error handling:
    • Invalid paths (proper error returned)
    • Invalid parameters (proper validation)

Breaking Changes

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Protocol Documentation
  • My changes follows MCP security best practices
  • I have updated the server's README accordingly
  • I have tested this with an LLM client
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have documented all environment variables and configuration options

Additional context

The implementation uses readline.craeteInterface and fs/promise.FileHandle.createReadStream for reading file's content with a stream. Please take a look at that and bring up any concern. Node isn't my safe zone but I tried handling it with some performance concerns in mind.

@altrao altrao force-pushed the read-file-lines branch from df2f234 to 3d7d5b6 Compare June 13, 2025 14:34
@olaservo olaservo added server-filesystem Reference implementation for the Filesystem MCP server - src/filesystem enhancement New feature or request labels Jun 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request server-filesystem Reference implementation for the Filesystem MCP server - src/filesystem
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants