search1api-mcp 0.3.1 → 0.4.0
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 +14 -4
- package/build/tools/crawl.js +12 -1
- package/build/tools/fetch.js +51 -0
- package/build/tools/handlers.js +4 -1
- package/build/tools/index.js +207 -56
- package/build/tools/news.js +13 -1
- package/build/tools/search.js +13 -1
- package/build/tools/sitemap.js +3 -1
- package/build/tools/trending.js +3 -1
- package/build/types.js +7 -0
- package/package.json +6 -3
- package/server.json +36 -0
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[中文文档](./README_zh.md)
|
|
4
4
|
|
|
5
|
-
The official MCP server for [Search1API](https://www.search1api.com/?utm_source=mcp) — web search, news,
|
|
5
|
+
The official MCP server for [Search1API](https://www.search1api.com/?utm_source=mcp) — web search, news, page retrieval, sitemap discovery, and trending topics in one API.
|
|
6
6
|
|
|
7
7
|
## Authentication
|
|
8
8
|
|
|
@@ -128,18 +128,27 @@ If you prefer to run the server locally, use npx — no cloning required:
|
|
|
128
128
|
## Tools
|
|
129
129
|
|
|
130
130
|
### search
|
|
131
|
-
Search the web using Search1API.
|
|
131
|
+
Search the web using Search1API. Results use the standard citable
|
|
132
|
+
`id`/`title`/`url` shape expected by ChatGPT deep research and company
|
|
133
|
+
knowledge.
|
|
132
134
|
|
|
133
135
|
| Parameter | Required | Default | Description |
|
|
134
136
|
|-----------|----------|---------|-------------|
|
|
135
137
|
| `query` | Yes | - | Search query |
|
|
136
138
|
| `max_results` | No | 10 | Number of results |
|
|
137
139
|
| `search_service` | No | google | google, bing, duckduckgo, yahoo, x, reddit, github, youtube, arxiv, wechat, bilibili, imdb, wikipedia |
|
|
138
|
-
| `crawl_results` | No | 0 | Number of results to crawl for full content |
|
|
140
|
+
| `crawl_results` | No | 0 | Number of top results to crawl for full content; each successful crawl adds 1 credit to the base 1-credit search request |
|
|
139
141
|
| `include_sites` | No | [] | Sites to include |
|
|
140
142
|
| `exclude_sites` | No | [] | Sites to exclude |
|
|
141
143
|
| `time_range` | No | - | day, month, year |
|
|
142
144
|
|
|
145
|
+
### fetch
|
|
146
|
+
Retrieve the full readable contents of a result returned by `search`.
|
|
147
|
+
|
|
148
|
+
| Parameter | Required | Description |
|
|
149
|
+
|-----------|----------|-------------|
|
|
150
|
+
| `id` | Yes | Result ID returned by `search` (the canonical page URL) |
|
|
151
|
+
|
|
143
152
|
### news
|
|
144
153
|
Search for news articles.
|
|
145
154
|
|
|
@@ -148,7 +157,7 @@ Search for news articles.
|
|
|
148
157
|
| `query` | Yes | - | Search query |
|
|
149
158
|
| `max_results` | No | 10 | Number of results |
|
|
150
159
|
| `search_service` | No | bing | google, bing, duckduckgo, yahoo, hackernews |
|
|
151
|
-
| `crawl_results` | No | 0 | Number of results to crawl for full content |
|
|
160
|
+
| `crawl_results` | No | 0 | Number of top results to crawl for full content; each successful crawl adds 1 credit to the base 1-credit news request |
|
|
152
161
|
| `include_sites` | No | [] | Sites to include |
|
|
153
162
|
| `exclude_sites` | No | [] | Sites to exclude |
|
|
154
163
|
| `time_range` | No | - | day, month, year |
|
|
@@ -177,6 +186,7 @@ Get trending topics from popular platforms.
|
|
|
177
186
|
|
|
178
187
|
## Version History
|
|
179
188
|
|
|
189
|
+
- v0.4.0: Standard `search`/`fetch` compatibility, structured output schemas, OAuth security schemes, safety annotations, and Official MCP Registry metadata
|
|
180
190
|
- v0.3.1: OAuth 2.1 support for Remote MCP; retired reasoning tool removed
|
|
181
191
|
- v0.3.0: Remote MCP support via Streamable HTTP; per-session API key authentication
|
|
182
192
|
- v0.2.0: Fallback `.env` support for LibreChat integration
|
package/build/tools/crawl.js
CHANGED
|
@@ -17,11 +17,22 @@ export async function handleCrawl(args, apiKey) {
|
|
|
17
17
|
const response = await makeRequest(API_CONFIG.ENDPOINTS.CRAWL, { url }, apiKey);
|
|
18
18
|
const endTime = Date.now();
|
|
19
19
|
log(`Crawl completed successfully in ${endTime - startTime}ms`);
|
|
20
|
+
const result = {
|
|
21
|
+
id: response.results.link || url,
|
|
22
|
+
title: response.results.title,
|
|
23
|
+
url: response.results.link || url,
|
|
24
|
+
text: response.results.content,
|
|
25
|
+
metadata: {
|
|
26
|
+
source: "search1api",
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
const structuredContent = { result };
|
|
20
30
|
return {
|
|
31
|
+
structuredContent,
|
|
21
32
|
content: [{
|
|
22
33
|
type: "text",
|
|
23
34
|
mimeType: "application/json",
|
|
24
|
-
text: JSON.stringify(
|
|
35
|
+
text: JSON.stringify(structuredContent)
|
|
25
36
|
}]
|
|
26
37
|
};
|
|
27
38
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ErrorCode, McpError } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
import { makeRequest } from "../api.js";
|
|
3
|
+
import { API_CONFIG } from "../config.js";
|
|
4
|
+
import { isValidFetchArgs, } from "../types.js";
|
|
5
|
+
import { formatError, log } from "../utils.js";
|
|
6
|
+
/**
|
|
7
|
+
* ChatGPT-compatible fetch implementation. Search result IDs are canonical
|
|
8
|
+
* URLs, so fetch can pass the ID directly to the crawl endpoint.
|
|
9
|
+
*/
|
|
10
|
+
export async function handleFetch(args, apiKey) {
|
|
11
|
+
if (!isValidFetchArgs(args)) {
|
|
12
|
+
throw new McpError(ErrorCode.InvalidParams, "Invalid fetch arguments");
|
|
13
|
+
}
|
|
14
|
+
const { id } = args;
|
|
15
|
+
log("Fetching search result:", id);
|
|
16
|
+
try {
|
|
17
|
+
const response = await makeRequest(API_CONFIG.ENDPOINTS.CRAWL, { url: id }, apiKey);
|
|
18
|
+
const result = {
|
|
19
|
+
id,
|
|
20
|
+
title: response.results.title,
|
|
21
|
+
text: response.results.content,
|
|
22
|
+
url: response.results.link || id,
|
|
23
|
+
metadata: {
|
|
24
|
+
source: "search1api",
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
return {
|
|
28
|
+
structuredContent: result,
|
|
29
|
+
content: [
|
|
30
|
+
{
|
|
31
|
+
type: "text",
|
|
32
|
+
mimeType: "application/json",
|
|
33
|
+
text: JSON.stringify(result),
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
log("Fetch error:", error);
|
|
40
|
+
return {
|
|
41
|
+
content: [
|
|
42
|
+
{
|
|
43
|
+
type: "text",
|
|
44
|
+
mimeType: "text/plain",
|
|
45
|
+
text: `Fetch API error: ${formatError(error)}`,
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
isError: true,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
package/build/tools/handlers.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { McpError, ErrorCode } from "@modelcontextprotocol/sdk/types.js";
|
|
2
2
|
import { log } from '../utils.js';
|
|
3
3
|
import { handleSearch } from './search.js';
|
|
4
|
+
import { handleFetch } from './fetch.js';
|
|
4
5
|
import { handleCrawl } from './crawl.js';
|
|
5
6
|
import { handleSitemap } from './sitemap.js';
|
|
6
7
|
import { handleNews } from './news.js';
|
|
7
8
|
import { handleTrending } from './trending.js';
|
|
8
|
-
import { SEARCH_TOOL, CRAWL_TOOL, SITEMAP_TOOL, NEWS_TOOL, TRENDING_TOOL } from './index.js';
|
|
9
|
+
import { SEARCH_TOOL, FETCH_TOOL, CRAWL_TOOL, SITEMAP_TOOL, NEWS_TOOL, TRENDING_TOOL } from './index.js';
|
|
9
10
|
/**
|
|
10
11
|
* Dispatch request based on tool name
|
|
11
12
|
* @param toolName Name of the tool
|
|
@@ -18,6 +19,8 @@ export async function handleToolCall(toolName, args, apiKey) {
|
|
|
18
19
|
switch (toolName) {
|
|
19
20
|
case SEARCH_TOOL.name:
|
|
20
21
|
return await handleSearch(args, apiKey);
|
|
22
|
+
case FETCH_TOOL.name:
|
|
23
|
+
return await handleFetch(args, apiKey);
|
|
21
24
|
case CRAWL_TOOL.name:
|
|
22
25
|
return await handleCrawl(args, apiKey);
|
|
23
26
|
case SITEMAP_TOOL.name:
|
package/build/tools/index.js
CHANGED
|
@@ -1,164 +1,315 @@
|
|
|
1
|
+
const AUTHENTICATED_READ_ONLY_WEB = {
|
|
2
|
+
securitySchemes: [
|
|
3
|
+
{
|
|
4
|
+
type: "oauth2",
|
|
5
|
+
scopes: ["openid", "offline_access"],
|
|
6
|
+
},
|
|
7
|
+
],
|
|
8
|
+
_meta: {
|
|
9
|
+
securitySchemes: [
|
|
10
|
+
{
|
|
11
|
+
type: "oauth2",
|
|
12
|
+
scopes: ["openid", "offline_access"],
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
annotations: {
|
|
17
|
+
readOnlyHint: true,
|
|
18
|
+
destructiveHint: false,
|
|
19
|
+
openWorldHint: true,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
const CITABLE_RESULT_SCHEMA = {
|
|
23
|
+
type: "object",
|
|
24
|
+
properties: {
|
|
25
|
+
id: {
|
|
26
|
+
type: "string",
|
|
27
|
+
description: "Stable identifier for this result; for web results this is the canonical URL",
|
|
28
|
+
},
|
|
29
|
+
title: {
|
|
30
|
+
type: "string",
|
|
31
|
+
description: "Human-readable result title",
|
|
32
|
+
},
|
|
33
|
+
url: {
|
|
34
|
+
type: "string",
|
|
35
|
+
format: "uri",
|
|
36
|
+
description: "Canonical URL that clients can cite and users can open",
|
|
37
|
+
},
|
|
38
|
+
text: {
|
|
39
|
+
type: "string",
|
|
40
|
+
description: "Result snippet or extracted page text when available",
|
|
41
|
+
},
|
|
42
|
+
metadata: {
|
|
43
|
+
type: "object",
|
|
44
|
+
description: "Additional source metadata",
|
|
45
|
+
additionalProperties: true,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
required: ["id", "title", "url"],
|
|
49
|
+
};
|
|
50
|
+
const SEARCH_OUTPUT_SCHEMA = {
|
|
51
|
+
type: "object",
|
|
52
|
+
properties: {
|
|
53
|
+
results: {
|
|
54
|
+
type: "array",
|
|
55
|
+
items: CITABLE_RESULT_SCHEMA,
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
required: ["results"],
|
|
59
|
+
};
|
|
60
|
+
const FETCH_OUTPUT_SCHEMA = {
|
|
61
|
+
type: "object",
|
|
62
|
+
properties: {
|
|
63
|
+
id: { type: "string" },
|
|
64
|
+
title: { type: "string" },
|
|
65
|
+
text: { type: "string" },
|
|
66
|
+
url: { type: "string", format: "uri" },
|
|
67
|
+
metadata: {
|
|
68
|
+
type: "object",
|
|
69
|
+
additionalProperties: true,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
required: ["id", "title", "text", "url"],
|
|
73
|
+
};
|
|
1
74
|
// Search tool definition
|
|
2
75
|
export const SEARCH_TOOL = {
|
|
3
76
|
name: "search",
|
|
4
|
-
|
|
77
|
+
title: "Search the web",
|
|
78
|
+
description: "Search the live public web when the user needs current information, sources, or research. Returns citable results with id, title, URL, and text. Pass a result id to fetch to retrieve the full page.",
|
|
79
|
+
...AUTHENTICATED_READ_ONLY_WEB,
|
|
5
80
|
inputSchema: {
|
|
6
81
|
type: "object",
|
|
7
82
|
properties: {
|
|
8
83
|
query: {
|
|
9
84
|
type: "string",
|
|
10
|
-
description: "
|
|
85
|
+
description: "Short, focused search query",
|
|
11
86
|
},
|
|
12
87
|
max_results: {
|
|
13
88
|
type: "number",
|
|
89
|
+
minimum: 1,
|
|
90
|
+
maximum: 50,
|
|
14
91
|
description: "Maximum number of results to return",
|
|
15
|
-
default: 10
|
|
92
|
+
default: 10,
|
|
16
93
|
},
|
|
17
94
|
search_service: {
|
|
18
95
|
type: "string",
|
|
19
|
-
description: "
|
|
96
|
+
description: "Search engine to use; choose one only when it matches the user's source intent",
|
|
20
97
|
default: "google",
|
|
21
|
-
enum: ["google", "bing", "duckduckgo", "yahoo", "x", "reddit", "github", "youtube", "arxiv", "wechat", "bilibili", "imdb", "wikipedia"]
|
|
98
|
+
enum: ["google", "bing", "duckduckgo", "yahoo", "x", "reddit", "github", "youtube", "arxiv", "wechat", "bilibili", "imdb", "wikipedia"],
|
|
22
99
|
},
|
|
23
100
|
crawl_results: {
|
|
24
101
|
type: "number",
|
|
25
|
-
|
|
26
|
-
|
|
102
|
+
minimum: 0,
|
|
103
|
+
description: "Number of top results to retrieve as full pages. Each successful page retrieval adds 1 credit to the base 1-credit search request",
|
|
104
|
+
default: 0,
|
|
27
105
|
},
|
|
28
106
|
include_sites: {
|
|
29
107
|
type: "array",
|
|
30
108
|
items: {
|
|
31
|
-
type: "string"
|
|
109
|
+
type: "string",
|
|
32
110
|
},
|
|
33
|
-
description: "
|
|
34
|
-
default: []
|
|
111
|
+
description: "Domains to include when the user explicitly scopes the search",
|
|
112
|
+
default: [],
|
|
35
113
|
},
|
|
36
114
|
exclude_sites: {
|
|
37
115
|
type: "array",
|
|
38
116
|
items: {
|
|
39
|
-
type: "string"
|
|
117
|
+
type: "string",
|
|
40
118
|
},
|
|
41
|
-
description: "
|
|
42
|
-
default: []
|
|
119
|
+
description: "Domains to exclude from the search",
|
|
120
|
+
default: [],
|
|
43
121
|
},
|
|
44
122
|
time_range: {
|
|
45
123
|
type: "string",
|
|
46
|
-
description: "
|
|
47
|
-
enum: ["day", "month", "year"]
|
|
48
|
-
}
|
|
124
|
+
description: "Optional recency window for time-sensitive searches",
|
|
125
|
+
enum: ["day", "month", "year"],
|
|
126
|
+
},
|
|
49
127
|
},
|
|
50
|
-
required: ["query"]
|
|
51
|
-
}
|
|
128
|
+
required: ["query"],
|
|
129
|
+
},
|
|
130
|
+
outputSchema: SEARCH_OUTPUT_SCHEMA,
|
|
131
|
+
};
|
|
132
|
+
// Fetch tool definition for ChatGPT deep research and company knowledge.
|
|
133
|
+
export const FETCH_TOOL = {
|
|
134
|
+
name: "fetch",
|
|
135
|
+
title: "Fetch a search result",
|
|
136
|
+
description: "Retrieve the full readable contents of a result returned by search. Pass the result id, which is the canonical page URL. Returns id, title, full text, URL, and metadata.",
|
|
137
|
+
...AUTHENTICATED_READ_ONLY_WEB,
|
|
138
|
+
inputSchema: {
|
|
139
|
+
type: "object",
|
|
140
|
+
properties: {
|
|
141
|
+
id: {
|
|
142
|
+
type: "string",
|
|
143
|
+
description: "Result id returned by search; for web results this is the canonical URL",
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
required: ["id"],
|
|
147
|
+
},
|
|
148
|
+
outputSchema: FETCH_OUTPUT_SCHEMA,
|
|
52
149
|
};
|
|
53
150
|
// News tool definition
|
|
54
151
|
export const NEWS_TOOL = {
|
|
55
152
|
name: "news",
|
|
56
|
-
|
|
153
|
+
title: "Search current news",
|
|
154
|
+
description: "Search current news when the user asks about recent events, announcements, or coverage. Returns citable article results with title, URL, snippet, and optional extracted text.",
|
|
155
|
+
...AUTHENTICATED_READ_ONLY_WEB,
|
|
57
156
|
inputSchema: {
|
|
58
157
|
type: "object",
|
|
59
158
|
properties: {
|
|
60
159
|
query: {
|
|
61
160
|
type: "string",
|
|
62
|
-
description: "
|
|
161
|
+
description: "Short, focused news query",
|
|
63
162
|
},
|
|
64
163
|
max_results: {
|
|
65
164
|
type: "number",
|
|
66
|
-
|
|
67
|
-
|
|
165
|
+
minimum: 1,
|
|
166
|
+
maximum: 50,
|
|
167
|
+
description: "Maximum number of articles to return",
|
|
168
|
+
default: 10,
|
|
68
169
|
},
|
|
69
170
|
search_service: {
|
|
70
171
|
type: "string",
|
|
71
|
-
description: "
|
|
172
|
+
description: "News search engine to use",
|
|
72
173
|
default: "bing",
|
|
73
|
-
enum: ["google", "bing", "duckduckgo", "yahoo", "hackernews"]
|
|
174
|
+
enum: ["google", "bing", "duckduckgo", "yahoo", "hackernews"],
|
|
74
175
|
},
|
|
75
176
|
crawl_results: {
|
|
76
177
|
type: "number",
|
|
77
|
-
|
|
78
|
-
|
|
178
|
+
minimum: 0,
|
|
179
|
+
description: "Number of top articles to retrieve as full pages. Each successful retrieval adds 1 credit to the base 1-credit news request",
|
|
180
|
+
default: 0,
|
|
79
181
|
},
|
|
80
182
|
include_sites: {
|
|
81
183
|
type: "array",
|
|
82
184
|
items: {
|
|
83
|
-
type: "string"
|
|
185
|
+
type: "string",
|
|
84
186
|
},
|
|
85
|
-
description: "
|
|
86
|
-
default: []
|
|
187
|
+
description: "News domains to include",
|
|
188
|
+
default: [],
|
|
87
189
|
},
|
|
88
190
|
exclude_sites: {
|
|
89
191
|
type: "array",
|
|
90
192
|
items: {
|
|
91
|
-
type: "string"
|
|
193
|
+
type: "string",
|
|
92
194
|
},
|
|
93
|
-
description: "
|
|
94
|
-
default: []
|
|
195
|
+
description: "News domains to exclude",
|
|
196
|
+
default: [],
|
|
95
197
|
},
|
|
96
198
|
time_range: {
|
|
97
199
|
type: "string",
|
|
98
|
-
description: "
|
|
99
|
-
enum: ["day", "month", "year"]
|
|
100
|
-
}
|
|
200
|
+
description: "Optional recency window; use day for breaking news",
|
|
201
|
+
enum: ["day", "month", "year"],
|
|
202
|
+
},
|
|
101
203
|
},
|
|
102
|
-
required: ["query"]
|
|
103
|
-
}
|
|
204
|
+
required: ["query"],
|
|
205
|
+
},
|
|
206
|
+
outputSchema: SEARCH_OUTPUT_SCHEMA,
|
|
104
207
|
};
|
|
105
208
|
// Crawl tool definition
|
|
106
209
|
export const CRAWL_TOOL = {
|
|
107
210
|
name: "crawl",
|
|
108
|
-
|
|
211
|
+
title: "Read a web page",
|
|
212
|
+
description: "Extract the readable title and full text from a specific public URL supplied by the user. Use fetch instead when following a result returned by search.",
|
|
213
|
+
...AUTHENTICATED_READ_ONLY_WEB,
|
|
109
214
|
inputSchema: {
|
|
110
215
|
type: "object",
|
|
111
216
|
properties: {
|
|
112
217
|
url: {
|
|
113
218
|
type: "string",
|
|
114
|
-
|
|
115
|
-
|
|
219
|
+
format: "uri",
|
|
220
|
+
description: "Public HTTP or HTTPS URL to retrieve",
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
required: ["url"],
|
|
224
|
+
},
|
|
225
|
+
outputSchema: {
|
|
226
|
+
type: "object",
|
|
227
|
+
properties: {
|
|
228
|
+
result: CITABLE_RESULT_SCHEMA,
|
|
116
229
|
},
|
|
117
|
-
required: ["
|
|
118
|
-
}
|
|
230
|
+
required: ["result"],
|
|
231
|
+
},
|
|
119
232
|
};
|
|
120
233
|
// Sitemap tool definition
|
|
121
234
|
export const SITEMAP_TOOL = {
|
|
122
235
|
name: "sitemap",
|
|
123
|
-
|
|
236
|
+
title: "Discover links on a site",
|
|
237
|
+
description: "Discover related public links from a page or domain when the user wants to explore a site's structure or available pages.",
|
|
238
|
+
...AUTHENTICATED_READ_ONLY_WEB,
|
|
124
239
|
inputSchema: {
|
|
125
240
|
type: "object",
|
|
126
241
|
properties: {
|
|
127
242
|
url: {
|
|
128
243
|
type: "string",
|
|
129
|
-
|
|
130
|
-
|
|
244
|
+
format: "uri",
|
|
245
|
+
description: "Public page or domain URL whose links should be discovered",
|
|
246
|
+
},
|
|
131
247
|
},
|
|
132
|
-
required: ["url"]
|
|
133
|
-
}
|
|
248
|
+
required: ["url"],
|
|
249
|
+
},
|
|
250
|
+
outputSchema: {
|
|
251
|
+
type: "object",
|
|
252
|
+
properties: {
|
|
253
|
+
links: {
|
|
254
|
+
type: "array",
|
|
255
|
+
items: {
|
|
256
|
+
type: "string",
|
|
257
|
+
format: "uri",
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
required: ["links"],
|
|
262
|
+
},
|
|
134
263
|
};
|
|
135
264
|
// Trending tool definition
|
|
136
265
|
export const TRENDING_TOOL = {
|
|
137
266
|
name: "trending",
|
|
138
|
-
|
|
267
|
+
title: "Explore trending topics",
|
|
268
|
+
description: "List currently trending repositories or stories from GitHub or Hacker News when the user asks what is popular now.",
|
|
269
|
+
...AUTHENTICATED_READ_ONLY_WEB,
|
|
139
270
|
inputSchema: {
|
|
140
271
|
type: "object",
|
|
141
272
|
properties: {
|
|
142
273
|
search_service: {
|
|
143
274
|
type: "string",
|
|
144
|
-
description: "
|
|
275
|
+
description: "Platform whose trending items should be returned",
|
|
145
276
|
enum: ["github", "hackernews"],
|
|
146
|
-
default: "github"
|
|
277
|
+
default: "github",
|
|
147
278
|
},
|
|
148
279
|
max_results: {
|
|
149
280
|
type: "number",
|
|
281
|
+
minimum: 1,
|
|
282
|
+
maximum: 50,
|
|
150
283
|
description: "Maximum number of trending items to return",
|
|
151
|
-
default: 10
|
|
152
|
-
}
|
|
284
|
+
default: 10,
|
|
285
|
+
},
|
|
286
|
+
},
|
|
287
|
+
required: ["search_service"],
|
|
288
|
+
},
|
|
289
|
+
outputSchema: {
|
|
290
|
+
type: "object",
|
|
291
|
+
properties: {
|
|
292
|
+
results: {
|
|
293
|
+
type: "array",
|
|
294
|
+
items: {
|
|
295
|
+
type: "object",
|
|
296
|
+
properties: {
|
|
297
|
+
title: { type: "string" },
|
|
298
|
+
url: { type: "string", format: "uri" },
|
|
299
|
+
description: { type: "string" },
|
|
300
|
+
},
|
|
301
|
+
required: ["title", "url"],
|
|
302
|
+
},
|
|
303
|
+
},
|
|
153
304
|
},
|
|
154
|
-
required: ["
|
|
155
|
-
}
|
|
305
|
+
required: ["results"],
|
|
306
|
+
},
|
|
156
307
|
};
|
|
157
|
-
// Export all tools
|
|
158
308
|
export const ALL_TOOLS = [
|
|
159
309
|
SEARCH_TOOL,
|
|
310
|
+
FETCH_TOOL,
|
|
160
311
|
NEWS_TOOL,
|
|
161
312
|
CRAWL_TOOL,
|
|
162
313
|
SITEMAP_TOOL,
|
|
163
|
-
TRENDING_TOOL
|
|
314
|
+
TRENDING_TOOL,
|
|
164
315
|
];
|
package/build/tools/news.js
CHANGED
|
@@ -13,11 +13,23 @@ export async function handleNews(args, apiKey) {
|
|
|
13
13
|
log("Processing news search with query:", args.query);
|
|
14
14
|
try {
|
|
15
15
|
const response = await makeRequest(API_CONFIG.ENDPOINTS.NEWS, args, apiKey);
|
|
16
|
+
const results = response.results.map((result) => ({
|
|
17
|
+
id: result.link,
|
|
18
|
+
title: result.title,
|
|
19
|
+
url: result.link,
|
|
20
|
+
text: result.content || result.snippet,
|
|
21
|
+
metadata: {
|
|
22
|
+
snippet: result.snippet,
|
|
23
|
+
...(result.content ? { has_full_content: true } : {}),
|
|
24
|
+
},
|
|
25
|
+
}));
|
|
26
|
+
const structuredContent = { results };
|
|
16
27
|
return {
|
|
28
|
+
structuredContent,
|
|
17
29
|
content: [{
|
|
18
30
|
type: "text",
|
|
19
31
|
mimeType: "application/json",
|
|
20
|
-
text: JSON.stringify(
|
|
32
|
+
text: JSON.stringify(structuredContent)
|
|
21
33
|
}]
|
|
22
34
|
};
|
|
23
35
|
}
|
package/build/tools/search.js
CHANGED
|
@@ -12,11 +12,23 @@ export async function handleSearch(args, apiKey) {
|
|
|
12
12
|
}
|
|
13
13
|
try {
|
|
14
14
|
const response = await makeRequest(API_CONFIG.ENDPOINTS.SEARCH, args, apiKey);
|
|
15
|
+
const results = response.results.map((result) => ({
|
|
16
|
+
id: result.link,
|
|
17
|
+
title: result.title,
|
|
18
|
+
url: result.link,
|
|
19
|
+
text: result.content || result.snippet,
|
|
20
|
+
metadata: {
|
|
21
|
+
snippet: result.snippet,
|
|
22
|
+
...(result.content ? { has_full_content: true } : {}),
|
|
23
|
+
},
|
|
24
|
+
}));
|
|
25
|
+
const structuredContent = { results };
|
|
15
26
|
return {
|
|
27
|
+
structuredContent,
|
|
16
28
|
content: [{
|
|
17
29
|
type: "text",
|
|
18
30
|
mimeType: "application/json",
|
|
19
|
-
text: JSON.stringify(
|
|
31
|
+
text: JSON.stringify(structuredContent)
|
|
20
32
|
}]
|
|
21
33
|
};
|
|
22
34
|
}
|
package/build/tools/sitemap.js
CHANGED
|
@@ -12,11 +12,13 @@ export async function handleSitemap(args, apiKey) {
|
|
|
12
12
|
}
|
|
13
13
|
try {
|
|
14
14
|
const response = await makeRequest(API_CONFIG.ENDPOINTS.SITEMAP, args, apiKey);
|
|
15
|
+
const structuredContent = { links: response.links };
|
|
15
16
|
return {
|
|
17
|
+
structuredContent,
|
|
16
18
|
content: [{
|
|
17
19
|
type: "text",
|
|
18
20
|
mimeType: "application/json",
|
|
19
|
-
text: JSON.stringify(
|
|
21
|
+
text: JSON.stringify(structuredContent)
|
|
20
22
|
}]
|
|
21
23
|
};
|
|
22
24
|
}
|
package/build/tools/trending.js
CHANGED
|
@@ -12,11 +12,13 @@ export async function handleTrending(args, apiKey) {
|
|
|
12
12
|
}
|
|
13
13
|
try {
|
|
14
14
|
const response = await makeRequest(API_CONFIG.ENDPOINTS.TRENDING, args, apiKey);
|
|
15
|
+
const structuredContent = { results: response.results };
|
|
15
16
|
return {
|
|
17
|
+
structuredContent,
|
|
16
18
|
content: [{
|
|
17
19
|
type: "text",
|
|
18
20
|
mimeType: "application/json",
|
|
19
|
-
text: JSON.stringify(
|
|
21
|
+
text: JSON.stringify(structuredContent)
|
|
20
22
|
}]
|
|
21
23
|
};
|
|
22
24
|
}
|
package/build/types.js
CHANGED
|
@@ -62,6 +62,13 @@ export function isValidSearchArgs(args) {
|
|
|
62
62
|
}
|
|
63
63
|
return true;
|
|
64
64
|
}
|
|
65
|
+
export function isValidFetchArgs(args) {
|
|
66
|
+
if (typeof args !== "object" || args === null) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
const { id } = args;
|
|
70
|
+
return typeof id === "string" && id.trim().length > 0;
|
|
71
|
+
}
|
|
65
72
|
export function isValidCrawlArgs(args) {
|
|
66
73
|
if (typeof args !== 'object' || args === null) {
|
|
67
74
|
return false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "search1api-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"mcpName": "io.github.superagents-lab/search1api",
|
|
4
5
|
"description": "A Model Context Protocol (MCP) server that provides search and crawl functionality using Search1API",
|
|
5
6
|
"private": false,
|
|
6
7
|
"type": "module",
|
|
@@ -8,7 +9,8 @@
|
|
|
8
9
|
"search1api-mcp": "build/index.js"
|
|
9
10
|
},
|
|
10
11
|
"files": [
|
|
11
|
-
"build"
|
|
12
|
+
"build",
|
|
13
|
+
"server.json"
|
|
12
14
|
],
|
|
13
15
|
"scripts": {
|
|
14
16
|
"build": "node -e \"require('node:fs').rmSync('build', { recursive: true, force: true })\" && tsc && node -e \"require('node:fs').chmodSync('build/index.js', '755')\"",
|
|
@@ -17,7 +19,8 @@
|
|
|
17
19
|
"prepack": "npm run build",
|
|
18
20
|
"watch": "tsc --watch",
|
|
19
21
|
"inspector": "npx @modelcontextprotocol/inspector build/index.js",
|
|
20
|
-
"start:http": "node build/http.js"
|
|
22
|
+
"start:http": "node build/http.js",
|
|
23
|
+
"sync:manifest": "npm run build && node scripts/sync-lobe-manifest.mjs"
|
|
21
24
|
},
|
|
22
25
|
"dependencies": {
|
|
23
26
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
package/server.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
|
+
"name": "io.github.superagents-lab/search1api",
|
|
4
|
+
"title": "Search1API",
|
|
5
|
+
"description": "Web search, news, page retrieval, sitemaps, and trending topics through Search1API.",
|
|
6
|
+
"repository": {
|
|
7
|
+
"url": "https://github.com/superagents-lab/search1api-mcp",
|
|
8
|
+
"source": "github"
|
|
9
|
+
},
|
|
10
|
+
"version": "0.4.0",
|
|
11
|
+
"remotes": [
|
|
12
|
+
{
|
|
13
|
+
"type": "streamable-http",
|
|
14
|
+
"url": "https://mcp.search1api.com/mcp"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"packages": [
|
|
18
|
+
{
|
|
19
|
+
"registryType": "npm",
|
|
20
|
+
"identifier": "search1api-mcp",
|
|
21
|
+
"version": "0.4.0",
|
|
22
|
+
"transport": {
|
|
23
|
+
"type": "stdio"
|
|
24
|
+
},
|
|
25
|
+
"environmentVariables": [
|
|
26
|
+
{
|
|
27
|
+
"name": "SEARCH1API_KEY",
|
|
28
|
+
"description": "Search1API API key for local stdio mode",
|
|
29
|
+
"isRequired": true,
|
|
30
|
+
"isSecret": true,
|
|
31
|
+
"format": "string"
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
}
|