@starfysh/gdrive-mcp 1.1.0 → 1.1.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.
- package/dist/auth.js +93 -1
- package/dist/server.js +13 -1
- package/package.json +1 -1
package/dist/auth.js
CHANGED
|
@@ -7,7 +7,7 @@ import * as readline from 'readline/promises';
|
|
|
7
7
|
import * as os from 'os';
|
|
8
8
|
import { existsSync } from 'fs';
|
|
9
9
|
// --- Calculate paths with fallback locations ---
|
|
10
|
-
const CONFIG_DIR = path.join(os.homedir(), '.config', 'gdrive-mcp');
|
|
10
|
+
export const CONFIG_DIR = path.join(os.homedir(), '.config', 'gdrive-mcp');
|
|
11
11
|
function resolvePath(envVar, filename) {
|
|
12
12
|
// 1. Environment variable (explicit override)
|
|
13
13
|
if (process.env[envVar]) {
|
|
@@ -187,3 +187,95 @@ export async function authorize() {
|
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
// --- END OF MODIFIED: The Main Exported Function ---
|
|
190
|
+
// --- Uninstall Function ---
|
|
191
|
+
export async function uninstall() {
|
|
192
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
193
|
+
try {
|
|
194
|
+
// Detect service account mode
|
|
195
|
+
if (process.env.SERVICE_ACCOUNT_PATH) {
|
|
196
|
+
console.log('ℹ Service account auth detected - no token files to remove.');
|
|
197
|
+
console.log(` Service account key at: ${process.env.SERVICE_ACCOUNT_PATH}`);
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
// Warn about custom paths via env vars
|
|
201
|
+
if (process.env.GDRIVE_MCP_TOKEN_PATH) {
|
|
202
|
+
console.log(`⚠ Custom token path set: ${process.env.GDRIVE_MCP_TOKEN_PATH}`);
|
|
203
|
+
console.log(' Remove manually if desired.\n');
|
|
204
|
+
}
|
|
205
|
+
if (process.env.GDRIVE_MCP_CREDENTIALS_PATH) {
|
|
206
|
+
console.log(`⚠ Custom credentials path set: ${process.env.GDRIVE_MCP_CREDENTIALS_PATH}`);
|
|
207
|
+
console.log(' Remove manually if desired.\n');
|
|
208
|
+
}
|
|
209
|
+
// Check ALL locations (not using resolvePath - it returns fallback even if missing)
|
|
210
|
+
const locations = [
|
|
211
|
+
{ dir: CONFIG_DIR, label: '~/.config/gdrive-mcp' },
|
|
212
|
+
{ dir: process.cwd(), label: 'current directory' }
|
|
213
|
+
];
|
|
214
|
+
let tokensRemoved = 0;
|
|
215
|
+
let credentialsToRemove = [];
|
|
216
|
+
// Remove token.json from all locations (no prompt - always safe)
|
|
217
|
+
for (const loc of locations) {
|
|
218
|
+
const tokenPath = path.join(loc.dir, 'token.json');
|
|
219
|
+
if (existsSync(tokenPath)) {
|
|
220
|
+
try {
|
|
221
|
+
await fs.unlink(tokenPath);
|
|
222
|
+
console.log(`✓ Removed token.json from ${loc.label}`);
|
|
223
|
+
tokensRemoved++;
|
|
224
|
+
}
|
|
225
|
+
catch (error) {
|
|
226
|
+
console.log(`⚠ Failed to remove token.json from ${loc.label}: ${error.message}`);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
const credPath = path.join(loc.dir, 'credentials.json');
|
|
230
|
+
if (existsSync(credPath)) {
|
|
231
|
+
credentialsToRemove.push(credPath);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (tokensRemoved === 0) {
|
|
235
|
+
console.log('ℹ No token.json found (already clean)');
|
|
236
|
+
}
|
|
237
|
+
// Prompt for credentials.json removal (only if interactive)
|
|
238
|
+
if (credentialsToRemove.length > 0) {
|
|
239
|
+
if (process.stdin.isTTY) {
|
|
240
|
+
const answer = await rl.question('\n? Remove credentials.json? You\'ll need to re-download from Google Console. [y/N] ');
|
|
241
|
+
if (answer.toLowerCase() === 'y') {
|
|
242
|
+
for (const credPath of credentialsToRemove) {
|
|
243
|
+
try {
|
|
244
|
+
await fs.unlink(credPath);
|
|
245
|
+
console.log(`✓ Removed ${credPath}`);
|
|
246
|
+
}
|
|
247
|
+
catch (error) {
|
|
248
|
+
console.log(`⚠ Failed to remove ${credPath}: ${error.message}`);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
console.log(' Keeping credentials.json');
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
console.log(`\nℹ Found credentials.json in ${credentialsToRemove.length} location(s) - kept (run interactively to remove)`);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
// Print mcp_config.json cleanup instructions with platform detection
|
|
261
|
+
const configPath = process.platform === 'darwin'
|
|
262
|
+
? '~/Library/Application Support/Claude/claude_desktop_config.json'
|
|
263
|
+
: process.platform === 'win32'
|
|
264
|
+
? '%APPDATA%\\Claude\\claude_desktop_config.json'
|
|
265
|
+
: '~/.config/Claude/claude_desktop_config.json';
|
|
266
|
+
console.log(`
|
|
267
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
268
|
+
│ Uninstall Complete │
|
|
269
|
+
├─────────────────────────────────────────────────────────────────┤
|
|
270
|
+
│ To remove from Claude Desktop: │
|
|
271
|
+
│ │
|
|
272
|
+
│ 1. Open: ${configPath.padEnd(48)} │
|
|
273
|
+
│ 2. Remove the "gdrive-mcp" entry from "mcpServers" │
|
|
274
|
+
│ 3. Restart Claude Desktop │
|
|
275
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
276
|
+
`);
|
|
277
|
+
}
|
|
278
|
+
finally {
|
|
279
|
+
rl.close();
|
|
280
|
+
}
|
|
281
|
+
}
|
package/dist/server.js
CHANGED
|
@@ -3185,4 +3185,16 @@ async function startServer() {
|
|
|
3185
3185
|
process.exit(1);
|
|
3186
3186
|
}
|
|
3187
3187
|
}
|
|
3188
|
-
|
|
3188
|
+
// Handle --uninstall flag
|
|
3189
|
+
if (process.argv.includes('--uninstall')) {
|
|
3190
|
+
import('./auth.js').then(async ({ uninstall }) => {
|
|
3191
|
+
await uninstall();
|
|
3192
|
+
process.exit(0);
|
|
3193
|
+
}).catch((err) => {
|
|
3194
|
+
console.error('Uninstall failed:', err.message);
|
|
3195
|
+
process.exit(1);
|
|
3196
|
+
});
|
|
3197
|
+
}
|
|
3198
|
+
else {
|
|
3199
|
+
startServer(); // Removed .catch here, let errors propagate if startup fails critically
|
|
3200
|
+
}
|