@deventerprisesoftware/scrapi-mcp 0.2.0 → 0.2.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/dist/index.js +8 -14
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import { z } from "zod";
|
|
|
8
8
|
const PORT = process.env.PORT || 5000;
|
|
9
9
|
const SCRAPI_API_KEY = process.env.SCRAPI_API_KEY || "00000000-0000-0000-0000-000000000000";
|
|
10
10
|
const SCRAPI_SERVER_NAME = "ScrAPI MCP Server";
|
|
11
|
-
const SCRAPI_SERVER_VERSION = "0.2.
|
|
11
|
+
const SCRAPI_SERVER_VERSION = "0.2.2";
|
|
12
12
|
const app = express();
|
|
13
13
|
app.use(cors({
|
|
14
14
|
origin: "*",
|
|
@@ -135,6 +135,9 @@ export default function createServer({ config, }) {
|
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
try {
|
|
138
|
+
const requestBody = JSON.stringify(body);
|
|
139
|
+
console.log(`Using ScrAPI on URL: ${url} with format: ${format}`);
|
|
140
|
+
console.log(`Request body: ${requestBody}`);
|
|
138
141
|
const response = await fetch("https://api.scrapi.tech/v1/scrape", {
|
|
139
142
|
method: "POST",
|
|
140
143
|
headers: {
|
|
@@ -142,7 +145,7 @@ export default function createServer({ config, }) {
|
|
|
142
145
|
"Content-Type": "application/json",
|
|
143
146
|
"X-API-KEY": config.scrapiApiKey || SCRAPI_API_KEY,
|
|
144
147
|
},
|
|
145
|
-
body:
|
|
148
|
+
body: requestBody,
|
|
146
149
|
signal: AbortSignal.timeout(300000),
|
|
147
150
|
});
|
|
148
151
|
const data = await response.text();
|
|
@@ -206,7 +209,7 @@ app.all("/mcp", async (req, res) => {
|
|
|
206
209
|
await transport.handleRequest(req, res, req.body);
|
|
207
210
|
}
|
|
208
211
|
catch (error) {
|
|
209
|
-
console.error("Error handling MCP request:", error);
|
|
212
|
+
console.error("Error handling ScrAPI MCP request:", error);
|
|
210
213
|
if (!res.headersSent) {
|
|
211
214
|
res.status(500).json({
|
|
212
215
|
jsonrpc: "2.0",
|
|
@@ -216,22 +219,13 @@ app.all("/mcp", async (req, res) => {
|
|
|
216
219
|
}
|
|
217
220
|
}
|
|
218
221
|
});
|
|
219
|
-
app.options("/*", (req, res) => {
|
|
220
|
-
const reqHeaders = req.header("access-control-request-headers");
|
|
221
|
-
if (reqHeaders) {
|
|
222
|
-
res.setHeader("Access-Control-Allow-Headers", reqHeaders);
|
|
223
|
-
}
|
|
224
|
-
res.setHeader("Access-Control-Allow-Methods", "GET,POST,OPTIONS");
|
|
225
|
-
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
226
|
-
res.sendStatus(204);
|
|
227
|
-
});
|
|
228
222
|
// Main function to start the server in the appropriate mode
|
|
229
223
|
async function main() {
|
|
230
224
|
const transport = process.env.TRANSPORT || "stdio";
|
|
231
225
|
if (transport === "http") {
|
|
232
226
|
// Run in HTTP mode
|
|
233
227
|
app.listen(PORT, () => {
|
|
234
|
-
console.log(`MCP HTTP Server listening on port ${PORT}`);
|
|
228
|
+
console.log(`ScrAPI MCP HTTP Server version ${SCRAPI_SERVER_VERSION} listening on port ${PORT}`);
|
|
235
229
|
});
|
|
236
230
|
}
|
|
237
231
|
else {
|
|
@@ -245,7 +239,7 @@ async function main() {
|
|
|
245
239
|
// Start receiving messages on stdin and sending messages on stdout
|
|
246
240
|
const stdioTransport = new StdioServerTransport();
|
|
247
241
|
await server.connect(stdioTransport);
|
|
248
|
-
console.error(
|
|
242
|
+
console.error(`ScrAPI MCP Server version ${SCRAPI_SERVER_VERSION} running in stdio mode`);
|
|
249
243
|
}
|
|
250
244
|
}
|
|
251
245
|
// Start the server
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deventerprisesoftware/scrapi-mcp",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "MCP server for using ScrAPI to scrape web pages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mcp",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/cors": "^2.8.19",
|
|
47
47
|
"@types/express": "^5.0.6",
|
|
48
|
-
"@types/node": "^25.0.
|
|
48
|
+
"@types/node": "^25.0.6",
|
|
49
49
|
"shx": "^0.4.0",
|
|
50
50
|
"typescript": "^5.9.3"
|
|
51
51
|
}
|