mcp-searxng 0.2.2 → 0.3.1
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/README.md +10 -5
- package/dist/index.js +33 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# SearXNG MCP Server
|
|
2
2
|
|
|
3
|
-
An [MCP server](https://modelcontextprotocol.io/introduction) implementation that integrates the
|
|
3
|
+
An [MCP server](https://modelcontextprotocol.io/introduction) implementation that integrates the [SearXNG](https://docs.searxng.org) API, providing web search capabilities.
|
|
4
4
|
|
|
5
5
|
<a href="https://glama.ai/mcp/servers/0j7jjyt7m9"><img width="380" height="200" src="https://glama.ai/mcp/servers/0j7jjyt7m9/badge" alt="SearXNG Server MCP server" /></a>
|
|
6
6
|
|
|
@@ -9,16 +9,21 @@ An [MCP server](https://modelcontextprotocol.io/introduction) implementation tha
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
11
11
|
- **Web Search**: General queries, news, articles, with pagination.
|
|
12
|
-
- **Pagination**: Control
|
|
12
|
+
- **Pagination**: Control which page of results to retrieve.
|
|
13
|
+
- **Time Filtering**: Filter results by time range (day, month, year).
|
|
14
|
+
- **Language Selection**: Filter results by preferred language.
|
|
15
|
+
- **Safe Search**: Control content filtering level for search results.
|
|
13
16
|
|
|
14
17
|
## Tools
|
|
15
18
|
|
|
16
19
|
- **searxng_web_search**
|
|
17
20
|
- Execute web searches with pagination
|
|
18
21
|
- Inputs:
|
|
19
|
-
- `query` (string):
|
|
20
|
-
- `
|
|
21
|
-
- `
|
|
22
|
+
- `query` (string): The search query. This string is passed to external search services.
|
|
23
|
+
- `pageno` (number, optional): Search page number, starts at 1 (default 1)
|
|
24
|
+
- `time_range` (string, optional): Filter results by time range - one of: "day", "month", "year" (default: none)
|
|
25
|
+
- `language` (string, optional): Language code for results (e.g., "en", "fr", "de") or "all" (default: "all")
|
|
26
|
+
- `safesearch` (number, optional): Safe search filter level (0: None, 1: Moderate, 2: Strict) (default: instance setting)
|
|
22
27
|
|
|
23
28
|
## Configuration
|
|
24
29
|
|
package/dist/index.js
CHANGED
|
@@ -12,17 +12,29 @@ const WEB_SEARCH_TOOL = {
|
|
|
12
12
|
properties: {
|
|
13
13
|
query: {
|
|
14
14
|
type: "string",
|
|
15
|
-
description: "
|
|
15
|
+
description: "The search query. This string is passed to external search services.",
|
|
16
16
|
},
|
|
17
|
-
|
|
17
|
+
pageno: {
|
|
18
18
|
type: "number",
|
|
19
|
-
description: "
|
|
20
|
-
default:
|
|
19
|
+
description: "Search page number (starts at 1)",
|
|
20
|
+
default: 1,
|
|
21
21
|
},
|
|
22
|
-
|
|
22
|
+
time_range: {
|
|
23
|
+
type: "string",
|
|
24
|
+
description: "Time range of search (day, month, year)",
|
|
25
|
+
enum: ["", "day", "month", "year"],
|
|
26
|
+
default: "",
|
|
27
|
+
},
|
|
28
|
+
language: {
|
|
29
|
+
type: "string",
|
|
30
|
+
description: "Language code for search results (e.g., 'en', 'fr', 'de'). Default is instance-dependent.",
|
|
31
|
+
default: "all",
|
|
32
|
+
},
|
|
33
|
+
safesearch: {
|
|
23
34
|
type: "number",
|
|
24
|
-
description: "
|
|
25
|
-
|
|
35
|
+
description: "Safe search filter level (0: None, 1: Moderate, 2: Strict)",
|
|
36
|
+
enum: [0, 1, 2],
|
|
37
|
+
default: undefined,
|
|
26
38
|
},
|
|
27
39
|
},
|
|
28
40
|
required: ["query"],
|
|
@@ -46,7 +58,7 @@ const READ_URL_TOOL = {
|
|
|
46
58
|
// Server implementation
|
|
47
59
|
const server = new Server({
|
|
48
60
|
name: "ihor-sokoliuk/mcp-searxng",
|
|
49
|
-
version: "0.
|
|
61
|
+
version: "0.3.1",
|
|
50
62
|
}, {
|
|
51
63
|
capabilities: {
|
|
52
64
|
resources: {},
|
|
@@ -59,13 +71,21 @@ function isSearXNGWebSearchArgs(args) {
|
|
|
59
71
|
"query" in args &&
|
|
60
72
|
typeof args.query === "string");
|
|
61
73
|
}
|
|
62
|
-
async function performWebSearch(query,
|
|
74
|
+
async function performWebSearch(query, pageno = 1, time_range = "", language = "all", safesearch) {
|
|
63
75
|
const searxngUrl = process.env.SEARXNG_URL || "http://localhost:8080";
|
|
64
76
|
const url = new URL(`${searxngUrl}/search`);
|
|
65
77
|
url.searchParams.set("q", query);
|
|
66
78
|
url.searchParams.set("format", "json");
|
|
67
|
-
url.searchParams.set("
|
|
68
|
-
|
|
79
|
+
url.searchParams.set("pageno", pageno.toString());
|
|
80
|
+
if (time_range && ["day", "month", "year"].includes(time_range)) {
|
|
81
|
+
url.searchParams.set("time_range", time_range);
|
|
82
|
+
}
|
|
83
|
+
if (language && language !== "all") {
|
|
84
|
+
url.searchParams.set("language", language);
|
|
85
|
+
}
|
|
86
|
+
if (safesearch !== undefined && [0, 1, 2].includes(safesearch)) {
|
|
87
|
+
url.searchParams.set("safesearch", safesearch.toString());
|
|
88
|
+
}
|
|
69
89
|
const response = await fetch(url.toString(), {
|
|
70
90
|
method: "GET",
|
|
71
91
|
});
|
|
@@ -126,8 +146,8 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
126
146
|
if (!isSearXNGWebSearchArgs(args)) {
|
|
127
147
|
throw new Error("Invalid arguments for searxng_web_search");
|
|
128
148
|
}
|
|
129
|
-
const { query,
|
|
130
|
-
const results = await performWebSearch(query,
|
|
149
|
+
const { query, pageno = 1, time_range = "", language = "all", safesearch, } = args;
|
|
150
|
+
const results = await performWebSearch(query, pageno, time_range, language, safesearch);
|
|
131
151
|
return {
|
|
132
152
|
content: [{ type: "text", text: results }],
|
|
133
153
|
isError: false,
|