Skip to content

Commit 2ec0465

Browse files
more feedback
1 parent d09d519 commit 2ec0465

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/mcp/src/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ server.tool(
2929
query: z
3030
.string()
3131
.describe(`The search pattern to match against code contents. Do not escape quotes in your query.`)
32-
// Wrap in quotes so the query is treated as a literal phrase (like grep).
33-
.transform((val) => `"${val.replace(/"/g, '\\"')}"`),
32+
// Escape backslashes first, then quotes, and wrap in double quotes
33+
// so the query is treated as a literal phrase (like grep).
34+
.transform((val) => {
35+
const escaped = val.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
36+
return `"${escaped}"`;
37+
}),
3438
useRegex: z
3539
.boolean()
3640
.describe(`Whether to use regular expression matching to match the search query against code contents. When false, substring matching is used. (default: false)`)

0 commit comments

Comments
 (0)