Skip to content

Commit ca63bf2

Browse files
fix(mcp): filterByFilepaths now accepts regular expressions (#1008)
* fix(mcp): clarify filterByFilepaths accepts regular expressions Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * chore: update mcp CHANGELOG for #1008 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * chore: update CHANGELOG to reflect behavior change in filterByFilepaths Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * chore: move CHANGELOG entry to main changelog Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * update claude.md * fix(web): filterByFilepaths in chat tool now accepts regular expressions Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 5b55f96 commit ca63bf2

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Changed
11+
- `filterByFilepaths` in the MCP `search_code` tool now accepts regular expressions matched against the full file path, instead of treating values as escaped literals. [#1008](https://github.com/sourcebot-dev/sourcebot/pull/1008)
12+
1013
## [4.15.7] - 2026-03-16
1114

1215
### Added

CLAUDE.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,5 @@ PR description:
247247

248248
After the PR is created:
249249
- Update CHANGELOG.md with an entry under `[Unreleased]` linking to the new PR. New entries should be placed at the bottom of their section.
250-
- If the change touches `packages/mcp`, update `packages/mcp/CHANGELOG.md` instead
251250
- Do NOT add a CHANGELOG entry for documentation-only changes (e.g., changes only in `docs/`)
252251
- Enterprise-only features (gated by an entitlement) should be prefixed with `[EE]` in the CHANGELOG entry (e.g., `- [EE] Added support for ...`)

packages/web/src/features/chat/tools.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export const createCodeSearchTool = (selectedRepos: string[]) => tool({
166166
.optional(),
167167
filterByFilepaths: z
168168
.array(z.string())
169-
.describe(`Scope the search to the provided filepaths.`)
169+
.describe(`Scope the search to the provided filepaths. Each filepath is a regular expression matched against the full file path.`)
170170
.optional(),
171171
caseSensitive: z
172172
.boolean()
@@ -206,7 +206,7 @@ export const createCodeSearchTool = (selectedRepos: string[]) => tool({
206206
}
207207

208208
if (filepaths.length > 0) {
209-
query += ` (file:${filepaths.map(filepath => escapeStringRegexp(filepath)).join(' or file:')})`;
209+
query += ` (file:${filepaths.join(' or file:')})`;
210210
}
211211

212212
if (ref) {

packages/web/src/features/mcp/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export function createMcpServer(): McpServer {
9898
.optional(),
9999
filterByFilepaths: z
100100
.array(z.string())
101-
.describe(`Scope the search to the provided filepaths.`)
101+
.describe(`Scope the search to the provided filepaths. Each filepath is a regular expression matched against the full file path.`)
102102
.optional(),
103103
caseSensitive: z
104104
.boolean()
@@ -147,7 +147,7 @@ export function createMcpServer(): McpServer {
147147
query += ` (lang:${languages.join(' or lang:')})`;
148148
}
149149
if (filepaths.length > 0) {
150-
query += ` (file:${filepaths.map(fp => escapeStringRegexp(fp)).join(' or file:')})`;
150+
query += ` (file:${filepaths.join(' or file:')})`;
151151
}
152152
if (ref) {
153153
query += ` ( rev:${ref} )`;

0 commit comments

Comments
 (0)