@deventerprisesoftware/scrapi-mcp 0.3.2 → 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/dist/index.js +25 -15
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -7,7 +7,22 @@ import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/
|
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
import { createRequire } from "module";
|
|
9
9
|
const require = createRequire(import.meta.url);
|
|
10
|
-
|
|
10
|
+
function getServerVersion() {
|
|
11
|
+
const packageJsonCandidates = ["./package.json", "../package.json"];
|
|
12
|
+
for (const packageJsonPath of packageJsonCandidates) {
|
|
13
|
+
try {
|
|
14
|
+
const { version } = require(packageJsonPath);
|
|
15
|
+
if (typeof version === "string" && version.trim() !== "") {
|
|
16
|
+
return version;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
// Try next candidate path.
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return "0.0.0";
|
|
24
|
+
}
|
|
25
|
+
const SCRAPI_SERVER_VERSION = getServerVersion();
|
|
11
26
|
const PORT = process.env.PORT || 5000;
|
|
12
27
|
const SCRAPI_API_KEY = process.env.SCRAPI_API_KEY || "00000000-0000-0000-0000-000000000000";
|
|
13
28
|
const SCRAPI_SERVER_NAME = "ScrAPI MCP Server";
|
|
@@ -34,6 +49,13 @@ const BROWSER_COMMANDS_DESCRIPTION = "BROWSER COMMANDS: You can optionally provi
|
|
|
34
49
|
'- WaitFor: {"waitfor": "#elementId"} - Wait for element to appear\n' +
|
|
35
50
|
'- JavaScript: {"javascript": "console.log(\'test\')"} - Execute custom JS\n' +
|
|
36
51
|
'Example: [{"click": "#accept-cookies"}, {"wait": 2000}, {"input": {"input[name=\'search\']": "query"}}]';
|
|
52
|
+
export const scrapeToolInputSchema = {
|
|
53
|
+
url: z.string().url({ error: "Invalid URL" }).describe("The URL to scrape"),
|
|
54
|
+
browserCommands: z
|
|
55
|
+
.string()
|
|
56
|
+
.optional()
|
|
57
|
+
.describe("Optional JSON array of browser commands to execute before scraping. See tool description for available commands and format."),
|
|
58
|
+
};
|
|
37
59
|
// Parse configuration from query parameters
|
|
38
60
|
export function parseConfig(req) {
|
|
39
61
|
const configParam = req.query["config"];
|
|
@@ -64,13 +86,7 @@ export default function createServer({ config }) {
|
|
|
64
86
|
"Use this for scraping website content that is difficult to access because of bot detection, captchas or even geolocation restrictions. " +
|
|
65
87
|
"The result will be in HTML which is preferable if advanced parsing is required.\n\n" +
|
|
66
88
|
BROWSER_COMMANDS_DESCRIPTION,
|
|
67
|
-
inputSchema:
|
|
68
|
-
url: z.string().url({ message: "Invalid URL" }).describe("The URL to scrape"),
|
|
69
|
-
browserCommands: z
|
|
70
|
-
.string()
|
|
71
|
-
.optional()
|
|
72
|
-
.describe("Optional JSON array of browser commands to execute before scraping. See tool description for available commands and format."),
|
|
73
|
-
},
|
|
89
|
+
inputSchema: scrapeToolInputSchema,
|
|
74
90
|
}, async ({ url, browserCommands }) => await scrapeUrl(url, "HTML", config.scrapiApiKey || SCRAPI_API_KEY, browserCommands));
|
|
75
91
|
server.registerTool("scrape_url_markdown", {
|
|
76
92
|
title: "Scrape URL and respond with Markdown",
|
|
@@ -78,13 +94,7 @@ export default function createServer({ config }) {
|
|
|
78
94
|
"Use this for scraping website content that is difficult to access because of bot detection, captchas or even geolocation restrictions. " +
|
|
79
95
|
"The result will be in Markdown which is preferable if the text content of the webpage is important and not the structural information of the page.\n\n" +
|
|
80
96
|
BROWSER_COMMANDS_DESCRIPTION,
|
|
81
|
-
inputSchema:
|
|
82
|
-
url: z.string().url({ message: "Invalid URL" }).describe("The URL to scrape"),
|
|
83
|
-
browserCommands: z
|
|
84
|
-
.string()
|
|
85
|
-
.optional()
|
|
86
|
-
.describe("Optional JSON array of browser commands to execute before scraping. See tool description for available commands and format."),
|
|
87
|
-
},
|
|
97
|
+
inputSchema: scrapeToolInputSchema,
|
|
88
98
|
}, async ({ url, browserCommands }) => await scrapeUrl(url, "Markdown", config.scrapiApiKey || SCRAPI_API_KEY, browserCommands));
|
|
89
99
|
return server.server;
|
|
90
100
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deventerprisesoftware/scrapi-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "MCP server for using ScrAPI to scrape web pages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mcp",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
47
47
|
"cors": "^2.8.6",
|
|
48
48
|
"express": "^5.2.1",
|
|
49
|
-
"zod": "^
|
|
49
|
+
"zod": "^4.4.3"
|
|
50
50
|
},
|
|
51
51
|
"engines": {
|
|
52
52
|
"node": ">=18"
|