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.

SettingValue
Services CoveredGmail, Google Calendar, Google Drive, Google Docs, Google Sheets
TransportLocal STDIO MCP (uvx workspace-mcp) or Custom Remote URL (--url)
AuthenticationGoogle Cloud OAuth (GOOGLE_OAUTH_CLIENT_ID & GOOGLE_OAUTH_CLIENT_SECRET)
python
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.

Diagram

๐Ÿ‘ค User

๐Ÿค– PraisonAI Agent

๐Ÿ›ก๏ธ approval=always

๐Ÿ’ป workspace-mcp (STDIO)

๐Ÿ“ง Gmail ยท ๐Ÿ“… Calendar ยท ๐Ÿ“„ Docs

โœ… Daily Briefing & Actions


How 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.

Diagram
PraisonAI AgentGoogle Workspace APIsworkspace-mcp (Local)Google Cloud ConsoleUserPraisonAI AgentGoogle Workspace APIsworkspace-mcp (Local)Google Cloud ConsoleUserEnable Gmail and Calendar APIs and create Desktop OAuth clientRun briefing prompt with workspace-mcpStart STDIO server with OAuth env varsFirst-run browser consentApprove Gmail and Calendar accessFetch calendar events and unread emailsMatching threads and eventsStructured tool resultsMorning briefing

Step-by-Step Setup

  1. Create Google Cloud OAuth credentials (one time)
    1. Open Google Cloud Console and create or select a project.
    2. Under APIs & Services โ†’ Library, enable only the APIs you need (for example Gmail API, Google Calendar API, Google Drive API, Google Docs API).
    3. Configure APIs & Services โ†’ OAuth consent screen and add your Google account under Test users.
    4. Under APIs & Services โ†’ Credentials โ†’ Create Credentials โ†’ OAuth client ID, choose Desktop app and copy the Client ID and Client Secret.
    5. 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}"
  2. Install prerequisites

    Install PraisonAI with MCP support and uv (which provides uvx to run Python MCP servers cleanly in isolated environments):

    bash
    pip install "praisonai[mcp]"
    uv --version
  3. Add the Google Workspace connector

    CLI (Local STDIO)

    Pass --tools to 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 \
      --auth

    PraisonAI 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}"
  4. Verify and inspect tools
    bash
    praisonai mcp sync google-workspace

    On first run, sign in with your Google account in the browser to authorize the requested scopes.

  5. 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

SymptomCauseFix
Access blocked during Google sign-inOAuth consent screen is in Testing mode without your emailAdd your Google address under OAuth consent screen โ†’ Test users
API has not been used in projectForgot to enable Gmail or Calendar API in Google Cloud ConsoleEnable the missing API under APIs & Services โ†’ Library
uvx: command not founduv is not installedInstall uv (pip install uv or brew install uv) and restart your shell
praisonai connectors test google-workspace failsconnectors test does not inject server.env for STDIO serversVerify 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}.


Related