feat(mcp): token budget management with progressive disclosure#76
Merged
feat(mcp): token budget management with progressive disclosure#76
Conversation
Implements #71 - Richer Search Results (sub-issue 5/5) Changes: - Add tokenBudget parameter to dev_search tool (500-10000, default: 2000/5000) - Add DetailLevel type: 'full' | 'signature' | 'minimal' - Add progressive disclosure options to FormatterOptions: - progressiveDisclosure: enable/disable (default: true) - fullDetailCount: top N results with full detail (default: 3) - signatureDetailCount: next M results with signatures (default: 4) CompactFormatter: - formatResultWithDetail() for detail-level-aware formatting - getDetailLevel() determines detail based on position and budget - Truncation notice when budget exceeded VerboseFormatter: - Same progressive disclosure support - Full: snippet + imports + signature + metadata - Signature: signature + metadata (no snippet) - Minimal: header + location only SearchAdapter: - tokenBudget parameter in tool definition - Creates formatter with custom budget when specified - Enables snippets/imports by default Testing: - 10 new tests for token budget management - All 1292 tests passing Closes #71
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.
Summary
Implements #71 - Token budget management for search results (sub-issue 5/5 of Epic #66)
Changes
New Parameters
tokenBudgetparameter todev_searchtool (500-10000 tokens)Progressive Disclosure Strategy
Formatter Options
Added to
FormatterOptions:progressiveDisclosure: Enable/disable (default: true)fullDetailCount: Top N results with full detail (default: 3)signatureDetailCount: Next M results with signatures (default: 4)DetailLeveltype:'full' | 'signature' | 'minimal'Token Estimation
Improved
estimateTokensForText()with:estimateCodeRatio()for code-heavy text detectionTesting
Example Output
With budget of 2000 tokens and 10 results:
Closes #71