@zenrows/mcp 2.0.0 → 2.0.1
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/http.js +17 -0
- package/dist/server.js +2 -4
- package/dist/tools/browser-fetch.js +1 -6
- package/package.json +1 -1
package/dist/http.js
CHANGED
|
@@ -59,6 +59,23 @@ app.post("/register", async (c) => {
|
|
|
59
59
|
...body,
|
|
60
60
|
}, 201);
|
|
61
61
|
});
|
|
62
|
+
// Proxy browser tool calls to internal service.
|
|
63
|
+
// npx clients default ZENROWS_BROWSER_URL to https://mcp.zenrows.com, so their
|
|
64
|
+
// /browser/* calls are forwarded here and proxied to the internal service.
|
|
65
|
+
const BROWSER_URL = process.env.ZENROWS_BROWSER_URL;
|
|
66
|
+
app.all("/browser/*", async (c) => {
|
|
67
|
+
if (!BROWSER_URL) {
|
|
68
|
+
return c.json({ error: "Browser service not available." }, 503);
|
|
69
|
+
}
|
|
70
|
+
const target = `${BROWSER_URL.replace(/\/$/, "")}${c.req.path}`;
|
|
71
|
+
const req = new Request(target, {
|
|
72
|
+
method: c.req.method,
|
|
73
|
+
headers: c.req.raw.headers,
|
|
74
|
+
body: c.req.raw.body,
|
|
75
|
+
});
|
|
76
|
+
const res = await fetch(req);
|
|
77
|
+
return new Response(res.body, { status: res.status, headers: res.headers });
|
|
78
|
+
});
|
|
62
79
|
app.all("/mcp", async (c) => {
|
|
63
80
|
const apiKey = extractApiKey(c.req.raw);
|
|
64
81
|
if (!apiKey) {
|
package/dist/server.js
CHANGED
|
@@ -260,9 +260,7 @@ Examples:
|
|
|
260
260
|
},
|
|
261
261
|
],
|
|
262
262
|
}));
|
|
263
|
-
const BROWSER_URL = process.env.ZENROWS_BROWSER_URL;
|
|
264
|
-
|
|
265
|
-
registerBrowserTools(server, apiKey, BROWSER_URL);
|
|
266
|
-
}
|
|
263
|
+
const BROWSER_URL = process.env.ZENROWS_BROWSER_URL ?? "https://mcp.zenrows.com";
|
|
264
|
+
registerBrowserTools(server, apiKey, BROWSER_URL);
|
|
267
265
|
return server;
|
|
268
266
|
}
|
|
@@ -12,12 +12,7 @@ export async function browserFetch(method, path, apiKey, browserUrl, body) {
|
|
|
12
12
|
const response = await fetch(url, init);
|
|
13
13
|
let data;
|
|
14
14
|
const contentType = response.headers.get("content-type") ?? "";
|
|
15
|
-
|
|
16
|
-
data = await response.json();
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
data = await response.text();
|
|
20
|
-
}
|
|
15
|
+
data = contentType.includes("application/json") ? await response.json() : await response.text();
|
|
21
16
|
return { ok: response.ok, status: response.status, data };
|
|
22
17
|
}
|
|
23
18
|
export function browserError(result) {
|