Skip to content

fix(mcp): filterByFilepaths now accepts regular expressions#1008

Merged
brendan-kellam merged 6 commits intomainfrom
brendan/fix-filepath-filter-regex-SOU-556
Mar 16, 2026
Merged

fix(mcp): filterByFilepaths now accepts regular expressions#1008
brendan-kellam merged 6 commits intomainfrom
brendan/fix-filepath-filter-regex-SOU-556

Conversation

@brendan-kellam
Copy link
Contributor

@brendan-kellam brendan-kellam commented Mar 16, 2026

Summary

  • filterByFilepaths in the search_code tool previously escaped filepath strings, treating them as literals. It now passes them directly as regular expressions matched against the full file path.
  • Updated the parameter description to reflect this behavior.

Test plan

  • Verify that regex patterns in filterByFilepaths (e.g., \.ts$) correctly filter results

Fixes #928

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • filterByFilepaths in MCP search now treats provided values as regular expressions matched against full file paths, allowing more flexible filtering.
  • Documentation

    • Updated tool descriptions and changelog wording to clarify the regex-based filepath matching behavior.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 16, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4a0b211b-3476-4a3b-b142-5e04fefa26aa

📥 Commits

Reviewing files that changed from the base of the PR and between b7e1c38 and 2d3d690.

📒 Files selected for processing (1)
  • packages/web/src/features/chat/tools.ts

Walkthrough

Search-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

Cohort / File(s) Summary
Documentation & Changelogs
CHANGELOG.md, CLAUDE.md
Added changelog note about filterByFilepaths now using regexes; removed an outdated guideline about updating MCP changelogs.
MCP Search Implementation
packages/web/src/features/mcp/server.ts, packages/web/src/features/chat/tools.ts
Updated tool/input descriptions to state filepaths are regexes against full path; stopped escaping filepaths when constructing file: filters and now join raw filepaths directly in the query.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • msukkari
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR documentation and code changes provide clarification about filterByFilepaths accepting regular expressions, but the core issue (#928) about filterByFilepaths returning no results appears unresolved by documentation alone. Verify that the code changes in server.ts fix the underlying bug causing zero results, not just document the expected behavior. The file path escape removal suggests a fix, but functional testing is needed.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately describes the main change: clarifying that filterByFilepaths now accepts regular expressions, which is the primary objective of this changeset.
Out of Scope Changes check ✅ Passed All changes (CHANGELOG.md updates, CLAUDE.md documentation removal, and server.ts modifications) are directly related to the filterByFilepaths regex feature and issue #928.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch brendan/fix-filepath-filter-regex-SOU-556
📝 Coding Plan
  • Generate coding plan for human review comments

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@brendan-kellam brendan-kellam changed the title fix(mcp): clarify filterByFilepaths accepts regular expressions fix(mcp): filterByFilepaths now accepts regular expressions Mar 16, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5b55f96 and b7e1c38.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • CLAUDE.md
  • packages/web/src/features/mcp/server.ts
💤 Files with no reviewable changes (1)
  • CLAUDE.md

@brendan-kellam brendan-kellam merged commit ca63bf2 into main Mar 16, 2026
6 of 7 checks passed
@brendan-kellam brendan-kellam deleted the brendan/fix-filepath-filter-regex-SOU-556 branch March 16, 2026 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] filterByFilepaths in a search query not working in copilot, the search returns no results

1 participant