mcp-google-extras 1.0.2 → 1.0.4

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 (3) hide show
  1. package/README.md +99 -13
  2. package/dist/auth.js +7 -4
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -11,19 +11,51 @@ All 44 tools from `@a-bonus/google-docs-mcp`, plus:
11
11
  - **readFile** — Read the full text content of a `.docx` or `.pdf` file from Google Drive by file ID
12
12
  - **searchFileContents** — Search Google Drive and extract matching text snippets from inside `.docx` and `.pdf` files
13
13
 
14
- ## Setup
14
+ ## Getting Started
15
15
 
16
- ### 1. Create Google OAuth credentials
16
+ ### Step 1: Create Google OAuth Credentials
17
17
 
18
18
  1. Go to the [Google Cloud Console](https://console.cloud.google.com/)
19
19
  2. Create a project (or use an existing one)
20
- 3. Enable the Google Docs API, Google Sheets API, and Google Drive API
21
- 4. Create OAuth 2.0 credentials (Desktop application type)
22
- 5. Note your Client ID and Client Secret
20
+ 3. Enable the **Google Docs API**, **Google Sheets API**, and **Google Drive API**
21
+ 4. Go to **Credentials** → **Create Credentials** **OAuth Client ID**
22
+ 5. Select **Desktop application** as the application type
23
+ 6. Download the credentials or note your **Client ID** and **Client Secret**
23
24
 
24
- ### 2. Configure your MCP client
25
+ ### Step 2: Provide Your Credentials
25
26
 
26
- Add this to your MCP configuration (e.g., `.mcp.json`):
27
+ Choose **one** of the following methods (whichever you prefer):
28
+
29
+ #### Option A: Use `credentials.json`
30
+
31
+ Download the JSON file from Google Cloud Console and place it in either location:
32
+
33
+ ```
34
+ ~/.config/google-docs-mcp/credentials.json (recommended — shared across projects)
35
+ ./credentials.json (local to your project)
36
+ ```
37
+
38
+ That's it — no env vars needed. The server will find it automatically.
39
+
40
+ #### Option B: Create a `.env` file
41
+
42
+ Create a `.env` file in either location:
43
+
44
+ ```
45
+ ~/.config/google-docs-mcp/.env (recommended — shared across projects)
46
+ ./.env (local to your project)
47
+ ```
48
+
49
+ With the following contents:
50
+
51
+ ```env
52
+ GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com
53
+ GOOGLE_CLIENT_SECRET=your-client-secret
54
+ ```
55
+
56
+ #### Option C: Set env vars in your MCP config
57
+
58
+ Add the credentials directly to your MCP configuration:
27
59
 
28
60
  ```json
29
61
  {
@@ -40,16 +72,68 @@ Add this to your MCP configuration (e.g., `.mcp.json`):
40
72
  }
41
73
  ```
42
74
 
43
- ### 3. Authenticate
75
+ > **Credential lookup order:** env vars → `~/.config/google-docs-mcp/.env` → project root `.env` → `~/.config/google-docs-mcp/credentials.json` → project root `credentials.json`
76
+
77
+ ### Step 3: Add to Your MCP Client
78
+
79
+ #### Claude Code (recommended)
80
+
81
+ If you used Option A or B above:
82
+
83
+ ```bash
84
+ claude mcp add google-docs -- npx -y mcp-google-extras
85
+ ```
86
+
87
+ Or with env vars (Option C):
88
+
89
+ ```bash
90
+ claude mcp add google-docs \
91
+ -e GOOGLE_CLIENT_ID=your-client-id \
92
+ -e GOOGLE_CLIENT_SECRET=your-client-secret \
93
+ -- npx -y mcp-google-extras
94
+ ```
95
+
96
+ #### Other MCP clients
97
+
98
+ Add this to your MCP configuration (e.g., `.mcp.json`, `claude_desktop_config.json`):
99
+
100
+ ```json
101
+ {
102
+ "mcpServers": {
103
+ "google-docs": {
104
+ "command": "npx",
105
+ "args": ["-y", "mcp-google-extras"]
106
+ }
107
+ }
108
+ }
109
+ ```
110
+
111
+ If using Option C, add an `"env"` block with your `GOOGLE_CLIENT_ID` and `GOOGLE_CLIENT_SECRET`.
112
+
113
+ ### Step 4: Authenticate
44
114
 
45
- On first run, the server will open your browser for Google OAuth consent. The token is saved to `~/.config/google-docs-mcp/token.json` for future use.
115
+ On your first tool call, the server will automatically open your browser for Google OAuth consent. Sign in and grant access — the token is saved to `~/.config/google-docs-mcp/token.json` for future use.
46
116
 
47
- You can also run the auth flow manually:
117
+ You can also run the auth flow manually anytime:
48
118
 
49
119
  ```bash
50
120
  npx mcp-google-extras auth
51
121
  ```
52
122
 
123
+ ### Multi-Account Support
124
+
125
+ Set the `GOOGLE_MCP_PROFILE` env var to use separate tokens per profile:
126
+
127
+ ```json
128
+ {
129
+ "env": {
130
+ "GOOGLE_MCP_PROFILE": "work"
131
+ }
132
+ }
133
+ ```
134
+
135
+ This stores tokens in `~/.config/google-docs-mcp/work/` instead of the default directory.
136
+
53
137
  ## Tools
54
138
 
55
139
  ### Google Docs
@@ -68,13 +152,15 @@ npx mcp-google-extras auth
68
152
 
69
153
  | Variable | Required | Description |
70
154
  |---|---|---|
71
- | `GOOGLE_CLIENT_ID` | Yes | OAuth 2.0 Client ID |
72
- | `GOOGLE_CLIENT_SECRET` | Yes | OAuth 2.0 Client Secret |
73
- | `GOOGLE_MCP_PROFILE` | No | Profile name for multi-account support |
155
+ | `GOOGLE_CLIENT_ID` | No* | OAuth 2.0 Client ID |
156
+ | `GOOGLE_CLIENT_SECRET` | No* | OAuth 2.0 Client Secret |
157
+ | `GOOGLE_MCP_PROFILE` | No | Profile name for multi-account support (see above) |
74
158
  | `LOG_LEVEL` | No | `debug`, `info`, `warn`, `error`, or `silent` |
75
159
  | `SERVICE_ACCOUNT_PATH` | No | Path to service account JSON key (alternative to OAuth) |
76
160
  | `GOOGLE_IMPERSONATE_USER` | No | Email to impersonate with service account |
77
161
 
162
+ \* Not required as env vars if you provide credentials via `.env` file or `credentials.json` (see [Step 2](#step-2-provide-your-credentials)).
163
+
78
164
  ## License
79
165
 
80
166
  ISC (based on [@a-bonus/google-docs-mcp](https://www.npmjs.com/package/@a-bonus/google-docs-mcp))
package/dist/auth.js CHANGED
@@ -87,17 +87,20 @@ async function loadClientSecrets() {
87
87
  if (process.env.GOOGLE_CLIENT_ID && process.env.GOOGLE_CLIENT_SECRET) {
88
88
  return { client_id: process.env.GOOGLE_CLIENT_ID, client_secret: process.env.GOOGLE_CLIENT_SECRET };
89
89
  }
90
- // 2–3. Try loading .env files (config dir first, then project root)
90
+ // 2–4. Try loading .env files (config dir, cwd, then package root)
91
91
  const configDir = getConfigDir();
92
+ const cwd = process.cwd();
92
93
  await loadEnvFile(path.join(configDir, '.env'));
94
+ await loadEnvFile(path.join(cwd, '.env'));
93
95
  await loadEnvFile(path.join(projectRootDir, '.env'));
94
96
  if (process.env.GOOGLE_CLIENT_ID && process.env.GOOGLE_CLIENT_SECRET) {
95
97
  logger.info('Loaded client credentials from .env file.');
96
98
  return { client_id: process.env.GOOGLE_CLIENT_ID, client_secret: process.env.GOOGLE_CLIENT_SECRET };
97
99
  }
98
- // 45. Try credentials.json (config dir first, then project root)
100
+ // 57. Try credentials.json (config dir, cwd, then package root)
99
101
  const credentialsPaths = [
100
102
  path.join(configDir, 'credentials.json'),
103
+ path.join(cwd, 'credentials.json'),
101
104
  CREDENTIALS_PATH,
102
105
  ];
103
106
  for (const credPath of credentialsPaths) {
@@ -117,8 +120,8 @@ async function loadClientSecrets() {
117
120
  throw new Error(
118
121
  'No OAuth credentials found. Provide them in any of these ways:\n' +
119
122
  ` 1. Set GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET env vars in your MCP config\n` +
120
- ` 2. Create ${configDirDisplay}/.env with GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET\n` +
121
- ` 3. Place your credentials.json (from Google Cloud Console) in ${configDirDisplay}/`
123
+ ` 2. Create a .env file with GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET in ${configDirDisplay}/ or your project directory\n` +
124
+ ` 3. Place your credentials.json (from Google Cloud Console) in ${configDirDisplay}/ or your project directory`
122
125
  );
123
126
  }
124
127
  // ---------------------------------------------------------------------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-google-extras",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "type": "module",
5
5
  "description": "MCP server for Google Docs, Sheets, Drive, plus .docx and .pdf file reading",
6
6
  "bin": {