diff --git a/backend/app/utils/toolkit/google_gmail_native_toolkit.py b/backend/app/utils/toolkit/google_gmail_native_toolkit.py index 7f6a70c7..680b6ae1 100644 --- a/backend/app/utils/toolkit/google_gmail_native_toolkit.py +++ b/backend/app/utils/toolkit/google_gmail_native_toolkit.py @@ -315,9 +315,9 @@ class GoogleGmailNativeToolkit(BaseGmailToolkit, AbstractToolkit): # If no token file, try environment variables if not creds: - client_id = env("GOOGLE_CLIENT_ID") - client_secret = env("GOOGLE_CLIENT_SECRET") - refresh_token = env("GOOGLE_REFRESH_TOKEN") + client_id = env("GMAIL_GOOGLE_CLIENT_ID") + client_secret = env("GMAIL_GOOGLE_CLIENT_SECRET") + refresh_token = env("GMAIL_GOOGLE_REFRESH_TOKEN") token_uri = env("GOOGLE_TOKEN_URI", "https://oauth2.googleapis.com/token") if refresh_token and client_id and client_secret: @@ -390,14 +390,14 @@ class GoogleGmailNativeToolkit(BaseGmailToolkit, AbstractToolkit): state.status = "authorizing" oauth_state_manager.update_status("google_gmail", "authorizing") - client_id = env("GOOGLE_CLIENT_ID") - client_secret = env("GOOGLE_CLIENT_SECRET") + client_id = env("GMAIL_GOOGLE_CLIENT_ID") + client_secret = env("GMAIL_GOOGLE_CLIENT_SECRET") token_uri = env("GOOGLE_TOKEN_URI", "https://oauth2.googleapis.com/token") logger.info(f"Google Gmail auth - client_id present: {bool(client_id)}, client_secret present: {bool(client_secret)}") if not client_id or not client_secret: - error_msg = "GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET must be set in environment variables" + error_msg = "GMAIL_GOOGLE_CLIENT_ID and GMAIL_GOOGLE_CLIENT_SECRET must be set in environment variables" logger.error(error_msg) raise ValueError(error_msg) @@ -488,9 +488,9 @@ class GoogleGmailNativeToolkit(BaseGmailToolkit, AbstractToolkit): def get_can_use_tools(cls, api_task_id: str) -> list[FunctionTool]: """Check if Gmail toolkit can be used and return available tools. - Requires GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET environment variables. + Requires GMAIL_GOOGLE_CLIENT_ID and GMAIL_GOOGLE_CLIENT_SECRET environment variables. """ - if env("GOOGLE_CLIENT_ID") and env("GOOGLE_CLIENT_SECRET"): + if env("GMAIL_GOOGLE_CLIENT_ID") and env("GMAIL_GOOGLE_CLIENT_SECRET"): return cls(api_task_id).get_tools() else: return [] diff --git a/server/app/model/config/config.py b/server/app/model/config/config.py index 593ec642..8d0ff0d9 100644 --- a/server/app/model/config/config.py +++ b/server/app/model/config/config.py @@ -124,8 +124,8 @@ class ConfigInfo: "env_vars": [], "toolkit": "google_drive_mcp_toolkit", }, - ConfigGroup.GOOGLE_GMAIL_MCP.value: { - "env_vars": ["GOOGLE_CLIENT_ID", "GOOGLE_CLIENT_SECRET", "GOOGLE_REFRESH_TOKEN"], + ConfigGroup.GOOGLE_GMAIL.value: { + "env_vars": ["GMAIL_GOOGLE_CLIENT_ID", "GMAIL_GOOGLE_CLIENT_SECRET", "GMAIL_GOOGLE_REFRESH_TOKEN"], "toolkit": "google_gmail_native_toolkit", }, ConfigGroup.IMAGE_ANALYSIS.value: { diff --git a/server/app/type/config_group.py b/server/app/type/config_group.py index ba7b6605..a401e6d7 100644 --- a/server/app/type/config_group.py +++ b/server/app/type/config_group.py @@ -21,7 +21,7 @@ class ConfigGroup(str, Enum): GITHUB = "Github" GOOGLE_CALENDAR = "Google Calendar" GOOGLE_DRIVE_MCP = "Google Drive MCP" - GOOGLE_GMAIL_MCP = "Google Gmail MCP" + GOOGLE_GMAIL = "Google Gmail" IMAGE_ANALYSIS = "Image Analysis" MCP_SEARCH = "MCP Search" PPTX = "PPTX" diff --git a/src/components/AddWorker/ToolSelect.tsx b/src/components/AddWorker/ToolSelect.tsx index fa49d771..8383c234 100644 --- a/src/components/AddWorker/ToolSelect.tsx +++ b/src/components/AddWorker/ToolSelect.tsx @@ -163,7 +163,7 @@ const ToolSelect = forwardRef< } }; - } else if (key.toLowerCase() === 'google gmail mcp') { + } else if (key.toLowerCase() === 'google gmail') { onInstall = async () => { try { const response = await fetchPost("/install/tool/google_gmail"); @@ -172,14 +172,14 @@ const ToolSelect = forwardRef< const existingConfigs = await proxyFetchGet("/api/configs"); const existing = Array.isArray(existingConfigs) ? existingConfigs.find((c: any) => - c.config_group?.toLowerCase() === "google gmail mcp" && - c.config_name === "GOOGLE_REFRESH_TOKEN" + c.config_group?.toLowerCase() === "google gmail" && + c.config_name === "GMAIL_GOOGLE_REFRESH_TOKEN" ) : null; const configPayload = { - config_group: "Google Gmail MCP", //According to backend config - config_name: "GOOGLE_REFRESH_TOKEN", + config_group: "Google Gmail", //According to backend config + config_name: "GMAIL_GOOGLE_REFRESH_TOKEN", config_value: "exists", }; @@ -239,7 +239,7 @@ const ToolSelect = forwardRef< ? t("layout.notion-workspace-integration") : key.toLowerCase() === 'google calendar' ? t("layout.google-calendar-integration") - : key.toLowerCase() === 'google gmail mcp' + : key.toLowerCase() === 'google gmail' ? "Google Gmail integration for managing emails and contacts" : "", onInstall, @@ -517,7 +517,7 @@ const ToolSelect = forwardRef< } // Trigger instantiation for Gmail - if (activeMcp.key === "Google Gmail MCP") { + if (activeMcp.key === "Google Gmail") { console.log("[ToolSelect installMcp] Starting Gmail installation"); try { const response = await fetchPost("/install/tool/google_gmail"); @@ -528,14 +528,14 @@ const ToolSelect = forwardRef< const existingConfigs = await proxyFetchGet("/api/configs"); const existing = Array.isArray(existingConfigs) ? existingConfigs.find((c: any) => - c.config_group?.toLowerCase() === "google gmail mcp" && - c.config_name === "GOOGLE_REFRESH_TOKEN" + c.config_group?.toLowerCase() === "google gmail" && + c.config_name === "GMAIL_GOOGLE_REFRESH_TOKEN" ) : null; const configPayload = { - config_group: "Google Gmail MCP", - config_name: "GOOGLE_REFRESH_TOKEN", + config_group: "Google Gmail", + config_name: "GMAIL_GOOGLE_REFRESH_TOKEN", config_value: "exists", }; @@ -580,14 +580,14 @@ const ToolSelect = forwardRef< const existingConfigs = await proxyFetchGet("/api/configs"); const existing = Array.isArray(existingConfigs) ? existingConfigs.find((c: any) => - c.config_group?.toLowerCase() === "google gmail mcp" && - c.config_name === "GOOGLE_REFRESH_TOKEN" + c.config_group?.toLowerCase() === "google gmail" && + c.config_name === "GMAIL_GOOGLE_REFRESH_TOKEN" ) : null; const configPayload = { - config_group: "Google Gmail MCP", - config_name: "GOOGLE_REFRESH_TOKEN", + config_group: "Google Gmail", + config_name: "GMAIL_GOOGLE_REFRESH_TOKEN", config_value: "exists", }; diff --git a/src/components/AddWorker/index.tsx b/src/components/AddWorker/index.tsx index 855c1831..090aa912 100644 --- a/src/components/AddWorker/index.tsx +++ b/src/components/AddWorker/index.tsx @@ -96,7 +96,7 @@ export function AddWorker({ ?.replace(/}}/g, "") || "", }; // GOOGLE_REFRESH_TOKEN is obtained via OAuth and does not require manual input - if (key === "GOOGLE_REFRESH_TOKEN") { + if (key === "GOOGLE_REFRESH_TOKEN" || key === "GMAIL_GOOGLE_REFRESH_TOKEN") { initialValues[key].required = false; } initialVisibility[key] = false; @@ -164,7 +164,7 @@ export function AddWorker({ // call ToolSelect's install method if (toolSelectRef.current) { try { - if (activeMcp.key === "EXA Search" || activeMcp.key === "Google Calendar" || activeMcp.key === "Google Gmail MCP") { + if (activeMcp.key === "EXA Search" || activeMcp.key === "Google Calendar" || activeMcp.key === "Google Gmail") { await toolSelectRef.current.installMcp( activeMcp.id, { ...envValues }, @@ -179,7 +179,7 @@ export function AddWorker({ } // For Google Calendar, close dialog after installMcp completes - if (activeMcp.key === "Google Calendar" || activeMcp.key === "Google Gmail MCP") { + if (activeMcp.key === "Google Calendar" || activeMcp.key === "Google Gmail") { setShowEnvConfig(false); } diff --git a/src/components/IntegrationList/index.tsx b/src/components/IntegrationList/index.tsx index b187eba1..b3558832 100644 --- a/src/components/IntegrationList/index.tsx +++ b/src/components/IntegrationList/index.tsx @@ -110,7 +110,7 @@ export default function IntegrationList({ return; } - if (item.key === "Google Gmail MCP") { + if (item.key === "Google Gmail") { const mcp = createMcpFromItem(item, 15); if (isSelectMode) { onShowEnvConfig?.(mcp); @@ -210,13 +210,13 @@ export default function IntegrationList({ console.log("[IntegrationList onConnect] Polling timeout"); return; } - } else if (mcp.key === "Google Gmail MCP") { + } else if (mcp.key === "Google Gmail") { console.log( "[IntegrationList onConnect] Google Gmail detected, starting auth flow" ); // Trigger install/authorization - const gmailItem = items.find((item) => item.key === "Google Gmail MCP"); + const gmailItem = items.find((item) => item.key === "Google Gmail"); try { if (gmailItem && gmailItem.onInstall) { await gmailItem.onInstall(); diff --git a/src/hooks/useIntegrationManagement.ts b/src/hooks/useIntegrationManagement.ts index 6b03e881..7dcdd4a7 100644 --- a/src/hooks/useIntegrationManagement.ts +++ b/src/hooks/useIntegrationManagement.ts @@ -63,12 +63,12 @@ export function useIntegrationManagement(items: IntegrationItem[]) { const map: { [key: string]: boolean } = {}; items.forEach((item) => { - if (item.key === "Google Calendar" || item.key === "Google Gmail MCP") { + if (item.key === "Google Calendar" || item.key === "Google Gmail") { // Only mark installed when refresh token is present (auth completed) const hasRefreshToken = configs.some( (c: any) => c.config_group?.toLowerCase() === item.key.toLowerCase() && - c.config_name === "GOOGLE_REFRESH_TOKEN" && + ["GOOGLE_REFRESH_TOKEN", "GMAIL_GOOGLE_REFRESH_TOKEN"].includes(c.config_name) && c.config_value && String(c.config_value).length > 0 ); map[item.key] = hasRefreshToken; @@ -248,7 +248,7 @@ export function useIntegrationManagement(items: IntegrationItem[]) { } catch (e) { console.log("Failed to clean up Google Calendar tokens:", e); } - } else if (item.key === "Google Gmail MCP") { + } else if (item.key === "Google Gmail") { try { await fetchDelete("/uninstall/tool/google_gmail"); console.log("Cleaned up Google Gmail authentication tokens"); diff --git a/src/pages/Setting/MCP.tsx b/src/pages/Setting/MCP.tsx index 725b3efa..f2bc2fac 100644 --- a/src/pages/Setting/MCP.tsx +++ b/src/pages/Setting/MCP.tsx @@ -311,7 +311,7 @@ export default function SettingMCP() { ); } } - } else if (key.toLowerCase() === 'google gmail mcp') { + } else if (key.toLowerCase() === 'google gmail') { onInstall = async () => { try { const response = await fetchPost("/install/tool/google_gmail"); @@ -320,14 +320,14 @@ export default function SettingMCP() { const existingConfigs = await proxyFetchGet("/api/configs"); const existing = Array.isArray(existingConfigs) ? existingConfigs.find((c: any) => - c.config_group?.toLowerCase() === "google gmail mcp" && - c.config_name === "GOOGLE_REFRESH_TOKEN" + c.config_group?.toLowerCase() === "google gmail" && + c.config_name === "GMAIL_GOOGLE_REFRESH_TOKEN" ) : null; const configPayload = { - config_group: "Google Gmail MCP", - config_name: "GOOGLE_REFRESH_TOKEN", + config_group: "Google Gmail", + config_name: "GMAIL_GOOGLE_REFRESH_TOKEN", config_value: "exists", }; @@ -358,14 +358,14 @@ export default function SettingMCP() { const configs = await proxyFetchGet("/api/configs"); const existing = Array.isArray(configs) ? configs.find((c: any) => - c.config_group?.toLowerCase() === "google gmail mcp" && - c.config_name === "GOOGLE_REFRESH_TOKEN" + c.config_group?.toLowerCase() === "google gmail" && + c.config_name === "GMAIL_GOOGLE_REFRESH_TOKEN" ) : null; const payload = { - config_group: "Google Gmail MCP", - config_name: "GOOGLE_REFRESH_TOKEN", + config_group: "Google Gmail", + config_name: "GMAIL_GOOGLE_REFRESH_TOKEN", config_value: "exists", }; @@ -420,7 +420,7 @@ export default function SettingMCP() { ? t("setting.notion-workspace-integration") : key.toLowerCase() === "google calendar" ? t("setting.google-calendar-integration") - : key.toLowerCase() === 'google gmail mcp' + : key.toLowerCase() === 'google gmail' ? "Google Gmail integration for managing emails, drafts, and contacts" : "", onInstall, diff --git a/src/pages/Setting/components/MCPEnvDialog.tsx b/src/pages/Setting/components/MCPEnvDialog.tsx index a6e7e09b..0bb8552e 100644 --- a/src/pages/Setting/components/MCPEnvDialog.tsx +++ b/src/pages/Setting/components/MCPEnvDialog.tsx @@ -106,7 +106,7 @@ export const MCPEnvDialog: FC = ({ if (key === 'EXA_API_KEY') { initialValues[key].required = false; } - if (key === 'GOOGLE_REFRESH_TOKEN') { + if (key === 'GOOGLE_REFRESH_TOKEN' || key === 'GMAIL_GOOGLE_REFRESH_TOKEN') { initialValues[key].required = false; } });