google-tools-mcp 1.1.3 → 1.1.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.
- package/dist/auth.js +18 -0
- package/package.json +1 -1
package/dist/auth.js
CHANGED
|
@@ -166,6 +166,23 @@ async function loadSavedCredentialsIfExist() {
|
|
|
166
166
|
const tokenPath = getTokenPath();
|
|
167
167
|
const content = await fs.readFile(tokenPath, 'utf8');
|
|
168
168
|
const credentials = JSON.parse(content);
|
|
169
|
+
|
|
170
|
+
// Check that the saved token covers all current SCOPES.
|
|
171
|
+
// Tokens without a scopes field (pre-upgrade) or with missing scopes
|
|
172
|
+
// are stale — delete and force re-auth via browser automatically.
|
|
173
|
+
if (!Array.isArray(credentials.scopes)) {
|
|
174
|
+
logger.info('Saved token has no scopes record (pre-upgrade token). Re-authentication required for new scopes.');
|
|
175
|
+
try { await fs.unlink(tokenPath); } catch {}
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
const saved = new Set(credentials.scopes);
|
|
179
|
+
const missing = SCOPES.filter(s => !saved.has(s));
|
|
180
|
+
if (missing.length > 0) {
|
|
181
|
+
logger.info(`Saved token is missing scope(s): ${missing.join(', ')}. Re-authentication required.`);
|
|
182
|
+
try { await fs.unlink(tokenPath); } catch {}
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
|
|
169
186
|
const { client_secret, client_id } = await loadClientSecrets();
|
|
170
187
|
const client = new google.auth.OAuth2(client_id, client_secret);
|
|
171
188
|
client.setCredentials(credentials);
|
|
@@ -185,6 +202,7 @@ async function saveCredentials(client) {
|
|
|
185
202
|
client_id,
|
|
186
203
|
client_secret,
|
|
187
204
|
refresh_token: client.credentials.refresh_token,
|
|
205
|
+
scopes: SCOPES,
|
|
188
206
|
}, null, 2);
|
|
189
207
|
await fs.writeFile(tokenPath, payload);
|
|
190
208
|
logger.info('Token stored to', tokenPath);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "google-tools-mcp",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "The easiest MCP server for Google Workspace — Drive, Docs, Sheets, Gmail, Calendar, and Forms. 153 tools with one-click browser auth. Read Word docs, PDFs, and spreadsheets straight from Drive.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|