Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(web-search): exclude fallback-only containers from prose

Alfredo Lopeze7aefcf2cfda
diff --git a/mcp-servers/web-search/README.md b/mcp-servers/web-search/README.md
index e3aea01d6..6a7962c64 100644
--- a/mcp-servers/web-search/README.md
+++ b/mcp-servers/web-search/README.md
@@ -55,6 +55,9 @@ body limit before and after decompression, and four active calls per process.
Additional calls fail immediately. `maxChars` remains the output display limit;
it is not the download limit. Redirect and error bodies are destroyed without
reading them. Encodings supported: identity, gzip, deflate and br.
+DNS resolution is additionally bounded by Node/c-ares' effective per-query
+ceiling (about five seconds on current Node); the absolute operation deadline
+remains the outer bound.
Errors expose only a stable code, never upstream details: `invalid_url`,
`invalid_max_chars`, `destination_blocked`, `redirect_limit`,
@@ -63,8 +66,9 @@ Errors expose only a stable code, never upstream details: `invalid_url`,
not parse the older `Error fetching page:` prefix; it no longer exists.
Private destinations and oversized documents previously accepted are
intentionally rejected. Text extraction ignores comments and non-page prose in
-script, style, textarea and similar containers. It is a bounded lightweight
-scan, not a browser DOM; HTML entities remain verbatim. Self-closing raw-text
+script, style, textarea, template, noscript and similar containers. It is a
+bounded lightweight scan, not a browser DOM; HTML entities remain verbatim.
+Self-closing raw-text
elements are recognized when the final response declares XML/XHTML; in HTML
syntax, a trailing slash does not close them.
diff --git a/mcp-servers/web-search/package-lock.json b/mcp-servers/web-search/package-lock.json
index fd96b951e..28bdbe7d4 100644
--- a/mcp-servers/web-search/package-lock.json
+++ b/mcp-servers/web-search/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "@clerum/web-search-mcp",
- "version": "1.0.18",
+ "version": "1.0.19",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@clerum/web-search-mcp",
- "version": "1.0.18",
+ "version": "1.0.19",
"dependencies": {
"@modelcontextprotocol/sdk": "^1.12.1",
"express": "^4.21.2"
diff --git a/mcp-servers/web-search/package.json b/mcp-servers/web-search/package.json
index f15260913..869be0c80 100644
--- a/mcp-servers/web-search/package.json
+++ b/mcp-servers/web-search/package.json
@@ -1,6 +1,6 @@
{
"name": "@clerum/web-search-mcp",
- "version": "1.0.18",
+ "version": "1.0.19",
"type": "module",
"main": "dist/index.js",
"scripts": {
diff --git a/mcp-servers/web-search/src/fetchPage.ts b/mcp-servers/web-search/src/fetchPage.ts
index d89bd228a..bb80fc25f 100644
--- a/mcp-servers/web-search/src/fetchPage.ts
+++ b/mcp-servers/web-search/src/fetchPage.ts
@@ -54,7 +54,17 @@ function closingTag(html: string, lower: string, name: string, from: number) {
return undefined
}
-const inertText = new Set(['script', 'style', 'textarea', 'xmp', 'iframe', 'noembed', 'noframes'])
+const inertText = new Set([
+ 'script',
+ 'style',
+ 'textarea',
+ 'xmp',
+ 'iframe',
+ 'noembed',
+ 'noframes',
+ 'noscript',
+ 'template',
+])
/** Extract visible page prose and the first real title in linear time. */
function scanPage(html: string, xmlSyntax = false): { title: string; content: string } {
diff --git a/mcp-servers/web-search/test/dns-fixture.mjs b/mcp-servers/web-search/test/dns-fixture.mjs
index 56939bc2e..f2b887a02 100644
--- a/mcp-servers/web-search/test/dns-fixture.mjs
+++ b/mcp-servers/web-search/test/dns-fixture.mjs
@@ -20,6 +20,8 @@ export async function startDnsFixture() {
const name = labels.join('.')
const key = name + ':' + type
queries.set(key, (queries.get(key) ?? 0) + 1)
+ // Deliberately unanswered: a real c-ares timeout producer.
+ if (name === 'timeout.test') return
let data
if (name.endsWith('.test')) {
if (type === 1)
diff --git a/mcp-servers/web-search/test/fetchPage.test.mjs b/mcp-servers/web-search/test/fetchPage.test.mjs
index 52354a915..b7a43e5ef 100644
--- a/mcp-servers/web-search/test/fetchPage.test.mjs
+++ b/mcp-servers/web-search/test/fetchPage.test.mjs
@@ -305,6 +305,18 @@ test('comments and inert raw text do not supply a title or page prose', async t
})
})
+test('template and noscript fallback content are not page prose', async t => {
+ upstream(t, [
+ {
+ body: '<template><p>Template fallback</p></template><noscript>Enable JavaScript</noscript><p>Visible</p>',
+ },
+ ])
+ assert.deepEqual(await fetchPage('http://8.8.8.8', 100), {
+ title: '',
+ content: 'Visible',
+ })
+})
+
test('quoted comment delimiters and textarea markup preserve the real title', async t => {
upstream(t, [
{
diff --git a/mcp-servers/web-search/test/mcp.network.mjs b/mcp-servers/web-search/test/mcp.network.mjs
index 75faa9270..f9da3b4aa 100644
--- a/mcp-servers/web-search/test/mcp.network.mjs
+++ b/mcp-servers/web-search/test/mcp.network.mjs
@@ -137,6 +137,17 @@ test('real DNS pins a single answer and rejects mixed public/private records', a
test('a real DNS SERVFAIL is an upstream failure', async () => {
assert.equal(errorCode(await call('http://servfail.test:8080/')), 'upstream_failure')
})
+
+test(
+ 'a real DNS timeout is bounded by the c-ares per-query ceiling',
+ { timeout: 8000 },
+ async () => {
+ const start = performance.now()
+ assert.equal(errorCode(await call('http://timeout.test:8080/')), 'upstream_failure')
+ const elapsed = performance.now() - start
+ assert.ok(elapsed >= 4000 && elapsed < 7000, `unexpected DNS timeout elapsed: ${elapsed}ms`)
+ }
+)
test('TLS validates original host and SNI, and blocks downgrade', async () => {
assert.notEqual((await call('https://fixture.test:8443/')).isError, true)
assert.equal(lastSni, 'fixture.test')