google-tools-mcp 1.2.8 → 1.2.10
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 +21 -6
- package/dist/auth.js +343 -325
- package/dist/clients.js +293 -213
- package/dist/index.js +85 -74
- package/dist/setup.js +453 -235
- package/dist/tools/sheets/deleteColumns.js +66 -0
- package/dist/tools/sheets/index.js +2 -0
- package/dist/tools/sheets/ungroupAllRows.js +6 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,75 +1,86 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// google-tools-mcp — Combined Google Workspace MCP server
|
|
3
|
-
//
|
|
4
|
-
// All tool categories (Drive, Docs, Sheets, Gmail, Calendar) are loaded at
|
|
5
|
-
// startup so they're available in the initial tools/list response.
|
|
6
|
-
//
|
|
7
|
-
// Usage:
|
|
8
|
-
// google-tools-mcp Start the MCP server (default)
|
|
9
|
-
// google-tools-mcp auth Run the interactive OAuth flow
|
|
10
|
-
// google-tools-mcp setup Guided setup: enable APIs, create credentials, authenticate
|
|
11
|
-
import { FastMCP } from 'fastmcp';
|
|
12
|
-
import { registerAllTools } from './tools/index.js';
|
|
13
|
-
import { logger } from './logger.js';
|
|
14
|
-
|
|
15
|
-
// --- Setup subcommand ---
|
|
16
|
-
if (process.argv[2] === 'setup') {
|
|
17
|
-
const { runSetup } = await import('./setup.js');
|
|
18
|
-
try {
|
|
19
|
-
await runSetup();
|
|
20
|
-
process.exit(0);
|
|
21
|
-
} catch (error) {
|
|
22
|
-
console.error('\nSetup failed:', error.message || error);
|
|
23
|
-
process.exit(1);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// --- Auth subcommand ---
|
|
28
|
-
if (process.argv[2] === 'auth') {
|
|
29
|
-
const { runAuthFlow } = await import('./auth.js');
|
|
30
|
-
try {
|
|
31
|
-
await runAuthFlow();
|
|
32
|
-
logger.info('Authorization complete. You can now start the MCP server.');
|
|
33
|
-
process.exit(0);
|
|
34
|
-
} catch (error) {
|
|
35
|
-
logger.error('Authorization failed:', error.message || error);
|
|
36
|
-
process.exit(1);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// --- Process lifecycle logging ---
|
|
41
|
-
process.on('uncaughtException', (error) => {
|
|
42
|
-
logger.error('Uncaught Exception:', error);
|
|
43
|
-
});
|
|
44
|
-
process.on('unhandledRejection', (reason, _promise) => {
|
|
45
|
-
logger.error('Unhandled Promise Rejection:', reason);
|
|
46
|
-
});
|
|
47
|
-
process.on('SIGINT', () => {
|
|
48
|
-
logger.info('Received SIGINT — shutting down.');
|
|
49
|
-
process.exit(0);
|
|
50
|
-
});
|
|
51
|
-
process.on('SIGTERM', () => {
|
|
52
|
-
logger.info('Received SIGTERM — shutting down.');
|
|
53
|
-
process.exit(0);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
2
|
+
// google-tools-mcp — Combined Google Workspace MCP server
|
|
3
|
+
//
|
|
4
|
+
// All tool categories (Drive, Docs, Sheets, Gmail, Calendar) are loaded at
|
|
5
|
+
// startup so they're available in the initial tools/list response.
|
|
6
|
+
//
|
|
7
|
+
// Usage:
|
|
8
|
+
// google-tools-mcp Start the MCP server (default)
|
|
9
|
+
// google-tools-mcp auth Run the interactive OAuth flow
|
|
10
|
+
// google-tools-mcp setup Guided setup: enable APIs, create credentials, authenticate
|
|
11
|
+
import { FastMCP } from 'fastmcp';
|
|
12
|
+
import { registerAllTools } from './tools/index.js';
|
|
13
|
+
import { logger } from './logger.js';
|
|
14
|
+
|
|
15
|
+
// --- Setup subcommand ---
|
|
16
|
+
if (process.argv[2] === 'setup') {
|
|
17
|
+
const { runSetup } = await import('./setup.js');
|
|
18
|
+
try {
|
|
19
|
+
await runSetup();
|
|
20
|
+
process.exit(0);
|
|
21
|
+
} catch (error) {
|
|
22
|
+
console.error('\nSetup failed:', error.message || error);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// --- Auth subcommand ---
|
|
28
|
+
if (process.argv[2] === 'auth') {
|
|
29
|
+
const { runAuthFlow } = await import('./auth.js');
|
|
30
|
+
try {
|
|
31
|
+
await runAuthFlow();
|
|
32
|
+
logger.info('Authorization complete. You can now start the MCP server.');
|
|
33
|
+
process.exit(0);
|
|
34
|
+
} catch (error) {
|
|
35
|
+
logger.error('Authorization failed:', error.message || error);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// --- Process lifecycle logging ---
|
|
41
|
+
process.on('uncaughtException', (error) => {
|
|
42
|
+
logger.error('Uncaught Exception:', error);
|
|
43
|
+
});
|
|
44
|
+
process.on('unhandledRejection', (reason, _promise) => {
|
|
45
|
+
logger.error('Unhandled Promise Rejection:', reason);
|
|
46
|
+
});
|
|
47
|
+
process.on('SIGINT', () => {
|
|
48
|
+
logger.info('Received SIGINT — shutting down.');
|
|
49
|
+
process.exit(0);
|
|
50
|
+
});
|
|
51
|
+
process.on('SIGTERM', () => {
|
|
52
|
+
logger.info('Received SIGTERM — shutting down.');
|
|
53
|
+
process.exit(0);
|
|
54
|
+
});
|
|
55
|
+
// Exit when the MCP client closes the stdio pipe.
|
|
56
|
+
// This is the primary shutdown path for stdio MCP servers — SIGTERM is not
|
|
57
|
+
// reliably delivered on Windows when a parent process exits.
|
|
58
|
+
process.stdin.on('close', () => {
|
|
59
|
+
logger.info('stdin closed — MCP client disconnected. Shutting down.');
|
|
60
|
+
process.exit(0);
|
|
61
|
+
});
|
|
62
|
+
process.stdin.on('end', () => {
|
|
63
|
+
logger.info('stdin ended — MCP client disconnected. Shutting down.');
|
|
64
|
+
process.exit(0);
|
|
65
|
+
});
|
|
66
|
+
process.on('exit', (code) => {
|
|
67
|
+
logger.info(`Process exiting with code ${code}.`);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// --- Server startup ---
|
|
71
|
+
const server = new FastMCP({
|
|
72
|
+
name: 'google-tools-mcp',
|
|
73
|
+
version: '1.0.0',
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
await registerAllTools(server);
|
|
77
|
+
|
|
78
|
+
try {
|
|
79
|
+
logger.info('Starting google-tools-mcp server...');
|
|
80
|
+
await server.start({ transportType: 'stdio' });
|
|
81
|
+
logger.info('MCP Server running using stdio. Awaiting client connection...');
|
|
82
|
+
logger.info('Google auth will run automatically on first tool call.');
|
|
83
|
+
} catch (startError) {
|
|
84
|
+
logger.error('FATAL: Server failed to start:', startError.message || startError);
|
|
85
|
+
process.exit(1);
|
|
86
|
+
}
|