MCPcopy
hub / github.com/continuedev/continue / searchWebImpl

Function searchWebImpl

core/tools/implementations/searchWeb.ts:7–39  ·  view source on GitHub ↗
(args, extras)

Source from the content-addressed store, hash-verified

5const DEFAULT_WEB_SEARCH_CHAR_LIMIT = 8000;
6
7export const searchWebImpl: ToolImpl = async (args, extras) => {
8 const query = getStringArg(args, "query");
9
10 const webResults = await fetchSearchResults(query, 5, extras.fetch);
11
12 // Track truncated results
13 const truncatedResults: string[] = [];
14
15 // Check and truncate each result
16 const processedResults = webResults.map((result, index) => {
17 if (result.content.length > DEFAULT_WEB_SEARCH_CHAR_LIMIT) {
18 truncatedResults.push(
19 result.name || result.description || `Result #${index + 1}`,
20 );
21 return {
22 ...result,
23 content: result.content.substring(0, DEFAULT_WEB_SEARCH_CHAR_LIMIT),
24 };
25 }
26 return result;
27 });
28
29 // Add truncation warning if needed
30 if (truncatedResults.length > 0) {
31 processedResults.push({
32 name: "Truncation warning",
33 description: "",
34 content: `The content from the following search results was truncated because it exceeded the ${DEFAULT_WEB_SEARCH_CHAR_LIMIT} character limit: ${truncatedResults.join(", ")}. For more detailed information, consider refining your search query.`,
35 });
36 }
37
38 return processedResults;
39};

Callers 2

callBuiltInToolFunction · 0.90

Calls 3

getStringArgFunction · 0.90
fetchSearchResultsFunction · 0.90
pushMethod · 0.65

Tested by

no test coverage detected