mcp-searxng 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/http-server.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/types.js +4 -3
- package/dist/url-reader.js +10 -3
- package/package.json +1 -1
package/dist/http-server.js
CHANGED
|
@@ -21,7 +21,7 @@ export async function createHttpServer(createMcpServer) {
|
|
|
21
21
|
callback(null, false);
|
|
22
22
|
},
|
|
23
23
|
exposedHeaders: ["Mcp-Session-Id"],
|
|
24
|
-
allowedHeaders: ["Content-Type", "mcp-session-id", "authorization"],
|
|
24
|
+
allowedHeaders: ["Content-Type", "mcp-session-id", "authorization", "mcp-protocol-version"],
|
|
25
25
|
}));
|
|
26
26
|
function rejectUnauthorized(res) {
|
|
27
27
|
res.status(401).json({
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
-
declare const packageVersion = "1.0.
|
|
3
|
+
declare const packageVersion = "1.0.5";
|
|
4
4
|
export { packageVersion };
|
|
5
5
|
export declare function isWebUrlReadArgs(args: unknown): args is {
|
|
6
6
|
url: string;
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import { fetchAndConvertToMarkdown } from "./url-reader.js";
|
|
|
10
10
|
import { createConfigResource, createHelpResource } from "./resources.js";
|
|
11
11
|
import { createHttpServer } from "./http-server.js";
|
|
12
12
|
// Use a static version string that will be updated by the version script
|
|
13
|
-
const packageVersion = "1.0.
|
|
13
|
+
const packageVersion = "1.0.5";
|
|
14
14
|
// Export the version for use in other modules
|
|
15
15
|
export { packageVersion };
|
|
16
16
|
// Type guard for URL reading args
|
package/dist/types.js
CHANGED
|
@@ -6,8 +6,9 @@ export function isSearXNGWebSearchArgs(args) {
|
|
|
6
6
|
}
|
|
7
7
|
export const WEB_SEARCH_TOOL = {
|
|
8
8
|
name: "searxng_web_search",
|
|
9
|
-
description: "
|
|
10
|
-
"
|
|
9
|
+
description: "Searches the web using SearXNG. " +
|
|
10
|
+
"CRITICAL: The parameter name MUST be exactly `query` (not `prompt`, `q`, or any other name). " +
|
|
11
|
+
"Pass your search terms as the value of the `query` parameter.",
|
|
11
12
|
annotations: {
|
|
12
13
|
readOnlyHint: true,
|
|
13
14
|
openWorldHint: true,
|
|
@@ -17,7 +18,7 @@ export const WEB_SEARCH_TOOL = {
|
|
|
17
18
|
properties: {
|
|
18
19
|
query: {
|
|
19
20
|
type: "string",
|
|
20
|
-
description: "The search query. This is the
|
|
21
|
+
description: "The search query string. This is the required parameter name — use exactly `query`, not `prompt` or `q`.",
|
|
21
22
|
},
|
|
22
23
|
pageno: {
|
|
23
24
|
type: "number",
|
package/dist/url-reader.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isIP } from "node:net";
|
|
2
2
|
import { NodeHtmlMarkdown } from "node-html-markdown";
|
|
3
|
+
import { fetch as undiciFetch } from "undici";
|
|
3
4
|
import { createProxyAgent, createDefaultAgent, ProxyType } from "./proxy.js";
|
|
4
5
|
import { logMessage } from "./logging.js";
|
|
5
6
|
import { urlCache } from "./cache.js";
|
|
@@ -57,9 +58,12 @@ function applyCharacterPagination(content, startChar = 0, maxLength) {
|
|
|
57
58
|
const end = maxLength ? Math.min(content.length, start + maxLength) : content.length;
|
|
58
59
|
return content.slice(start, end);
|
|
59
60
|
}
|
|
61
|
+
function escapeRegExp(str) {
|
|
62
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
63
|
+
}
|
|
60
64
|
function extractSection(markdownContent, sectionHeading) {
|
|
61
65
|
const lines = markdownContent.split('\n');
|
|
62
|
-
const sectionRegex = new RegExp(`^#{1,6}
|
|
66
|
+
const sectionRegex = new RegExp(`^#{1,6}\\s*.*${escapeRegExp(sectionHeading)}.*$`, 'i');
|
|
63
67
|
let startIndex = -1;
|
|
64
68
|
let currentLevel = 0;
|
|
65
69
|
// Find the section start
|
|
@@ -192,8 +196,11 @@ export async function fetchAndConvertToMarkdown(mcpServer, url, timeoutMs = 1000
|
|
|
192
196
|
}
|
|
193
197
|
let response;
|
|
194
198
|
try {
|
|
195
|
-
// Fetch the URL with the abort signal
|
|
196
|
-
|
|
199
|
+
// Fetch the URL with the abort signal.
|
|
200
|
+
// Use undici's own fetch so it shares the same internal version as the
|
|
201
|
+
// Agent/ProxyAgent dispatcher — avoids the Node.js bundled-undici vs
|
|
202
|
+
// npm-undici version mismatch that breaks Content-Encoding decompression.
|
|
203
|
+
response = await undiciFetch(url, requestOptions);
|
|
197
204
|
}
|
|
198
205
|
catch (error) {
|
|
199
206
|
const context = {
|