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

Function checkDomainBlocklist

src/tools/WebFetchTool/utils.ts:176–203  ·  view source on GitHub ↗
(
  domain: string,
)

Source from the content-addressed store, hash-verified

174 | { status: 'check_failed'; error: Error }
175
176export async function checkDomainBlocklist(
177 domain: string,
178): Promise<DomainCheckResult> {
179 if (DOMAIN_CHECK_CACHE.has(domain)) {
180 return { status: 'allowed' }
181 }
182 try {
183 const response = await axios.get(
184 `https://api.anthropic.com/api/web/domain_info?domain=${encodeURIComponent(domain)}`,
185 { timeout: DOMAIN_CHECK_TIMEOUT_MS },
186 )
187 if (response.status === 200) {
188 if (response.data.can_fetch === true) {
189 DOMAIN_CHECK_CACHE.set(domain, true)
190 return { status: 'allowed' }
191 }
192 return { status: 'blocked' }
193 }
194 // Non-200 status but didn't throw
195 return {
196 status: 'check_failed',
197 error: new Error(`Domain check returned status ${response.status}`),
198 }
199 } catch (e) {
200 logError(e)
201 return { status: 'check_failed', error: e as Error }
202 }
203}
204
205/**
206 * Check if a redirect is safe to follow

Callers 1

getURLMarkdownContentFunction · 0.85

Calls 4

getMethod · 0.65
logErrorFunction · 0.50
hasMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected