MCPcopy Create free account
hub / github.com/Noumena-Network/code / checkDomainBlocklist

Function checkDomainBlocklist

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

Source from the content-addressed store, hash-verified

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

Callers 2

utils.test.tsFile · 0.85
getURLMarkdownContentFunction · 0.85

Calls 5

buildNoumenaPlatformUrlFunction · 0.85
setMethod · 0.80
logErrorFunction · 0.50
hasMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected