google-tools-mcp 1.0.13 → 1.0.14

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/README.md CHANGED
@@ -235,6 +235,7 @@ Google Forms — create/read forms, manage responses, and publish settings.
235
235
  | `GOOGLE_CLIENT_SECRET` | No* | OAuth 2.0 Client Secret |
236
236
  | `GOOGLE_MCP_PROFILE` | No | Profile name for multi-account support (see above) |
237
237
  | `LOG_LEVEL` | No | `debug`, `info`, `warn`, `error`, or `silent` |
238
+ | `GOOGLE_MCP_LOG_FILE` | No | Set to `1` to log to `~/.config/google-tools-mcp/server.log`, or set to a custom file path |
238
239
  | `SERVICE_ACCOUNT_PATH` | No | Path to service account JSON key (alternative to OAuth) |
239
240
  | `GOOGLE_IMPERSONATE_USER` | No | Email to impersonate with service account |
240
241
 
package/dist/auth.js CHANGED
@@ -271,12 +271,16 @@ export async function authorize() {
271
271
  if (client) {
272
272
  // Proactively refresh to verify the token is still valid
273
273
  try {
274
+ logger.info('Refreshing access token...');
274
275
  const { credentials } = await client.refreshAccessToken();
275
276
  client.setCredentials(credentials);
276
277
  if (credentials.refresh_token) {
277
278
  await saveCredentials(client);
278
279
  }
279
- logger.info('Using saved credentials (token refreshed successfully).');
280
+ const expiryDate = credentials.expiry_date
281
+ ? new Date(credentials.expiry_date).toISOString()
282
+ : 'unknown';
283
+ logger.info(`Token refreshed successfully. Expires: ${expiryDate}`);
280
284
  return client;
281
285
  } catch (err) {
282
286
  const isInvalidGrant = err.message?.includes('invalid_grant') ||
@@ -286,6 +290,7 @@ export async function authorize() {
286
290
  try { await fs.unlink(getTokenPath()); } catch {}
287
291
  return authenticate();
288
292
  }
293
+ logger.error('Token refresh failed:', err.message || err);
289
294
  throw err;
290
295
  }
291
296
  }
package/dist/index.js CHANGED
@@ -24,14 +24,26 @@ if (process.argv[2] === 'auth') {
24
24
  }
25
25
  }
26
26
 
27
- // --- Server startup ---
27
+ // --- Process lifecycle logging ---
28
28
  process.on('uncaughtException', (error) => {
29
29
  logger.error('Uncaught Exception:', error);
30
30
  });
31
31
  process.on('unhandledRejection', (reason, _promise) => {
32
32
  logger.error('Unhandled Promise Rejection:', reason);
33
33
  });
34
+ process.on('SIGINT', () => {
35
+ logger.info('Received SIGINT — shutting down.');
36
+ process.exit(0);
37
+ });
38
+ process.on('SIGTERM', () => {
39
+ logger.info('Received SIGTERM — shutting down.');
40
+ process.exit(0);
41
+ });
42
+ process.on('exit', (code) => {
43
+ logger.info(`Process exiting with code ${code}.`);
44
+ });
34
45
 
46
+ // --- Server startup ---
35
47
  const server = new FastMCP({
36
48
  name: 'google-tools-mcp',
37
49
  version: '1.0.0',
package/dist/logger.js CHANGED
@@ -1,5 +1,10 @@
1
1
  // Centralized logger with LOG_LEVEL support.
2
2
  // All log output goes to stderr (stdout reserved for MCP protocol).
3
+ // If GOOGLE_MCP_LOG_FILE is set, logs are also appended to that file.
4
+ import * as fs from 'fs';
5
+ import * as path from 'path';
6
+ import * as os from 'os';
7
+
3
8
  const LOG_LEVELS = {
4
9
  debug: 0,
5
10
  info: 1,
@@ -21,25 +26,62 @@ export function refreshLogLevel() {
21
26
  function shouldLog(level) {
22
27
  return LOG_LEVELS[level] >= LOG_LEVELS[currentLevel];
23
28
  }
24
- export const logger = {
25
- debug(...args) {
26
- if (shouldLog('debug')) {
27
- console.error('[DEBUG]', ...args);
28
- }
29
- },
30
- info(...args) {
31
- if (shouldLog('info')) {
32
- console.error('[INFO]', ...args);
33
- }
34
- },
35
- warn(...args) {
36
- if (shouldLog('warn')) {
37
- console.error('[WARN]', ...args);
38
- }
39
- },
40
- error(...args) {
41
- if (shouldLog('error')) {
42
- console.error('[ERROR]', ...args);
29
+
30
+ // --- File logging ---
31
+ let logStream = null;
32
+
33
+ function getDefaultLogPath() {
34
+ const xdg = process.env.XDG_CONFIG_HOME;
35
+ const base = xdg || path.join(os.homedir(), '.config');
36
+ const baseDir = path.join(base, 'google-tools-mcp');
37
+ const profile = process.env.GOOGLE_MCP_PROFILE;
38
+ const dir = profile ? path.join(baseDir, profile) : baseDir;
39
+ return path.join(dir, 'server.log');
40
+ }
41
+
42
+ function initLogFile() {
43
+ if (logStream) return;
44
+ const logPath = process.env.GOOGLE_MCP_LOG_FILE === '1'
45
+ ? getDefaultLogPath()
46
+ : process.env.GOOGLE_MCP_LOG_FILE;
47
+ if (!logPath) return;
48
+ try {
49
+ fs.mkdirSync(path.dirname(logPath), { recursive: true });
50
+ logStream = fs.createWriteStream(logPath, { flags: 'a' });
51
+ } catch {
52
+ // If we can't open the log file, continue without file logging
53
+ }
54
+ }
55
+ initLogFile();
56
+
57
+ function timestamp() {
58
+ return new Date().toISOString();
59
+ }
60
+
61
+ function formatArgs(args) {
62
+ return args.map(a => {
63
+ if (a instanceof Error) return a.stack || a.message;
64
+ if (typeof a === 'object') {
65
+ try { return JSON.stringify(a); } catch { return String(a); }
43
66
  }
44
- },
67
+ return String(a);
68
+ }).join(' ');
69
+ }
70
+
71
+ function log(level, args) {
72
+ if (!shouldLog(level)) return;
73
+ const tag = level.toUpperCase();
74
+ const ts = timestamp();
75
+ const msg = formatArgs(args);
76
+ console.error(`${ts} [${tag}] ${msg}`);
77
+ if (logStream) {
78
+ logStream.write(`${ts} [${tag}] ${msg}\n`);
79
+ }
80
+ }
81
+
82
+ export const logger = {
83
+ debug(...args) { log('debug', args); },
84
+ info(...args) { log('info', args); },
85
+ warn(...args) { log('warn', args); },
86
+ error(...args) { log('error', args); },
45
87
  };
@@ -6,9 +6,9 @@ export function register(server) {
6
6
  server.addTool({
7
7
  name: 'manage_event',
8
8
  description:
9
- 'Create, update, or delete a calendar event. Supports attendees, Google Meet, reminders, attachments, visibility, and transparency settings.',
9
+ 'Create, update, or delete a calendar event. Supports attendees, Google Meet, reminders, attachments, visibility, and transparency settings. IMPORTANT: To modify an existing event, always use action "update" with the existing event_id. Never delete and recreate an event to make changes — this destroys the event ID, attendee RSVPs, and sent notifications.',
10
10
  parameters: z.object({
11
- action: z.enum(['create', 'update', 'delete']).describe('The operation to perform.'),
11
+ action: z.enum(['create', 'update', 'delete']).describe('The operation to perform. Use "update" to modify existing events — do not delete and recreate. "delete" should only be used to permanently remove an event, not to redo one.'),
12
12
  calendar_id: z
13
13
  .string()
14
14
  .optional()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "google-tools-mcp",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "description": "Combined Google Workspace MCP server (Drive, Docs, Sheets, Gmail) with lazy-loaded tool categories",
5
5
  "type": "module",
6
6
  "bin": {