Notebooks
G
Groq
Mcp Google Workspace

Mcp Google Workspace

mcp-google-workspacemanaged-by-terraformtutorials03-mcpgroq-api-cookbook

Groq + Google Workspace MCP: Intelligent Email, Calendar & Drive Automation

This notebook demonstrates how to empower Groq inference with Google Workspace capabilities using Model Context Protocol (MCP) connectors for Gmail, Google Calendar, and Google Drive. By connecting Groq's ultra-fast inference with Google's productivity suite, you can build AI agents that read emails, schedule meetings, search documents, and manage your workspaceโ€”all through natural language.

What are Google Workspace MCP Connectors?

Google Workspace MCP connectors provide AI models with secure, authenticated access to your productivity data. Instead of being limited to training data, your AI can:

  • Access real-time data from Gmail, Calendar, and Drive
  • Take actions like sending emails or creating calendar events
  • Coordinate across services in a single natural language request
  • Maintain security through OAuth 2.0 authentication

These connectors use the industry-standard OAuth 2.0 flow, ensuring your data remains secure and access is properly scoped.

What We'll Build

We'll create an AI productivity assistant that:

  1. Searches your Gmail for unread emails and provides intelligent summaries
  2. Checks your Google Calendar to view schedules and find meetings
  3. Searches your Google Drive for documents based on natural language queries
  4. Coordinates across all three services to provide comprehensive workspace insights

This showcases how Google Workspace MCP connectors enable powerful productivity automation through simple, fast AI interactions.


[ ]

Getting Started

Follow these steps to set up:

1. Get your Groq API key

Sign up for Groq at console.groq.com to get your free API key.

2. Get your Google Workspace OAuth Token

Google Workspace MCP connectors require OAuth 2.0 authentication. You'll need to obtain an access token with the following required scopes:

Required OAuth Scopes

From Gmail API v1:

  • https://www.googleapis.com/auth/gmail.modify - Read and modify Gmail messages

From Google Calendar API v3:

  • https://www.googleapis.com/auth/calendar.events - Manage calendar events

From Google Drive API v3:

  • https://www.googleapis.com/auth/drive.readonly - Download the content of Drive files

From Google OAuth2 API v2:

  • https://www.googleapis.com/auth/userinfo.email - View your email address
  • https://www.googleapis.com/auth/userinfo.profile - View your basic profile info

To obtain your OAuth token:

  1. Visit the OAuth Playground
  2. In Step 1, select all five scopes listed above
  3. Click "Authorize APIs" and sign in with your Google account
  4. In Step 2, click "Exchange authorization code for tokens"
  5. Copy the Access token (starts with ya29.)

Note: OAuth tokens expire after approximately 1 hour. You'll need to refresh them for extended sessions.

3. Configure your environment

Paste your API keys into the cell below and run the cell.

Note: do not run the cell below if your keys are already configured in an .env file in this directory

[ ]
[ ]

Step 1: Set up the Groq client

[ ]

Step 2: Set up Google Workspace MCP Connectors

Unlike remote MCP servers that use server_url, Google Workspace uses connectors with connector_id and OAuth authorization. This allows for secure, user-authenticated access to your Google Workspace data.

You can configure one or more connectors depending on which Google services you want to access:

[ ]

Step 3: Connect Groq to Google Workspace MCPs through Groq's Responses API

This will be our main function we use to call the Groq API with Google Workspace connectors.

[ ]

Let's implement a helper function to display MCP tool calls and their results. This will provide transparency into which tools were called, their arguments, and outputs.

(This is generally useful when debugging if you need to view raw MCP outputs, it's not vital for functionality)

[ ]

Examples

Note: Some queries may consume more tokens than others depending on the amount of tool calls the model makes. Please be aware of various rate limits that are tied to your API keys if you happen to run into any rate limit errors.

Important: Make sure your OAuth token has the necessary scopes for the operations you want to perform.


Demo 1: Gmail - Search Unread Emails

Let's start with a simple Gmail operation: searching for recent unread emails. This demonstrates how Groq can quickly process your email data and provide intelligent summaries.

[ ]

Let's display the agent's response in markdown format.

[ ]

Let's examine the agent's intermediate steps, including how it calls Gmail connector tools.

[ ]

Demo 2: Google Calendar - Check Today's Schedule

Now let's interact with Google Calendar to retrieve today's events and get an overview of your schedule.

[ ]

Let's display the calendar summary.

[ ]

Let's examine the agent's intermediate steps.

[ ]

Demo 3: Google Drive - Search Documents

Let's use Google Drive to search for specific documents and get information about them.

[ ]

Let's display the search results.

[ ]

Let's examine the agent's intermediate steps.

Demo 4: Google Drive - Find PDF Documents

Let's search specifically for PDF files in your Drive and get their details. The drive.readonly scope allows us to download and read the content of Drive files.

[ ]

Let's display the PDF search results.

[ ]

Let's examine the agent's intermediate steps.

[ ]

Demo 5: Multi-Service Workflow - Email & Calendar Integration

Now let's demonstrate the power of combining multiple Google Workspace services. We'll search for emails about meetings and cross-reference them with the calendar.

[ ]

Let's display the cross-referenced results.

[ ]

Let's examine the agent's intermediate steps.

[ ]

Demo 6: Try it Yourself

Now it's your turn! Create your own Google Workspace automation by replacing the query below with your specific task.

Safe ideas for screen recording:

  • Email stats: "How many unread emails do I have? Group them by sender domain (e.g., gmail.com, work domain)"
  • Calendar summary: "How many meetings do I have this week? What's my busiest day?"
  • Drive overview: "How many files do I have in my Drive? What are the most common file types?"
  • File organization: "List my 5 largest files in Drive with their sizes"
  • Weekly summary: "Give me a count of emails, calendar events, and Drive files for this week"

Advanced ideas (use with your own data):

  • Email triage: "Find all emails from my boss this week and summarize the key action items"
  • Meeting prep: "What meetings do I have tomorrow? For each meeting, search my Drive for related documents"
  • Document search: "Search my Drive for files containing 'budget' or 'proposal'"
[ ]
[ ]
[ ]

Available Google Workspace MCP Tools

The Google Workspace MCP connectors provide access to a wide range of tools across Gmail, Google Calendar, and Google Drive:

Gmail Tools

ToolDescription
gmail_searchSearch for emails with advanced filters (sender, date, labels, etc.)
gmail_get_messageRetrieve full details of a specific email message
gmail_sendSend emails with attachments and formatting
gmail_create_draftCreate draft emails to review before sending
gmail_modify_labelsAdd or remove labels from messages
gmail_list_labelsGet all available labels in your Gmail account

Google Calendar Tools

ToolDescription
calendar_list_eventsList events within a specific time range
calendar_get_eventGet detailed information about a specific event
calendar_create_eventCreate new calendar events with attendees and reminders
calendar_update_eventModify existing calendar events
calendar_delete_eventRemove events from your calendar
calendar_list_calendarsList all calendars you have access to

Google Drive Tools

ToolDescription
drive_search_filesSearch for files and folders with advanced queries
drive_get_fileGet metadata and content of a specific file
drive_list_filesList files in a specific folder or across Drive
drive_create_fileCreate new files or folders
drive_update_fileModify existing file metadata or content
drive_delete_fileMove files to trash
drive_export_fileExport Google Docs/Sheets/Slides to standard formats

Key Benefits

  1. Natural Language Interface: Control Google Workspace using plain English
  2. Ultra-Fast Responses: Sub-second inference from Groq combined with real-time Google data
  3. Multi-Service Coordination: Seamlessly work across Gmail, Calendar, and Drive in one workflow
  4. Secure OAuth Authentication: Industry-standard OAuth 2.0 for safe access to your data
  5. Full Transparency: See exactly which tools were called and what data was accessed

Alternative: Using curl

Prefer curl? Here's a quick example for Gmail:

curl -X POST https://api.groq.com/api/openai/v1/responses \
  -H "Authorization: Bearer YOUR_GROQ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"openai/gpt-oss-20b","tools":[{"type":"mcp","server_label":"gmail","connector_id":"connector_gmail","authorization":"YOUR_OAUTH_TOKEN","require_approval":"never"}],"input":"Show me my last 3 unread emails"}'

Replace connector details for Calendar (connector_googlecalendar) or Drive (connector_googledrive).


Summary

You've just experienced the power of combining Groq's fast inference with Google Workspace MCP connectors.

๐Ÿ”ง Google Workspace MCP Connectors

Description: Google Workspace MCP connectors enable AI models to interact with Gmail, Google Calendar, and Google Drive through secure OAuth authentication. Build intelligent assistants that can read emails, manage your schedule, search documents, and automate your productivity workflows.

What Makes This Powerful:

  1. Speed + Intelligence: Groq's ultra-fast inference means your AI assistant responds instantly to complex workspace queries
  2. Real-Time Data: Unlike static training data, MCP connectors give your model access to your actual, current emails, calendar, and files
  3. Multi-Service Workflows: Coordinate actions across multiple Google services in a single natural language request
  4. Secure Authentication: OAuth 2.0 ensures your data is accessed securely with proper scope limitations
  5. Productivity Automation: Build custom workflows for email triage, meeting prep, document search, and more

Use Cases:

  • Executive Assistant: Summarize important emails, manage calendar, and prepare for meetings
  • Email Triage: Automatically categorize, prioritize, and respond to emails
  • Meeting Intelligence: Search for meeting-related documents and provide context before calls
  • Document Discovery: Find and organize files across your Drive based on natural language queries
  • Schedule Optimization: Analyze calendar patterns and suggest better time management
  • Cross-Service Workflows: Connect email threads with calendar events and relevant documents

Resources:


Happy automating with Groq + Google Workspace! ๐Ÿš€