mcp-google-ads 1.0.7 → 1.0.9
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 +32 -21
- package/dist/resilience.js +5 -2
- package/package.json +2 -2
package/dist/build-info.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"sha":"
|
|
1
|
+
{"sha":"ac23879","builtAt":"2026-04-09T21:37:02.993Z"}
|
package/dist/index.js
CHANGED
|
@@ -8,31 +8,36 @@ import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextpro
|
|
|
8
8
|
import { tools } from "./tools.js";
|
|
9
9
|
import { GoogleAdsApi, enums } from "google-ads-api";
|
|
10
10
|
import { readFileSync, existsSync } from "fs";
|
|
11
|
+
// CLI package info
|
|
12
|
+
const __cliPkg = JSON.parse(readFileSync(join(dirname(new URL(import.meta.url).pathname), "..", "package.json"), "utf-8"));
|
|
11
13
|
// Log build fingerprint at startup
|
|
12
14
|
try {
|
|
13
15
|
const __buildInfoDir = dirname(new URL(import.meta.url).pathname);
|
|
14
16
|
const buildInfo = JSON.parse(readFileSync(join(__buildInfoDir, "build-info.json"), "utf-8"));
|
|
15
|
-
|
|
17
|
+
console.error(`[build] SHA: ${buildInfo.sha} (${buildInfo.builtAt})`);
|
|
16
18
|
}
|
|
17
19
|
catch {
|
|
18
|
-
|
|
20
|
+
console.error(`[build] ${__cliPkg.name}@${__cliPkg.version} (dev mode)`);
|
|
19
21
|
}
|
|
20
22
|
// CLI flags
|
|
21
|
-
const __cliPkg = JSON.parse(readFileSync(join(dirname(new URL(import.meta.url).pathname), "..", "package.json"), "utf-8"));
|
|
22
23
|
if (process.argv.includes("--help") || process.argv.includes("-h")) {
|
|
23
|
-
console.
|
|
24
|
-
console.
|
|
25
|
-
console.
|
|
26
|
-
console.
|
|
27
|
-
console.
|
|
28
|
-
console.
|
|
29
|
-
console.
|
|
24
|
+
console.error(`${__cliPkg.name} v${__cliPkg.version}\n`);
|
|
25
|
+
console.error(`Usage: ${__cliPkg.name} [options]\n`);
|
|
26
|
+
console.error("MCP server communicating via stdio. Configure in your .mcp.json.\n");
|
|
27
|
+
console.error("Options:");
|
|
28
|
+
console.error(" --help, -h Show this help message");
|
|
29
|
+
console.error(" --version, -v Show version number");
|
|
30
|
+
console.error(`\nDocumentation: https://github.com/mharnett/mcp-google-ads`);
|
|
30
31
|
process.exit(0);
|
|
31
32
|
}
|
|
32
33
|
if (process.argv.includes("--version") || process.argv.includes("-v")) {
|
|
33
|
-
console.
|
|
34
|
+
console.error(__cliPkg.version);
|
|
34
35
|
process.exit(0);
|
|
35
36
|
}
|
|
37
|
+
// ============================================
|
|
38
|
+
// ENV VAR TRIMMING
|
|
39
|
+
// ============================================
|
|
40
|
+
const envTrimmed = (key) => (process.env[key] || "").trim().replace(/^["']|["']$/g, "");
|
|
36
41
|
function loadConfig() {
|
|
37
42
|
// Try config.json first (for multi-client setups)
|
|
38
43
|
const configPath = join(dirname(new URL(import.meta.url).pathname), "..", "config.json");
|
|
@@ -40,12 +45,12 @@ function loadConfig() {
|
|
|
40
45
|
return JSON.parse(readFileSync(configPath, "utf-8"));
|
|
41
46
|
}
|
|
42
47
|
// Fall back to env vars (single-client mode)
|
|
43
|
-
const clientId =
|
|
44
|
-
const clientSecret =
|
|
45
|
-
const developerToken =
|
|
46
|
-
const refreshToken =
|
|
47
|
-
const customerId =
|
|
48
|
-
const mccId =
|
|
48
|
+
const clientId = envTrimmed("GOOGLE_ADS_CLIENT_ID");
|
|
49
|
+
const clientSecret = envTrimmed("GOOGLE_ADS_CLIENT_SECRET");
|
|
50
|
+
const developerToken = envTrimmed("GOOGLE_ADS_DEVELOPER_TOKEN");
|
|
51
|
+
const refreshToken = envTrimmed("GOOGLE_ADS_REFRESH_TOKEN");
|
|
52
|
+
const customerId = envTrimmed("GOOGLE_ADS_CUSTOMER_ID");
|
|
53
|
+
const mccId = envTrimmed("GOOGLE_ADS_MCC_CUSTOMER_ID");
|
|
49
54
|
if (!clientId || !clientSecret || !developerToken || !refreshToken) {
|
|
50
55
|
throw new Error("No configuration found. Either:\n" +
|
|
51
56
|
" 1. Set env vars: GOOGLE_ADS_CLIENT_ID, GOOGLE_ADS_CLIENT_SECRET, GOOGLE_ADS_DEVELOPER_TOKEN, GOOGLE_ADS_REFRESH_TOKEN, GOOGLE_ADS_CUSTOMER_ID\n" +
|
|
@@ -112,11 +117,11 @@ class GoogleAdsManager {
|
|
|
112
117
|
throw new GoogleAdsAuthError(msg);
|
|
113
118
|
}
|
|
114
119
|
logger.info("Credentials validated: all required env vars present");
|
|
115
|
-
this.defaultRefreshToken =
|
|
120
|
+
this.defaultRefreshToken = envTrimmed("GOOGLE_ADS_REFRESH_TOKEN");
|
|
116
121
|
this.api = new GoogleAdsApi({
|
|
117
|
-
client_id:
|
|
118
|
-
client_secret:
|
|
119
|
-
developer_token:
|
|
122
|
+
client_id: envTrimmed("GOOGLE_ADS_CLIENT_ID"),
|
|
123
|
+
client_secret: envTrimmed("GOOGLE_ADS_CLIENT_SECRET"),
|
|
124
|
+
developer_token: envTrimmed("GOOGLE_ADS_DEVELOPER_TOKEN"),
|
|
120
125
|
});
|
|
121
126
|
}
|
|
122
127
|
getClientForCustomerId(customerId) {
|
|
@@ -1814,4 +1819,10 @@ process.on("SIGINT", () => {
|
|
|
1814
1819
|
console.error("[shutdown] SIGINT received, exiting");
|
|
1815
1820
|
process.exit(0);
|
|
1816
1821
|
});
|
|
1822
|
+
process.on("SIGPIPE", () => {
|
|
1823
|
+
// Client disconnected -- expected during shutdown
|
|
1824
|
+
});
|
|
1825
|
+
process.on("unhandledRejection", (reason) => {
|
|
1826
|
+
console.error("[error] Unhandled promise rejection:", reason);
|
|
1827
|
+
});
|
|
1817
1828
|
main().catch((err) => logger.error({ error: err.message, stack: err.stack }, "Fatal startup error"));
|
package/dist/resilience.js
CHANGED
|
@@ -5,17 +5,20 @@ import pino from "pino";
|
|
|
5
5
|
// ============================================
|
|
6
6
|
export const logger = pino({
|
|
7
7
|
level: process.env.LOG_LEVEL || "info",
|
|
8
|
-
...(process.env.NODE_ENV !== "test" && {
|
|
8
|
+
...(process.env.NODE_ENV !== "test" && process.stderr.isTTY && {
|
|
9
9
|
transport: {
|
|
10
10
|
target: "pino-pretty",
|
|
11
11
|
options: {
|
|
12
12
|
colorize: true,
|
|
13
13
|
singleLine: true,
|
|
14
14
|
translateTime: "SYS:standard",
|
|
15
|
+
destination: 2, // stderr -- stdout is reserved for MCP JSON-RPC
|
|
15
16
|
},
|
|
16
17
|
},
|
|
17
18
|
}),
|
|
18
|
-
}
|
|
19
|
+
},
|
|
20
|
+
// When no transport (test mode), write to stderr directly
|
|
21
|
+
process.env.NODE_ENV === "test" ? pino.destination(2) : undefined);
|
|
19
22
|
// ============================================
|
|
20
23
|
// SAFE RESPONSE (Response Size Limiting)
|
|
21
24
|
// ============================================
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-google-ads",
|
|
3
3
|
"mcpName": "io.github.mharnett/google-ads",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.9",
|
|
5
5
|
"description": "MCP server for Google Ads API with MCC support, 35 tools for campaign management, reporting, and optimization. Safe by default — all changes created PAUSED.",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"bin": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"homepage": "https://github.com/mharnett/mcp-google-ads#readme",
|
|
55
55
|
"engines": {
|
|
56
|
-
"node": ">=18.
|
|
56
|
+
"node": ">=18.18.0"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"@anthropic-ai/sdk": "^0.24.0",
|