mcp-searxng 0.4.5 → 0.4.6
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/index.js +11 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
4
4
|
import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
5
5
|
import { NodeHtmlMarkdown } from "node-html-markdown";
|
|
6
6
|
// Use a static version string that will be updated by the version script
|
|
7
|
-
const packageVersion = "0.4.
|
|
7
|
+
const packageVersion = "0.4.5";
|
|
8
8
|
const WEB_SEARCH_TOOL = {
|
|
9
9
|
name: "searxng_web_search",
|
|
10
10
|
description: "Performs a web search using the SearXNG API, ideal for general queries, news, articles, and online content. " +
|
|
@@ -24,7 +24,7 @@ const WEB_SEARCH_TOOL = {
|
|
|
24
24
|
time_range: {
|
|
25
25
|
type: "string",
|
|
26
26
|
description: "Time range of search (day, month, year)",
|
|
27
|
-
enum: ["
|
|
27
|
+
enum: ["day", "month", "year"],
|
|
28
28
|
default: "",
|
|
29
29
|
},
|
|
30
30
|
language: {
|
|
@@ -33,10 +33,10 @@ const WEB_SEARCH_TOOL = {
|
|
|
33
33
|
default: "all",
|
|
34
34
|
},
|
|
35
35
|
safesearch: {
|
|
36
|
-
type: "
|
|
36
|
+
type: "string",
|
|
37
37
|
description: "Safe search filter level (0: None, 1: Moderate, 2: Strict)",
|
|
38
|
-
enum: [0, 1, 2],
|
|
39
|
-
default:
|
|
38
|
+
enum: ["0", "1", "2"],
|
|
39
|
+
default: "0",
|
|
40
40
|
},
|
|
41
41
|
},
|
|
42
42
|
required: ["query"],
|
|
@@ -82,20 +82,21 @@ function isSearXNGWebSearchArgs(args) {
|
|
|
82
82
|
"query" in args &&
|
|
83
83
|
typeof args.query === "string");
|
|
84
84
|
}
|
|
85
|
-
async function performWebSearch(query, pageno = 1, time_range
|
|
85
|
+
async function performWebSearch(query, pageno = 1, time_range, language = "all", safesearch) {
|
|
86
86
|
const searxngUrl = process.env.SEARXNG_URL || "http://localhost:8080";
|
|
87
87
|
const url = new URL(`${searxngUrl}/search`);
|
|
88
88
|
url.searchParams.set("q", query);
|
|
89
89
|
url.searchParams.set("format", "json");
|
|
90
90
|
url.searchParams.set("pageno", pageno.toString());
|
|
91
|
-
if (time_range
|
|
91
|
+
if (time_range !== undefined &&
|
|
92
|
+
["day", "month", "year"].includes(time_range)) {
|
|
92
93
|
url.searchParams.set("time_range", time_range);
|
|
93
94
|
}
|
|
94
95
|
if (language && language !== "all") {
|
|
95
96
|
url.searchParams.set("language", language);
|
|
96
97
|
}
|
|
97
|
-
if (safesearch !== undefined && [0, 1, 2].includes(safesearch)) {
|
|
98
|
-
url.searchParams.set("safesearch", safesearch
|
|
98
|
+
if (safesearch !== undefined && ["0", "1", "2"].includes(safesearch)) {
|
|
99
|
+
url.searchParams.set("safesearch", safesearch);
|
|
99
100
|
}
|
|
100
101
|
const response = await fetch(url.toString(), {
|
|
101
102
|
method: "GET",
|
|
@@ -157,7 +158,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
157
158
|
if (!isSearXNGWebSearchArgs(args)) {
|
|
158
159
|
throw new Error("Invalid arguments for searxng_web_search");
|
|
159
160
|
}
|
|
160
|
-
const { query, pageno = 1, time_range
|
|
161
|
+
const { query, pageno = 1, time_range, language = "all", safesearch, } = args;
|
|
161
162
|
const results = await performWebSearch(query, pageno, time_range, language, safesearch);
|
|
162
163
|
return {
|
|
163
164
|
content: [{ type: "text", text: results }],
|