diff --git a/CHANGELOG.md b/CHANGELOG.md index 129801c5e..5988562a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed +- `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) + ## [4.15.7] - 2026-03-16 ### Added diff --git a/CLAUDE.md b/CLAUDE.md index e1bf3918c..2fff041c8 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -247,6 +247,5 @@ PR description: After the PR is created: - Update CHANGELOG.md with an entry under `[Unreleased]` linking to the new PR. New entries should be placed at the bottom of their section. -- If the change touches `packages/mcp`, update `packages/mcp/CHANGELOG.md` instead - Do NOT add a CHANGELOG entry for documentation-only changes (e.g., changes only in `docs/`) - Enterprise-only features (gated by an entitlement) should be prefixed with `[EE]` in the CHANGELOG entry (e.g., `- [EE] Added support for ...`) diff --git a/packages/web/src/features/chat/tools.ts b/packages/web/src/features/chat/tools.ts index 3e1db4345..713f31722 100644 --- a/packages/web/src/features/chat/tools.ts +++ b/packages/web/src/features/chat/tools.ts @@ -166,7 +166,7 @@ export const createCodeSearchTool = (selectedRepos: string[]) => tool({ .optional(), filterByFilepaths: z .array(z.string()) - .describe(`Scope the search to the provided filepaths.`) + .describe(`Scope the search to the provided filepaths. Each filepath is a regular expression matched against the full file path.`) .optional(), caseSensitive: z .boolean() @@ -206,7 +206,7 @@ export const createCodeSearchTool = (selectedRepos: string[]) => tool({ } if (filepaths.length > 0) { - query += ` (file:${filepaths.map(filepath => escapeStringRegexp(filepath)).join(' or file:')})`; + query += ` (file:${filepaths.join(' or file:')})`; } if (ref) { diff --git a/packages/web/src/features/mcp/server.ts b/packages/web/src/features/mcp/server.ts index e65aa070a..8db766164 100644 --- a/packages/web/src/features/mcp/server.ts +++ b/packages/web/src/features/mcp/server.ts @@ -98,7 +98,7 @@ export function createMcpServer(): McpServer { .optional(), filterByFilepaths: z .array(z.string()) - .describe(`Scope the search to the provided filepaths.`) + .describe(`Scope the search to the provided filepaths. Each filepath is a regular expression matched against the full file path.`) .optional(), caseSensitive: z .boolean() @@ -147,7 +147,7 @@ export function createMcpServer(): McpServer { query += ` (lang:${languages.join(' or lang:')})`; } if (filepaths.length > 0) { - query += ` (file:${filepaths.map(fp => escapeStringRegexp(fp)).join(' or file:')})`; + query += ` (file:${filepaths.join(' or file:')})`; } if (ref) { query += ` ( rev:${ref} )`;