> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 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`) |

> [!TIP]
>
> Only need Google Calendar in Python without running an MCP server? See [Google Calendar Tools](https://praison.ai/docs/tools/googlecalendar.md). Only need Google Drive? See the [Google Drive Connector](https://praison.ai/docs/mcp/gdrive.md).

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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 ok
```

***

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

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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 briefing
```

***

## Step-by-Step Setup

**1. Create Google Cloud OAuth credentials (one time)**

1. Open [Google Cloud Console](https://console.cloud.google.com/) 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 theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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 theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
pip install "praisonai[mcp]"
uv --version
```

**3. Add the Google Workspace connector**

> [tab] CLI (Local STDIO)
>
> Pass `--tools` to expose only the Google Workspace apps you actually need:
>
> ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> 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"
> ```

> [tab] Custom Remote URL (Hosted Gateway)
>
> If you use a hosted MCP gateway for Google Workspace:
>
> ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> praisonai connectors add google-workspace \
>   --url https://your-gateway.example.com/mcp \
>   --oauth \
>   --auth
> ```

> [tab] PraisonAI Dashboard
>
> Declare the server in your PraisonAIUI `config.yaml`:
>
> ```yaml theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> 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 theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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 theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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

> [!WARNING]
>
> **Protect outbound emails and calendar invites.** Pass `--tools gmail calendar` (only the services you need), list exact read/draft tools with `praisonai mcp sync google-workspace`, and keep `approval="always"` enabled so the agent cannot send emails or delete events silently.

***

## 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

> [accordion] 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.

> [accordion] 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.

> [accordion] 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

> [card] [Google Drive Connector](https://praison.ai/docs/mcp/gdrive.md)
>
> Dedicated Google Drive MCP setup guide

> [card] [Google Calendar Tools (Python)](https://praison.ai/docs/tools/googlecalendar.md)
>
> Native Python tools for Google Calendar without MCP

> [card] [List of Connectors](https://praison.ai/docs/features/connectors-list.md)
>
> Browse all popular connectors and step-by-step guides

> [card] [Human Approval](https://praison.ai/docs/features/approval.md)
>
> Require human approval before outbound actions


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.