You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Register the search tool once during plugin initialization
43
45
server.tool(
44
46
"search-tool-result",
45
-
`Search for text patterns in files and directories. Use this to find specific content, code, or information within files.`,
47
+
`Search for text patterns in files and directories. Use this to find specific content, code, or information within files. Provide a simple literal string or a regular expression. If your pattern is a regex, ensure it's valid; otherwise use quotes or escape special characters to treat it as a literal string.
48
+
Only search within the allowed directory: ${allowedSearchDir}`,
"Text to search for. Can be a plain string or a regular expression. For regexes, don't include delimiters (e.g. use `^foo` not `/^foo/`). If you get a regex parse error, try escaping special chars or using a simpler literal search.",
52
56
},
53
57
path: {
54
58
type: "string",
55
-
description: "File or folder path (optional)",
59
+
description:
60
+
"File or folder path to limit the search (optional). Must be within the allowed directory.",
56
61
},
57
62
maxResults: {
58
63
type: "number",
59
-
description: "Max results (optional)",
64
+
description:
65
+
"Maximum number of matches to return (optional). Lower this to reduce output size and runtime.",
`❌ Path "${args.path}" not allowed. Must be within: ${allowedSearchDir}`,
89
116
},
90
117
],
118
+
isError: true,
91
119
};
92
120
}
93
121
}
94
122
95
123
constsearchPath=requestedPath;
96
124
125
+
// Reject overly-broad patterns to avoid expensive/unsafe searches
126
+
constrawPattern=args.pattern??"";
127
+
if(isBroad(rawPattern)){
128
+
return{
129
+
content: [
130
+
{
131
+
type: "text",
132
+
text:
133
+
`❌ Search pattern too broad: "${rawPattern}"\nProvide a more specific pattern (e.g. include a filename fragment, a keyword, or limit with the "path" parameter). Avoid patterns that only contain wildcards like "*" or ".*".`,
134
+
},
135
+
],
136
+
isError: true,
137
+
};
138
+
}
139
+
97
140
// Create timeout promise and keep reference to clear it later
0 commit comments