Heuristic:0xKoda WireMCP Graceful Degradation
| Knowledge Sources | |
|---|---|
| Domains | Optimization, Debugging, Threat_Intelligence |
| Last Updated | 2026-10-28 00:00 GMT |
Overview
Fall back to an empty blacklist array when the URLhaus HTTP fetch fails, so the MCP threat-check tool still returns a (degraded) response instead of erroring out.
Description
The graceful degradation heuristic wraps the URLhaus `axios.get` call in a try/catch that sets `urlhausData = []` on any fetch failure (network error, DNS failure, timeout, TLS error). Downstream, the IP intersection (`ips.filter(ip => urlhausData.includes(ip))` or `urlhausData.includes(ip)`) naturally produces zero matches against an empty array, so the tool reports "No threats detected" rather than throwing. This keeps the MCP tool response contract intact (a success envelope, not an error envelope) while silently disabling detection. The failure is logged to stderr via `console.error` so it is observable but non-fatal.
Usage
Use this heuristic when a tool depends on an external network feed that may be unreachable, but the tool should still return a usable (if degraded) result. It applies to the `check_threats` and `check_ip_threats` tools, which fetch the URLhaus blacklist.
The Insight (Rule of Thumb)
- Action: Wrap the external feed fetch in `try { ... } catch (e) { urlhausData = []; }` and let downstream set-intersection logic treat an empty feed as "no matches".
- Value: Empty array `[]` as the fallback feed (not `null`, not `undefined`).
- Trade-off: The tool silently reports no threats when the feed is unreachable, which can be mistaken for a clean bill of health. Gains: the tool never crashes on a transient network error; the MCP response envelope stays a success.
- Observability: Always log the failure to stderr (`console.error(`Failed to fetch URLhaus data: ${e.message}`)`) so degradation is diagnosable.
Reasoning
A threat-intelligence feed is an enhancement, not a precondition, for returning a capture's IPs — the tool can still report which IPs were observed. Crashing on a feed outage would make the entire `check_threats` tool unusable during network partitions, defeating the capture's primary value. An empty-array fallback composes cleanly with the set-intersection logic (`filter`/`includes` over an empty array yields nothing) without special-casing. The key risk is silent false negatives: "No threats detected" is indistinguishable to the LLM from a genuine clean result. Mitigation is the stderr log, which is visible to operators but not to the MCP client.
Code Evidence
Degrade-to-empty-array in `check_threats` from `index.js:210-230`:
let urlhausData;
let urlhausThreats = [];
try {
const response = await axios.get(urlhausUrl);
// ... extract IPs from response.data ...
urlhausThreats = ips.filter(ip => urlhausData.includes(ip));
} catch (e) {
console.error(`Failed to fetch URLhaus data: ${e.message}`);
urlhausData = [];
}
Same pattern in `check_ip_threats` from `index.js:263-283`:
let urlhausData;
let isThreat = false;
try {
const response = await axios.get(urlhausUrl);
// ... extract IPs from response.data ...
isThreat = urlhausData.includes(ip);
} catch (e) {
console.error(`Failed to fetch URLhaus data: ${e.message}`);
urlhausData = [];
}