Improve search context efficiency to prevent token overflow - #13
Merged
Conversation
Addresses feedback from issue #12 to make the MCP server more efficient and prevent token overflow errors when searching documents with OCR content. Changes: - Remove list_documents tool (rarely useful, caused unnecessary fallback) - Filter out content field from search_documents results (prevents token overflow) - Remove download_url and thumbnail_url from search results (reduces token usage) - Add comprehensive Paperless-NGX search syntax documentation to tool description - Add pagination parameters (page, page_size) to search_documents - Update all tool descriptions to remove references to list_documents This creates a more efficient workflow where LLMs search first to get document IDs and metadata, then use get_document for full details only on documents of interest. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
3 tasks
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.
$(cat <<'EOF'
Summary
Addresses feedback from issue #12 to improve context efficiency and prevent token overflow errors when searching documents with OCR content.
Changes
1. Removed
list_documentstoolsearch_documentsfailedsearch_documentswith proper query syntax2. Filter out
contentfield from search resultsget_document(id)to retrieve full details for specific documents3. Remove long URLs from search results
download_urlandthumbnail_urlfields (token-heavy)idis still included for referenceget_document4. Comprehensive search syntax documentation
Added full Paperless-NGX query language documentation to the tool description:
tag:unpaid,type:invoice,correspondent:universityterm1 AND (term2 OR term3)created:[2020 to 2024],added:yesterday,modified:todayprod*name5. Pagination support
pageandpage_sizeparameters tosearch_documents6. Updated tool descriptions
list_documentsthroughout the codebaseget_document,download_document, andbulk_edit_documentsdescriptionsImproved Workflow
This creates a more efficient pattern where LLMs:
search_documentswith proper query syntax → get document IDs and metadataget_documentonly for documents of interestThis prevents token overflow while maintaining full functionality.
Testing
Closes #12
🤖 Generated with Claude Code
EOF
)
💻 View my work • 👤 Initiated by @nloui • About Codegen
⛔ Remove Codegen from PR • 🚫 Ban action checks