@starfysh/gdrive-mcp 1.0.0 → 1.0.1

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.
Files changed (2) hide show
  1. package/dist/auth.js +24 -7
  2. package/package.json +1 -1
package/dist/auth.js CHANGED
@@ -4,13 +4,30 @@ import { JWT } from 'google-auth-library'; // ADDED: Import for Service Account
4
4
  import * as fs from 'fs/promises';
5
5
  import * as path from 'path';
6
6
  import * as readline from 'readline/promises';
7
- import { fileURLToPath } from 'url';
8
- // --- Calculate paths relative to this script file (ESM way) ---
9
- const __filename = fileURLToPath(import.meta.url);
10
- const __dirname = path.dirname(__filename);
11
- const projectRootDir = path.resolve(__dirname, '..');
12
- const TOKEN_PATH = path.join(projectRootDir, 'token.json');
13
- const CREDENTIALS_PATH = path.join(projectRootDir, 'credentials.json');
7
+ import * as os from 'os';
8
+ import { existsSync } from 'fs';
9
+ // --- Calculate paths with fallback locations ---
10
+ const CONFIG_DIR = path.join(os.homedir(), '.config', 'gdrive-mcp');
11
+ function resolvePath(envVar, filename) {
12
+ // 1. Environment variable (explicit override)
13
+ if (process.env[envVar]) {
14
+ return process.env[envVar];
15
+ }
16
+ // 2. Current working directory
17
+ const cwdPath = path.join(process.cwd(), filename);
18
+ if (existsSync(cwdPath)) {
19
+ return cwdPath;
20
+ }
21
+ // 3. User config directory (~/.config/gdrive-mcp/)
22
+ const configPath = path.join(CONFIG_DIR, filename);
23
+ if (existsSync(configPath)) {
24
+ return configPath;
25
+ }
26
+ // Default to cwd (will error at read time with helpful message)
27
+ return cwdPath;
28
+ }
29
+ const TOKEN_PATH = resolvePath('GDRIVE_MCP_TOKEN_PATH', 'token.json');
30
+ const CREDENTIALS_PATH = resolvePath('GDRIVE_MCP_CREDENTIALS_PATH', 'credentials.json');
14
31
  // --- End of path calculation ---
15
32
  const SCOPES = [
16
33
  'https://www.googleapis.com/auth/documents',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starfysh/gdrive-mcp",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "type": "module",
5
5
  "description": "MCP server for Google Docs, Sheets, and Drive integration with Claude",
6
6
  "main": "dist/server.js",