search1api-mcp 0.1.2 → 0.1.3
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 +16 -3
- package/build/index.js +64 -6
- package/build/types.js +16 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
A Model Context Protocol (MCP) server that provides search and crawl functionality using Search1API.
|
|
4
4
|
|
|
5
|
+
https://github.com/user-attachments/assets/58bc98ae-3b6b-442c-a7fc-010508b5f028
|
|
6
|
+
|
|
7
|
+
|
|
5
8
|
## Features
|
|
6
9
|
|
|
7
|
-
- Web search functionality
|
|
10
|
+
- Web search functionality
|
|
11
|
+
- News search functionality
|
|
8
12
|
- Web page content extraction
|
|
9
13
|
- Website sitemap extraction
|
|
10
14
|
- Seamless integration with Claude Desktop
|
|
@@ -19,13 +23,21 @@ A Model Context Protocol (MCP) server that provides search and crawl functionali
|
|
|
19
23
|
* `max_results` (optional, default: 10): Number of results to return
|
|
20
24
|
* `search_service` (optional, default: "google"): Search service to use
|
|
21
25
|
|
|
22
|
-
### 2.
|
|
26
|
+
### 2. News Tool
|
|
27
|
+
- Name: `news`
|
|
28
|
+
- Description: Search for news articles using Search1API
|
|
29
|
+
- Parameters:
|
|
30
|
+
* `query` (required): Search query
|
|
31
|
+
* `max_results` (optional, default: 10): Number of results to return
|
|
32
|
+
* `search_service` (optional, default: "google"): Search service to use
|
|
33
|
+
|
|
34
|
+
### 3. Crawl Tool
|
|
23
35
|
- Name: `crawl`
|
|
24
36
|
- Description: Extract content from a URL using Search1API
|
|
25
37
|
- Parameters:
|
|
26
38
|
* `url` (required): URL to crawl
|
|
27
39
|
|
|
28
|
-
###
|
|
40
|
+
### 4. Sitemap Tool
|
|
29
41
|
- Name: `sitemap`
|
|
30
42
|
- Description: Get all related links from a URL
|
|
31
43
|
- Parameters:
|
|
@@ -61,6 +73,7 @@ Configuration file location:
|
|
|
61
73
|
|
|
62
74
|
## Version History
|
|
63
75
|
|
|
76
|
+
- v0.1.3: Added news search functionality
|
|
64
77
|
- v0.1.2: Added sitemap functionality
|
|
65
78
|
- v0.1.1: Added web crawling functionality
|
|
66
79
|
- v0.1.0: Initial release with search functionality
|
package/build/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
|
3
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
4
|
import { ListResourcesRequestSchema, ReadResourceRequestSchema, ListToolsRequestSchema, CallToolRequestSchema, ErrorCode, McpError } from "@modelcontextprotocol/sdk/types.js";
|
|
5
5
|
import dotenv from "dotenv";
|
|
6
|
-
import { isValidSearchArgs, isValidCrawlArgs, isValidSitemapArgs } from "./types.js";
|
|
6
|
+
import { isValidSearchArgs, isValidCrawlArgs, isValidSitemapArgs, isValidNewsArgs } from "./types.js";
|
|
7
7
|
dotenv.config();
|
|
8
8
|
const API_KEY = process.env.SEARCH1API_KEY;
|
|
9
9
|
if (!API_KEY) {
|
|
@@ -15,7 +15,8 @@ const API_CONFIG = {
|
|
|
15
15
|
ENDPOINTS: {
|
|
16
16
|
SEARCH: '/search',
|
|
17
17
|
CRAWL: '/crawl',
|
|
18
|
-
SITEMAP: '/sitemap'
|
|
18
|
+
SITEMAP: '/sitemap',
|
|
19
|
+
NEWS: '/news'
|
|
19
20
|
}
|
|
20
21
|
};
|
|
21
22
|
const SEARCH_TOOL = {
|
|
@@ -42,6 +43,30 @@ const SEARCH_TOOL = {
|
|
|
42
43
|
required: ["query"]
|
|
43
44
|
}
|
|
44
45
|
};
|
|
46
|
+
const NEWS_TOOL = {
|
|
47
|
+
name: "news",
|
|
48
|
+
description: "Search for news articles",
|
|
49
|
+
inputSchema: {
|
|
50
|
+
type: "object",
|
|
51
|
+
properties: {
|
|
52
|
+
query: {
|
|
53
|
+
type: "string",
|
|
54
|
+
description: "News search query"
|
|
55
|
+
},
|
|
56
|
+
max_results: {
|
|
57
|
+
type: "number",
|
|
58
|
+
description: "Maximum number of results to return (default: 10)",
|
|
59
|
+
default: 10
|
|
60
|
+
},
|
|
61
|
+
search_service: {
|
|
62
|
+
type: "string",
|
|
63
|
+
description: "Search service to use (default: google)",
|
|
64
|
+
default: "google"
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
required: ["query"]
|
|
68
|
+
}
|
|
69
|
+
};
|
|
45
70
|
const CRAWL_TOOL = {
|
|
46
71
|
name: "crawl",
|
|
47
72
|
description: "Extract content from URL",
|
|
@@ -73,11 +98,26 @@ const SITEMAP_TOOL = {
|
|
|
73
98
|
// Server implementation
|
|
74
99
|
const server = new Server({
|
|
75
100
|
name: "search1api-mcp",
|
|
76
|
-
version: "0.1.
|
|
101
|
+
version: "0.1.3",
|
|
77
102
|
}, {
|
|
78
103
|
capabilities: {
|
|
79
|
-
resources: {
|
|
80
|
-
|
|
104
|
+
resources: {
|
|
105
|
+
supportedTypes: ["application/json", "text/plain"],
|
|
106
|
+
},
|
|
107
|
+
tools: {
|
|
108
|
+
search: {
|
|
109
|
+
description: "Search functionality"
|
|
110
|
+
},
|
|
111
|
+
news: {
|
|
112
|
+
description: "News search functionality"
|
|
113
|
+
},
|
|
114
|
+
crawl: {
|
|
115
|
+
description: "Web crawling functionality"
|
|
116
|
+
},
|
|
117
|
+
sitemap: {
|
|
118
|
+
description: "Sitemap extraction functionality"
|
|
119
|
+
}
|
|
120
|
+
},
|
|
81
121
|
},
|
|
82
122
|
});
|
|
83
123
|
// 添加服务器事件监听
|
|
@@ -182,7 +222,7 @@ server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
|
182
222
|
});
|
|
183
223
|
// Tool handlers
|
|
184
224
|
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
185
|
-
tools: [SEARCH_TOOL, CRAWL_TOOL, SITEMAP_TOOL],
|
|
225
|
+
tools: [SEARCH_TOOL, CRAWL_TOOL, SITEMAP_TOOL, NEWS_TOOL],
|
|
186
226
|
}));
|
|
187
227
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
188
228
|
try {
|
|
@@ -258,6 +298,24 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
258
298
|
throw formatError(error);
|
|
259
299
|
}
|
|
260
300
|
}
|
|
301
|
+
case "news": {
|
|
302
|
+
if (!isValidNewsArgs(args)) {
|
|
303
|
+
throw new McpError(ErrorCode.InvalidParams, "Invalid news arguments");
|
|
304
|
+
}
|
|
305
|
+
const { query, max_results = 10, search_service = "google" } = args;
|
|
306
|
+
const response = await makeRequest(API_CONFIG.ENDPOINTS.NEWS, {
|
|
307
|
+
query,
|
|
308
|
+
search_service,
|
|
309
|
+
max_results
|
|
310
|
+
});
|
|
311
|
+
return {
|
|
312
|
+
content: [{
|
|
313
|
+
type: "text",
|
|
314
|
+
mimeType: "application/json",
|
|
315
|
+
text: JSON.stringify(response.results, null, 2)
|
|
316
|
+
}]
|
|
317
|
+
};
|
|
318
|
+
}
|
|
261
319
|
default:
|
|
262
320
|
throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${name}`);
|
|
263
321
|
}
|
package/build/types.js
CHANGED
|
@@ -34,3 +34,19 @@ export function isValidSitemapArgs(args) {
|
|
|
34
34
|
}
|
|
35
35
|
return true;
|
|
36
36
|
}
|
|
37
|
+
export function isValidNewsArgs(args) {
|
|
38
|
+
if (typeof args !== 'object' || args === null) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
const { query, max_results, search_service } = args;
|
|
42
|
+
if (typeof query !== 'string' || query.trim().length === 0) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
if (max_results !== undefined && (typeof max_results !== 'number' || max_results < 1 || max_results > 50)) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
if (search_service !== undefined && typeof search_service !== 'string') {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
return true;
|
|
52
|
+
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "search1api-mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "A Model Context Protocol (MCP) server that provides search and crawl functionality using Search1API",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
8
|
-
"search1api-mcp": "
|
|
8
|
+
"search1api-mcp": "build/index.js"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"build"
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"license": "MIT",
|
|
38
38
|
"repository": {
|
|
39
39
|
"type": "git",
|
|
40
|
-
"url": "https://github.com/fatwang2/search1api-mcp"
|
|
40
|
+
"url": "git+https://github.com/fatwang2/search1api-mcp.git"
|
|
41
41
|
},
|
|
42
42
|
"engines": {
|
|
43
43
|
"node": ">=18.0.0"
|