mcp-ga4 2.0.4 → 2.0.6
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/build-info.json +1 -1
- package/dist/index.js +23 -12
- package/dist/resilience.js +5 -2
- package/package.json +2 -2
package/dist/build-info.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"sha":"
|
|
1
|
+
{"sha":"9f7d432","builtAt":"2026-04-09T21:37:39.488Z"}
|
package/dist/index.js
CHANGED
|
@@ -11,6 +11,8 @@ import { GoogleAuth } from "google-auth-library";
|
|
|
11
11
|
import { Ga4AuthError, Ga4RateLimitError, Ga4ServiceError, classifyError, } from "./errors.js";
|
|
12
12
|
import { tools } from "./tools.js";
|
|
13
13
|
import { withResilience, safeResponse, logger } from "./resilience.js";
|
|
14
|
+
// CLI package info
|
|
15
|
+
const __cliPkg = JSON.parse(readFileSync(join(dirname(new URL(import.meta.url).pathname), "..", "package.json"), "utf-8"));
|
|
14
16
|
// Log build fingerprint at startup
|
|
15
17
|
try {
|
|
16
18
|
const __buildInfoDir = dirname(new URL(import.meta.url).pathname);
|
|
@@ -18,28 +20,31 @@ try {
|
|
|
18
20
|
console.error(`[build] SHA: ${buildInfo.sha} (${buildInfo.builtAt})`);
|
|
19
21
|
}
|
|
20
22
|
catch {
|
|
21
|
-
|
|
23
|
+
console.error(`[build] ${__cliPkg.name}@${__cliPkg.version} (dev mode)`);
|
|
22
24
|
}
|
|
23
25
|
// CLI flags
|
|
24
|
-
const __cliPkg = JSON.parse(readFileSync(join(dirname(new URL(import.meta.url).pathname), "..", "package.json"), "utf-8"));
|
|
25
26
|
if (process.argv.includes("--help") || process.argv.includes("-h")) {
|
|
26
|
-
console.
|
|
27
|
-
console.
|
|
28
|
-
console.
|
|
29
|
-
console.
|
|
30
|
-
console.
|
|
31
|
-
console.
|
|
32
|
-
console.
|
|
27
|
+
console.error(`${__cliPkg.name} v${__cliPkg.version}\n`);
|
|
28
|
+
console.error(`Usage: ${__cliPkg.name} [options]\n`);
|
|
29
|
+
console.error("MCP server communicating via stdio. Configure in your .mcp.json.\n");
|
|
30
|
+
console.error("Options:");
|
|
31
|
+
console.error(" --help, -h Show this help message");
|
|
32
|
+
console.error(" --version, -v Show version number");
|
|
33
|
+
console.error(`\nDocumentation: https://github.com/mharnett/mcp-ga4`);
|
|
33
34
|
process.exit(0);
|
|
34
35
|
}
|
|
35
36
|
if (process.argv.includes("--version") || process.argv.includes("-v")) {
|
|
36
|
-
console.
|
|
37
|
+
console.error(__cliPkg.version);
|
|
37
38
|
process.exit(0);
|
|
38
39
|
}
|
|
40
|
+
// ============================================
|
|
41
|
+
// ENV VAR TRIMMING
|
|
42
|
+
// ============================================
|
|
43
|
+
const envTrimmed = (key) => (process.env[key] || "").trim().replace(/^["']|["']$/g, "");
|
|
39
44
|
function loadConfig() {
|
|
40
45
|
// Single-property mode via env vars
|
|
41
|
-
const propertyId =
|
|
42
|
-
const credsFile =
|
|
46
|
+
const propertyId = envTrimmed("GA4_PROPERTY_ID");
|
|
47
|
+
const credsFile = envTrimmed("GOOGLE_APPLICATION_CREDENTIALS");
|
|
43
48
|
if (propertyId) {
|
|
44
49
|
return {
|
|
45
50
|
credentials_file: credsFile,
|
|
@@ -451,4 +456,10 @@ process.on("SIGINT", () => {
|
|
|
451
456
|
console.error("[shutdown] SIGINT received, exiting");
|
|
452
457
|
process.exit(0);
|
|
453
458
|
});
|
|
459
|
+
process.on("SIGPIPE", () => {
|
|
460
|
+
// Client disconnected -- expected during shutdown
|
|
461
|
+
});
|
|
462
|
+
process.on("unhandledRejection", (reason) => {
|
|
463
|
+
console.error("[error] Unhandled promise rejection:", reason);
|
|
464
|
+
});
|
|
454
465
|
main().catch(console.error);
|
package/dist/resilience.js
CHANGED
|
@@ -2,17 +2,20 @@ import { retry, circuitBreaker, wrap, handleWhen, timeout, TimeoutStrategy, Expo
|
|
|
2
2
|
import pino from "pino";
|
|
3
3
|
export const logger = pino({
|
|
4
4
|
level: process.env.LOG_LEVEL || "info",
|
|
5
|
-
...(process.env.NODE_ENV !== "test" && {
|
|
5
|
+
...(process.env.NODE_ENV !== "test" && process.stderr.isTTY && {
|
|
6
6
|
transport: {
|
|
7
7
|
target: "pino-pretty",
|
|
8
8
|
options: {
|
|
9
9
|
colorize: true,
|
|
10
10
|
singleLine: true,
|
|
11
11
|
translateTime: "SYS:standard",
|
|
12
|
+
destination: 2, // stderr -- stdout is reserved for MCP JSON-RPC
|
|
12
13
|
},
|
|
13
14
|
},
|
|
14
15
|
}),
|
|
15
|
-
}
|
|
16
|
+
},
|
|
17
|
+
// When no transport (test mode), write to stderr directly
|
|
18
|
+
process.env.NODE_ENV === "test" ? pino.destination(2) : undefined);
|
|
16
19
|
const MAX_RESPONSE_SIZE = 200_000;
|
|
17
20
|
export function safeResponse(data, context) {
|
|
18
21
|
let current = data;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-ga4",
|
|
3
3
|
"mcpName": "io.github.mharnett/ga4",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.6",
|
|
5
5
|
"description": "MCP server for Google Analytics 4 - query GA4 data with natural language via Claude.",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"bin": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"author": "drak-marketing",
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"engines": {
|
|
33
|
-
"node": ">=18.
|
|
33
|
+
"node": ">=18.18.0"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@google-analytics/admin": "^9.0.1",
|