fix(mcp): filterByFilepaths now accepts regular expressions#1008
fix(mcp): filterByFilepaths now accepts regular expressions#1008brendan-kellam merged 6 commits intomainfrom
Conversation
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughSearch-file filtering was changed so filterByFilepaths values are treated as regular expressions matched against full file paths; code and descriptive text were updated to stop escaping provided filepaths before inserting them into file: filters. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@CHANGELOG.md`:
- Around line 10-11: The changelog entry for `filterByFilepaths` in the MCP
`search_code` tool is a bug fix and should be moved from the `### Changed`
section to `### Fixed`; update the header for that bullet to `### Fixed` (or
move the bullet into the existing `Fixed` section) and ensure the `-
filterByFilepaths ...` line appears at the bottom of the `Fixed` section per
CHANGELOG/CLAUDE.md conventions, preserving the PR/issue link and exact wording.
In `@packages/web/src/features/mcp/server.ts`:
- Line 150: The filepath filter in packages/web/src/features/mcp/server.ts
currently treats values as regexes; make it consistent with the other builders
by escaping filepaths as literal strings before composing the query: when
building the clause that uses filterByFilepaths (the line constructing query
with `file:${filepaths.join(' or file:')}`), map each filepath through
escapeStringRegexp(file) (the same helper used in
packages/web/src/features/chat/tools.ts and packages/mcp/src/index.ts) and then
join; ensure this mirrors how repos are escaped so all three query builders use
escaped literal filepaths.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 008345f1-c9be-4be9-9e3f-fd6ffdbf76e1
📒 Files selected for processing (3)
CHANGELOG.mdCLAUDE.mdpackages/web/src/features/mcp/server.ts
💤 Files with no reviewable changes (1)
- CLAUDE.md
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Summary
filterByFilepathsin thesearch_codetool previously escaped filepath strings, treating them as literals. It now passes them directly as regular expressions matched against the full file path.Test plan
filterByFilepaths(e.g.,\.ts$) correctly filter resultsFixes #928
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
filterByFilepathsin MCP search now treats provided values as regular expressions matched against full file paths, allowing more flexible filtering.Documentation