From 21c6480b65528a98ac0e1e3855f3c78c1f9b7cbe Mon Sep 17 00:00:00 2001 From: Yuki Okita Date: Wed, 20 Aug 2025 10:55:47 +0900 Subject: Refac: Centralize storage file management (#4078) Co-authored-by: Taylor Mullen --- packages/core/src/mcp/oauth-token-storage.test.ts | 1 + packages/core/src/mcp/oauth-token-storage.ts | 8 ++------ 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'packages/core/src/mcp') diff --git a/packages/core/src/mcp/oauth-token-storage.test.ts b/packages/core/src/mcp/oauth-token-storage.test.ts index 5fe2f3f5..f1dc644e 100644 --- a/packages/core/src/mcp/oauth-token-storage.test.ts +++ b/packages/core/src/mcp/oauth-token-storage.test.ts @@ -21,6 +21,7 @@ vi.mock('node:fs', () => ({ mkdir: vi.fn(), unlink: vi.fn(), }, + mkdirSync: vi.fn(), })); vi.mock('node:os', () => ({ diff --git a/packages/core/src/mcp/oauth-token-storage.ts b/packages/core/src/mcp/oauth-token-storage.ts index 0500b43e..00814ba9 100644 --- a/packages/core/src/mcp/oauth-token-storage.ts +++ b/packages/core/src/mcp/oauth-token-storage.ts @@ -6,7 +6,7 @@ import { promises as fs } from 'node:fs'; import * as path from 'node:path'; -import * as os from 'node:os'; +import { Storage } from '../config/storage.js'; import { getErrorMessage } from '../utils/errors.js'; /** @@ -36,17 +36,13 @@ export interface MCPOAuthCredentials { * Class for managing MCP OAuth token storage and retrieval. */ export class MCPOAuthTokenStorage { - private static readonly TOKEN_FILE = 'mcp-oauth-tokens.json'; - private static readonly CONFIG_DIR = '.gemini'; - /** * Get the path to the token storage file. * * @returns The full path to the token storage file */ private static getTokenFilePath(): string { - const homeDir = os.homedir(); - return path.join(homeDir, this.CONFIG_DIR, this.TOKEN_FILE); + return Storage.getMcpOAuthTokensPath(); } /** -- cgit v1.2.3