MCPcopy Index your code
hub / github.com/continuedev/continue / fetchUrlContentImpl

Function fetchUrlContentImpl

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

Source from the content-addressed store, hash-verified

5const DEFAULT_FETCH_URL_CHAR_LIMIT = 20000;
6
7export const fetchUrlContentImpl: ToolImpl = async (args, extras) => {
8 const url = getStringArg(args, "url");
9
10 const contextItems = await getUrlContextItems(url, extras.fetch);
11
12 // Track truncated content
13 const truncatedUrls: string[] = [];
14
15 // Check and truncate each context item
16 const processedItems = contextItems.map((item) => {
17 if (item.content.length > DEFAULT_FETCH_URL_CHAR_LIMIT) {
18 truncatedUrls.push(url);
19 return {
20 ...item,
21 content: item.content.substring(0, DEFAULT_FETCH_URL_CHAR_LIMIT),
22 };
23 }
24 return item;
25 });
26
27 // Add truncation warning if needed
28 if (truncatedUrls.length > 0) {
29 processedItems.push({
30 name: "Truncation warning",
31 description: "",
32 content: `The content from ${truncatedUrls.join(", ")} was truncated because it exceeded the ${DEFAULT_FETCH_URL_CHAR_LIMIT} character limit. If you need more content, consider fetching specific sections or using a more targeted approach.`,
33 });
34 }
35
36 return processedItems;
37};

Callers 3

callBuiltInToolFunction · 0.90
fetch.tsFile · 0.85

Calls 3

getStringArgFunction · 0.90
getUrlContextItemsFunction · 0.90
pushMethod · 0.65

Tested by

no test coverage detected