authenticate_gmail
Authenticate Gmail access by automatically opening a web browser to establish connection for managing your inbox through natural language commands.
Instructions
Authenticate Gmail access via web browser (opens browser automatically)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/lib.ts:52-109 (handler)Core handler for the 'authenticate_gmail' tool: checks for OAuth client, performs web browser authentication, initializes Gmail service, and returns success message.if (req.params.name === 'authenticate_gmail') { // Always get fresh OAuth client let oauth2Client = await getOAuthClient(); if (!oauth2Client) { throw new Error(`Gmail OAuth Setup Required Please complete the following steps: 1. Create Google Cloud Project Visit: https://console.cloud.google.com/projectcreate 2. Enable Gmail API Visit: https://console.cloud.google.com/apis/api/gmail.googleapis.com/metrics 3. Create OAuth Credentials Visit: https://console.cloud.google.com/auth/clients Choose "Desktop app" type Download as gcp-oauth.keys.json 4. Add Required Scope Visit: https://console.cloud.google.com/auth/scopes Add: https://mail.google.com/ 5. Add Test User Visit: https://console.cloud.google.com/auth/audience Add your Google email as test user 6. Save the file to project directory and restart Claude Desktop Expected OAuth file location: ${process.env.GMAIL_OAUTH_PATH || 'project directory/gcp-oauth.keys.json'}`); } try { await authenticateWeb(oauth2Client); // Reinitialize Gmail service after successful authentication let gmailService = new GmailService(oauth2Client); return { content: [{ type: "text", text: `Authentication Successful! Gmail Manager is now connected to your Gmail account! You can now use all Gmail tools: - Search and filter emails - Delete emails in bulk - Create and manage labels - Organize your inbox Ready to start managing your inbox!` }] }; } catch (error) { throw new Error(`Authentication failed: ${error instanceof Error ? error.message : String(error)}`); } }
- src/tools.ts:32-32 (schema)Input schema definition for 'authenticate_gmail' tool using Zod (no input parameters required).authenticate_gmail: z.object({})
- src/lib.ts:48-48 (registration)Registers the 'authenticate_gmail' tool (among others) by handling ListToolsRequestSchema with definitions from getToolDefinitions().server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: getToolDefinitions() }));
- src/tools.ts:47-47 (schema)Description string for the 'authenticate_gmail' tool used in tool definitions.authenticate_gmail: "Authenticate Gmail access via web browser (opens browser automatically)"
- src/tools.ts:144-147 (helper)Stub handler in tools.ts that delegates 'authenticate_gmail' to the main server (lib.ts).case "authenticate_gmail": { // This is a special case - handled in index.ts throw new Error("Authentication should be handled by the main server"); }