MCPcopy
hub / github.com/codeaashu/claude-code / call

Function call

src/tools/WebFetchTool/WebFetchTool.ts:208–299  ·  view source on GitHub ↗
(
    { url, prompt },
    { abortController, options: { isNonInteractiveSession } },
  )

Source from the content-addressed store, hash-verified

206 renderToolUseProgressMessage,
207 renderToolResultMessage,
208 async call(
209 { url, prompt },
210 { abortController, options: { isNonInteractiveSession } },
211 ) {
212 const start = Date.now()
213
214 const response = await getURLMarkdownContent(url, abortController)
215
216 // Check if we got a redirect to a different host
217 if ('type' in response && response.type === 'redirect') {
218 const statusText =
219 response.statusCode === 301
220 ? 'Moved Permanently'
221 : response.statusCode === 308
222 ? 'Permanent Redirect'
223 : response.statusCode === 307
224 ? 'Temporary Redirect'
225 : 'Found'
226
227 const message = `REDIRECT DETECTED: The URL redirects to a different host.
228
229Original URL: ${response.originalUrl}
230Redirect URL: ${response.redirectUrl}
231Status: ${response.statusCode} ${statusText}
232
233To complete your request, I need to fetch content from the redirected URL. Please use WebFetch again with these parameters:
234- url: "${response.redirectUrl}"
235- prompt: "${prompt}"`
236
237 const output: Output = {
238 bytes: Buffer.byteLength(message),
239 code: response.statusCode,
240 codeText: statusText,
241 result: message,
242 durationMs: Date.now() - start,
243 url,
244 }
245
246 return {
247 data: output,
248 }
249 }
250
251 const {
252 content,
253 bytes,
254 code,
255 codeText,
256 contentType,
257 persistedPath,
258 persistedSize,
259 } = response as FetchedContent
260
261 const isPreapproved = isPreapprovedUrl(url)
262
263 let result: string
264 if (
265 isPreapproved &&

Callers

nothing calls this directly

Calls 4

getURLMarkdownContentFunction · 0.85
isPreapprovedUrlFunction · 0.85
applyPromptToMarkdownFunction · 0.85
formatFileSizeFunction · 0.85

Tested by

no test coverage detected