Skip to content

fix(filesystem): handle explicit read line limits#4178

Open
pragnyanramtha wants to merge 1 commit into
modelcontextprotocol:mainfrom
pragnyanramtha:codex/fix-filesystem-line-limits
Open

fix(filesystem): handle explicit read line limits#4178
pragnyanramtha wants to merge 1 commit into
modelcontextprotocol:mainfrom
pragnyanramtha:codex/fix-filesystem-line-limits

Conversation

@pragnyanramtha
Copy link
Copy Markdown

Summary

  • Treat head: 0 and tail: 0 as explicit read_text_file limits instead of falling through to full-file reads.
  • Reject fractional line limits for head and tail at tool input validation time.
  • Add MCP client integration coverage for zero, simultaneous zero, and fractional line-limit arguments.

Root Cause

readTextFileHandler used truthiness checks for optional head and tail arguments. Because 0 is falsy, a caller requesting zero lines received the complete file instead. The schema also accepted any number, so fractional values could be forwarded to line-reading helpers even though line counts should be integral.

Validation

  • npm run build -w src/filesystem
  • npm exec -w src/filesystem -- vitest run __tests__/structured-content.test.ts
  • npm test -w src/filesystem

@pragnyanramtha pragnyanramtha marked this pull request as ready for review May 17, 2026 01:47
Copilot AI review requested due to automatic review settings May 17, 2026 01:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@BossChaos
Copy link
Copy Markdown

Code Review

PR: fix(filesystem): handle explicit read line limits by @pragnyanramtha

  • ✅ Bug/security fix

Wallet: 0xdaE5d307339074A24F579dB48e7c639359D94904

Code review for MCP servers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants