Change grep default behavior to search tools only#101
Merged
jancurn merged 11 commits intofeat/grep-cmdfrom Mar 24, 2026
Merged
Change grep default behavior to search tools only#101jancurn merged 11 commits intofeat/grep-cmdfrom
jancurn merged 11 commits intofeat/grep-cmdfrom
Conversation
By default, grep now searches only tools. Users must explicitly pass --resources and/or --prompts to include those types in search results. When --tools is combined with other flags, it behaves as an explicit opt-in just like the others. https://claude.ai/code/session_016JBmUAMywHLhbJWq94JV3J
Tools are now always searched by default (additive model): - No flags → tools only - --resources → tools + resources - --prompts → tools + prompts - --no-tools --resources → resources only Also adds comprehensive e2e tests for grep covering default behavior, opt-in flags, regex, case sensitivity, and JSON output. https://claude.ai/code/session_016JBmUAMywHLhbJWq94JV3J
No flags → tools only (default). Specifying --resources or --prompts searches exactly those types, skipping tools. Use --tools alongside other flags to include tools explicitly. Updated e2e tests to match. https://claude.ai/code/session_016JBmUAMywHLhbJWq94JV3J
Session names in sessions.json already include the @ prefix (e.g. "@test"), but grepAllSessions was prepending another @, producing "@@test" which failed to resolve. Now correctly checks for existing prefix. Also changed --tools/--resources/--prompts to explicit selection model: specifying any flag searches exactly those types, default is tools only. https://claude.ai/code/session_016JBmUAMywHLhbJWq94JV3J
…ailable sessions The grep matcher now builds searchable text as "@session/item-name <JSON schema>" so patterns can match session names, tool parameters, and other schema metadata. Unavailable sessions (crashed, disconnected, etc.) are now displayed with their status instead of being silently skipped. https://claude.ai/code/session_016JBmUAMywHLhbJWq94JV3J
Limits the number of results shown. The total match count is still reported so users know how many were omitted. Works for both single-session and multi-session grep, with the limit applied globally across sessions. https://claude.ai/code/session_016JBmUAMywHLhbJWq94JV3J
- Add test/e2e/suites/basic/grep-global.test.sh covering mcpc grep <pattern> across all active sessions (multi-session search, type flags, regex, case sensitivity, JSON output, --max-results, no-sessions edge case) - Add grep section to README with usage examples - Add grep to command listings in README help block - Remove per-session "(N matches)" suffix from global grep human output https://claude.ai/code/session_016JBmUAMywHLhbJWq94JV3J
The test's "no sessions" assertions at the end could fail when other parallel tests had active sessions with matching tools in the shared home directory. https://claude.ai/code/session_016JBmUAMywHLhbJWq94JV3J
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
Modified the
grepcommand to search only tools by default, making--resourcesand--promptsopt-in filters rather than included by default. This provides a more focused search experience and aligns with the principle of least surprise.Key Changes
grepnow searches tools only when no type flags are specified--resourcesand--promptsmust be explicitly provided to include those typesgetSearchTypes()function to explicitly handle the default case where only tools are searchedImplementation Details
getSearchTypes()function now uses a ternary operator to clearly distinguish between "any filter specified" and "default behavior" casesgrepcommands was updated consistentlygrepcommand and session-specific@session grepcommandshttps://claude.ai/code/session_016JBmUAMywHLhbJWq94JV3J