search1api-mcp 0.1.1 → 0.1.2
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/LICENSE +21 -0
- package/README.md +9 -2
- package/build/index.js +37 -4
- package/build/types.js +10 -0
- package/package.json +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 fatwang2
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -5,9 +5,9 @@ A Model Context Protocol (MCP) server that provides search and crawl functionali
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
7
|
- Web search functionality through Search1API
|
|
8
|
-
- Web page content extraction
|
|
8
|
+
- Web page content extraction
|
|
9
|
+
- Website sitemap extraction
|
|
9
10
|
- Seamless integration with Claude Desktop
|
|
10
|
-
- Support for Google search engine
|
|
11
11
|
|
|
12
12
|
## Tools
|
|
13
13
|
|
|
@@ -25,6 +25,12 @@ A Model Context Protocol (MCP) server that provides search and crawl functionali
|
|
|
25
25
|
- Parameters:
|
|
26
26
|
* `url` (required): URL to crawl
|
|
27
27
|
|
|
28
|
+
### 3. Sitemap Tool
|
|
29
|
+
- Name: `sitemap`
|
|
30
|
+
- Description: Get all related links from a URL
|
|
31
|
+
- Parameters:
|
|
32
|
+
* `url` (required): URL to get sitemap
|
|
33
|
+
|
|
28
34
|
## Setup Guide
|
|
29
35
|
|
|
30
36
|
### 1. Get Search1API Key
|
|
@@ -55,6 +61,7 @@ Configuration file location:
|
|
|
55
61
|
|
|
56
62
|
## Version History
|
|
57
63
|
|
|
64
|
+
- v0.1.2: Added sitemap functionality
|
|
58
65
|
- v0.1.1: Added web crawling functionality
|
|
59
66
|
- v0.1.0: Initial release with search functionality
|
|
60
67
|
|
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 } from "./types.js";
|
|
6
|
+
import { isValidSearchArgs, isValidCrawlArgs, isValidSitemapArgs } from "./types.js";
|
|
7
7
|
dotenv.config();
|
|
8
8
|
const API_KEY = process.env.SEARCH1API_KEY;
|
|
9
9
|
if (!API_KEY) {
|
|
@@ -14,7 +14,8 @@ const API_CONFIG = {
|
|
|
14
14
|
DEFAULT_QUERY: 'latest news in the world',
|
|
15
15
|
ENDPOINTS: {
|
|
16
16
|
SEARCH: '/search',
|
|
17
|
-
CRAWL: '/crawl'
|
|
17
|
+
CRAWL: '/crawl',
|
|
18
|
+
SITEMAP: '/sitemap'
|
|
18
19
|
}
|
|
19
20
|
};
|
|
20
21
|
const SEARCH_TOOL = {
|
|
@@ -43,7 +44,7 @@ const SEARCH_TOOL = {
|
|
|
43
44
|
};
|
|
44
45
|
const CRAWL_TOOL = {
|
|
45
46
|
name: "crawl",
|
|
46
|
-
description: "
|
|
47
|
+
description: "Extract content from URL",
|
|
47
48
|
inputSchema: {
|
|
48
49
|
type: "object",
|
|
49
50
|
properties: {
|
|
@@ -55,6 +56,20 @@ const CRAWL_TOOL = {
|
|
|
55
56
|
required: ["url"]
|
|
56
57
|
}
|
|
57
58
|
};
|
|
59
|
+
const SITEMAP_TOOL = {
|
|
60
|
+
name: "sitemap",
|
|
61
|
+
description: "Get all related links from a URL",
|
|
62
|
+
inputSchema: {
|
|
63
|
+
type: "object",
|
|
64
|
+
properties: {
|
|
65
|
+
url: {
|
|
66
|
+
type: "string",
|
|
67
|
+
description: "URL to get sitemap"
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
required: ["url"]
|
|
71
|
+
}
|
|
72
|
+
};
|
|
58
73
|
// Server implementation
|
|
59
74
|
const server = new Server({
|
|
60
75
|
name: "search1api-mcp",
|
|
@@ -167,7 +182,7 @@ server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
|
167
182
|
});
|
|
168
183
|
// Tool handlers
|
|
169
184
|
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
170
|
-
tools: [SEARCH_TOOL, CRAWL_TOOL],
|
|
185
|
+
tools: [SEARCH_TOOL, CRAWL_TOOL, SITEMAP_TOOL],
|
|
171
186
|
}));
|
|
172
187
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
173
188
|
try {
|
|
@@ -225,6 +240,24 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
225
240
|
};
|
|
226
241
|
}
|
|
227
242
|
}
|
|
243
|
+
case "sitemap": {
|
|
244
|
+
if (!isValidSitemapArgs(args)) {
|
|
245
|
+
throw new McpError(ErrorCode.InvalidParams, "Invalid sitemap arguments");
|
|
246
|
+
}
|
|
247
|
+
try {
|
|
248
|
+
const response = await makeRequest(API_CONFIG.ENDPOINTS.SITEMAP, args);
|
|
249
|
+
return {
|
|
250
|
+
content: [{
|
|
251
|
+
type: "text",
|
|
252
|
+
mimeType: "application/json",
|
|
253
|
+
text: JSON.stringify(response.links, null, 2)
|
|
254
|
+
}]
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
catch (error) {
|
|
258
|
+
throw formatError(error);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
228
261
|
default:
|
|
229
262
|
throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${name}`);
|
|
230
263
|
}
|
package/build/types.js
CHANGED
|
@@ -24,3 +24,13 @@ export function isValidCrawlArgs(args) {
|
|
|
24
24
|
}
|
|
25
25
|
return true;
|
|
26
26
|
}
|
|
27
|
+
export function isValidSitemapArgs(args) {
|
|
28
|
+
if (typeof args !== 'object' || args === null) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
const { url } = args;
|
|
32
|
+
if (typeof url !== 'string' || url.trim().length === 0) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
return true;
|
|
36
|
+
}
|