feat(filesystem): add head/tail support to read_multiple_files#4025
Open
factspark23-hash wants to merge 1 commit intomodelcontextprotocol:mainfrom
Open
feat(filesystem): add head/tail support to read_multiple_files#4025factspark23-hash wants to merge 1 commit intomodelcontextprotocol:mainfrom
factspark23-hash wants to merge 1 commit intomodelcontextprotocol:mainfrom
Conversation
Add per-file head/tail line limits when reading multiple files. - head: returns only the first N lines of each file - tail: returns only the last N lines of each file - Cannot use both simultaneously (throws error) - Backward compatible: omitting both reads full files Useful for previewing large log files, checking file headers, or sampling content from many files at once.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Add optional
headandtailparameters to theread_multiple_filestool, allowing line-limited reads across multiple files at once.Why
The single-file
read_text_filealready supportsheadandtail, butread_multiple_filesdoes not. When working with multiple large files (logs, configs, data files), agents often only need the first/last N lines of each.Currently the only option is to call
read_text_filewith head/tail N times, which is slower and more verbose.How
head— returns only the first N lines of each filetail— returns only the last N lines of each fileread_text_file)Changes
src/filesystem/index.ts:headandtailtoReadMultipleFilesArgsSchemaheadFile/tailFilefrom lib.tsread_text_file)