mobile-growth-mcp 2.3.5 → 2.3.7
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 +47 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9,27 +9,59 @@ import { z } from "zod";
|
|
|
9
9
|
var EDGE_FUNCTION_URL = "https://iattgvzqiqrpzoqnrwfr.supabase.co/functions/v1/mcp";
|
|
10
10
|
var nextRequestId = 1;
|
|
11
11
|
async function jsonRpcRequest(apiKey2, method, params) {
|
|
12
|
+
const id = nextRequestId++;
|
|
12
13
|
const body = {
|
|
13
14
|
jsonrpc: "2.0",
|
|
14
15
|
method,
|
|
15
|
-
id
|
|
16
|
+
id
|
|
16
17
|
};
|
|
17
18
|
if (params) body.params = params;
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
const toolName = params?.name ?? "";
|
|
20
|
+
const label = toolName ? `${method}:${toolName}` : method;
|
|
21
|
+
const t0 = Date.now();
|
|
22
|
+
console.error(`[proxy] \u2192 #${id} ${label} start`);
|
|
23
|
+
try {
|
|
24
|
+
const res = await fetch(EDGE_FUNCTION_URL, {
|
|
25
|
+
method: "POST",
|
|
26
|
+
headers: {
|
|
27
|
+
"Content-Type": "application/json",
|
|
28
|
+
"x-api-key": apiKey2,
|
|
29
|
+
Accept: "application/json, text/event-stream"
|
|
30
|
+
},
|
|
31
|
+
body: JSON.stringify(body),
|
|
32
|
+
signal: AbortSignal.timeout(15e3)
|
|
33
|
+
});
|
|
34
|
+
const headersMs = Date.now() - t0;
|
|
35
|
+
if (!res.ok) {
|
|
36
|
+
const text = await res.text();
|
|
37
|
+
console.error(
|
|
38
|
+
`[proxy] \u2717 #${id} ${label} http ${res.status} after ${headersMs}ms`
|
|
39
|
+
);
|
|
40
|
+
throw new Error(`Edge Function error (${res.status}): ${text}`);
|
|
41
|
+
}
|
|
42
|
+
const contentType = res.headers.get("content-type") ?? "";
|
|
43
|
+
let json;
|
|
44
|
+
if (contentType.includes("text/event-stream")) {
|
|
45
|
+
const text = await res.text();
|
|
46
|
+
const match = text.match(/^data:\s*(.+)$/m);
|
|
47
|
+
if (!match) {
|
|
48
|
+
throw new Error(`SSE response had no data line: ${text.slice(0, 200)}`);
|
|
49
|
+
}
|
|
50
|
+
json = JSON.parse(match[1]);
|
|
51
|
+
} else {
|
|
52
|
+
json = await res.json();
|
|
53
|
+
}
|
|
54
|
+
console.error(
|
|
55
|
+
`[proxy] \u2190 #${id} ${label} ok in ${Date.now() - t0}ms (headers ${headersMs}ms, ct=${contentType.split(";")[0] || "?"})`
|
|
56
|
+
);
|
|
57
|
+
return json;
|
|
58
|
+
} catch (err) {
|
|
59
|
+
const e = err;
|
|
60
|
+
console.error(
|
|
61
|
+
`[proxy] \u2717 #${id} ${label} ${e.name}: ${e.message} after ${Date.now() - t0}ms`
|
|
62
|
+
);
|
|
63
|
+
throw err;
|
|
31
64
|
}
|
|
32
|
-
return await res.json();
|
|
33
65
|
}
|
|
34
66
|
async function fetchRemoteTools(apiKey2) {
|
|
35
67
|
const resp = await jsonRpcRequest(apiKey2, "tools/list");
|
package/package.json
CHANGED