Skip to content

Add offset/continuation support for search_pdf when results are too large #4

Description

@vlad-ds

Problem

The search_pdf tool can return responses that are too large for the MCP context when searching yields many matches across a large PDF. This causes failures when the response exceeds context limits, preventing users from seeing all search results.

Proposed Solution

Add offset/continuation parameters to search_pdf to enable paginated search results:

  • offset: Starting index for search results (default: 0)
  • limit: Maximum number of matches to return (default: current behavior)
  • Include metadata about total matches found and whether more are available
  • Maintain consistent search state for pagination

Example Usage

// Get first 20 search results
search_pdf({ path: "document.pdf", search_pattern: "budget", offset: 0, limit: 20 })

// Get next 20 search results
search_pdf({ path: "document.pdf", search_pattern: "budget", offset: 20, limit: 20 })

Implementation Notes

  • Should work with existing max_results parameter (offset within max_results)
  • Include response metadata:
    • total_matches_found: Total number of matches discovered
    • has_more_results: Boolean indicating if more results are available
    • next_offset: Suggested offset for next request
  • Consider caching search results temporarily to avoid re-scanning entire PDF
  • Ensure consistent ordering of results across paginated requests

Related

This complements the existing max_results and max_pages_scanned parameters but focuses on chunking the response rather than limiting the search scope.

Priority

Medium - affects usability when searching large PDFs with many matches

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions