Google Workspace Connector (Gmail, Calendar & Docs)
Step-by-step guide to connect PraisonAI agents to Gmail, Google Calendar, Google Drive, and Google Docs using Google Cloud OAuth and MCP
Connect your PraisonAI agents to Gmail, Google Calendar, Google Docs, and Google Drive through a local Google Workspace MCP server powered by your own Google Cloud OAuth credentials.
| Setting | Value |
|---|---|
| Services Covered | Gmail, Google Calendar, Google Drive, Google Docs, Google Sheets |
| Transport | Local STDIO MCP (uvx workspace-mcp) or Custom Remote URL (--url) |
| Authentication | Google Cloud OAuth (GOOGLE_OAUTH_CLIENT_ID & GOOGLE_OAUTH_CLIENT_SECRET) |
import os
from praisonaiagents import Agent, MCP
agent = Agent(
name="Executive Assistant",
instructions="Check today's calendar and recent Gmail threads concisely. Ask before sending any email.",
tools=MCP(
"uvx workspace-mcp --tools gmail calendar",
env={
"GOOGLE_OAUTH_CLIENT_ID": os.environ["GOOGLE_OAUTH_CLIENT_ID"],
"GOOGLE_OAUTH_CLIENT_SECRET": os.environ["GOOGLE_OAUTH_CLIENT_SECRET"],
},
approval="always",
),
)
agent.start("Summarize my meetings today and flag any unread emails from attendees")The user asks for a morning briefing; PraisonAI queries Google Calendar and Gmail via the Workspace MCP server and summarizes the day’s schedule alongside relevant threads.
graph LR
User["๐ค User"] --> Agent["๐ค PraisonAI Agent"]
Agent --> Guard["๐ก๏ธ approval=always"]
Guard --> Local["๐ป workspace-mcp (STDIO)"]
Local --> Google["๐ง Gmail ยท ๐
Calendar ยท ๐ Docs"]
Google --> Result["โ
Daily Briefing & Actions"]
classDef input fill:#6366F1,stroke:#7C90A0,color:#fff
classDef agent fill:#8B0000,stroke:#7C90A0,color:#fff
classDef warn fill:#F59E0B,stroke:#7C90A0,color:#fff
classDef proc fill:#189AB4,stroke:#7C90A0,color:#fff
classDef ok fill:#10B981,stroke:#7C90A0,color:#fff
class User input
class Agent agent
class Guard warn
class Local proc
class Google,Result okHow It Works
You enable only the Google APIs you want (for example Gmail and Calendar) in Google Cloud Console, pass your Desktop OAuth Client ID and Secret via environment variables, and run the Workspace MCP server locally over STDIO so credentials stay on your machine.
sequenceDiagram
participant User
participant GCP as Google Cloud Console
participant WS as workspace-mcp (Local)
participant Google as Google Workspace APIs
participant Agent as PraisonAI Agent
User->>GCP: Enable Gmail and Calendar APIs and create Desktop OAuth client
User->>Agent: Run briefing prompt with workspace-mcp
Agent->>WS: Start STDIO server with OAuth env vars
WS-->>User: First-run browser consent
User->>WS: Approve Gmail and Calendar access
WS->>Google: Fetch calendar events and unread emails
Google-->>WS: Matching threads and events
WS-->>Agent: Structured tool results
Agent-->>User: Morning briefingStep-by-Step Setup
- Create Google Cloud OAuth credentials (one time)
- Open Google Cloud Console and create or select a project.
- Under APIs & Services โ Library, enable only the APIs you need (for example Gmail API, Google Calendar API, Google Drive API, Google Docs API).
- Configure APIs & Services โ OAuth consent screen and add your Google account under Test users.
- Under APIs & Services โ Credentials โ Create Credentials โ OAuth client ID, choose Desktop app and copy the Client ID and Client Secret.
- Export both as environment variables:
bash export GOOGLE_OAUTH_CLIENT_ID="${GOOGLE_OAUTH_CLIENT_ID:?Set GOOGLE_OAUTH_CLIENT_ID in your shell}" export GOOGLE_OAUTH_CLIENT_SECRET="${GOOGLE_OAUTH_CLIENT_SECRET:?Set GOOGLE_OAUTH_CLIENT_SECRET in your shell}" - Install prerequisites
Install PraisonAI with MCP support and
uv(which providesuvxto run Python MCP servers cleanly in isolated environments):bash pip install "praisonai[mcp]" uv --version - Add the Google Workspace connector
CLI (Local STDIO)
Pass
--toolsto expose only the Google Workspace apps you actually need:bash praisonai mcp add google-workspace uvx \ --args "workspace-mcp --tools gmail calendar" \ --env "GOOGLE_OAUTH_CLIENT_ID=$GOOGLE_OAUTH_CLIENT_ID,GOOGLE_OAUTH_CLIENT_SECRET=$GOOGLE_OAUTH_CLIENT_SECRET"Custom Remote URL (Hosted Gateway)
If you use a hosted MCP gateway for Google Workspace:
bash praisonai connectors add google-workspace \ --url https://your-gateway.example.com/mcp \ --oauth \ --authPraisonAI Dashboard
Declare the server in your PraisonAIUI
config.yaml:yaml mcp: enabled: true servers: google-workspace: command: uvx args: ["workspace-mcp", "--tools", "gmail", "calendar"] env: GOOGLE_OAUTH_CLIENT_ID: "${GOOGLE_OAUTH_CLIENT_ID}" GOOGLE_OAUTH_CLIENT_SECRET: "${GOOGLE_OAUTH_CLIENT_SECRET}" - Verify and inspect tools
bash praisonai mcp sync google-workspaceOn first run, sign in with your Google account in the browser to authorize the requested scopes.
- Run your agent safely
python import os from praisonaiagents import Agent, MCP agent = Agent( name="Inbox & Calendar Helper", instructions="Draft replies only โ never send emails without explicit approval.", tools=MCP( "uvx workspace-mcp --tools gmail calendar", env={ "GOOGLE_OAUTH_CLIENT_ID": os.environ["GOOGLE_OAUTH_CLIENT_ID"], "GOOGLE_OAUTH_CLIENT_SECRET": os.environ["GOOGLE_OAUTH_CLIENT_SECRET"], }, approval="always", ), ) agent.start("Find free 30-minute slots tomorrow afternoon and draft a reply proposing them")
Scope Tools for Safety
Common Workflows
- Morning Schedule & Inbox Digest:
"List my calendar events today and highlight unread emails related to each meeting." - Draft-Only Replies:
"Search Gmail for messages about the Q4 invoice and create a draft reply summarizing our latest status."
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
Access blocked during Google sign-in | OAuth consent screen is in Testing mode without your email | Add your Google address under OAuth consent screen โ Test users |
API has not been used in project | Forgot to enable Gmail or Calendar API in Google Cloud Console | Enable the missing API under APIs & Services โ Library |
uvx: command not found | uv is not installed | Install uv (pip install uv or brew install uv) and restart your shell |
praisonai connectors test google-workspace fails | connectors test does not inject server.env for STDIO servers | Verify with praisonai mcp sync google-workspace |
Best Practices
Enable only the Workspace services you need with –tools
Loading every Google service adds dozens of tool schemas to every LLM call. Pass --tools gmail calendar (or drive docs) to keep prompts lean and focused.
Prefer creating Gmail drafts over direct send
Restrict automated inbox agents to reading threads and creating drafts so a human reviews every outbound email before sending.
Keep OAuth secrets in environment variables
Never commit GOOGLE_OAUTH_CLIENT_SECRET into config.yaml or Python files โ always reference ${GOOGLE_OAUTH_CLIENT_SECRET}.