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

# Gmail

> Read, send, label, draft, and manage mail via the Google Gmail API. 30 tools covering messages, threads, drafts, labels, attachments, and history — accessible through the MCP runtime endpoint.

<img src="https://icon.horse/icon/mail.google.com" alt="Gmail" style={{ width: "48px", height: "48px", marginBottom: "16px" }} />

## Overview

| Property   | Value                          |
| ---------- | ------------------------------ |
| Slug       | `gmail`                        |
| Category   | Communication                  |
| Auth       | OAuth 2.0 + PKCE               |
| Base URL   | `https://gmail.googleapis.com` |
| Tool count | 30                             |
| Rate limit | 5 req/sec, 250 req/min         |

## Supported tools

All 30 slugs surfaced through MCP:

| Area                       | Slugs                                                                                                                           |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| Profile                    | `GMAIL_GET_PROFILE`                                                                                                             |
| Read messages              | `GMAIL_FETCH_EMAILS`, `GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID`, `GMAIL_FETCH_MESSAGE_BY_THREAD_ID`                                   |
| Send & write               | `GMAIL_SEND_EMAIL`, `GMAIL_SEND_DRAFT`                                                                                          |
| Delete & trash             | `GMAIL_DELETE_MESSAGE`, `GMAIL_MOVE_TO_TRASH`, `GMAIL_UNTRASH_MESSAGE`, `GMAIL_BATCH_DELETE_MESSAGES`                           |
| Modify labels              | `GMAIL_ADD_LABEL_TO_EMAIL`, `GMAIL_BATCH_MODIFY_MESSAGES`                                                                       |
| Attachments                | `GMAIL_GET_ATTACHMENT`                                                                                                          |
| Drafts                     | `GMAIL_LIST_DRAFTS`, `GMAIL_GET_DRAFT`, `GMAIL_CREATE_EMAIL_DRAFT`, `GMAIL_UPDATE_DRAFT`, `GMAIL_DELETE_DRAFT`                  |
| Labels                     | `GMAIL_LIST_LABELS`, `GMAIL_GET_LABEL`, `GMAIL_CREATE_LABEL`, `GMAIL_UPDATE_LABEL`, `GMAIL_PATCH_LABEL`, `GMAIL_DELETE_LABEL`   |
| Threads                    | `GMAIL_LIST_THREADS`, `GMAIL_DELETE_THREAD`, `GMAIL_MODIFY_THREAD_LABELS`, `GMAIL_MOVE_THREAD_TO_TRASH`, `GMAIL_UNTRASH_THREAD` |
| History (incremental sync) | `GMAIL_LIST_HISTORY`                                                                                                            |

## Connect setup

Gmail uses Google's OAuth 2.0 with PKCE. You need a Google Cloud project with the **Gmail API** enabled and OAuth credentials configured for a Web application.

<Steps>
  <Step title="Create a Google Cloud OAuth client">
    Go to [Google Cloud Console → APIs & Services → Credentials](https://console.cloud.google.com/apis/credentials), choose **Create credentials → OAuth client ID → Web application**, then copy the **Client ID** and **Client Secret**.
  </Step>

  <Step title="Add the redirect URI">
    Under **Authorized redirect URIs**, add:

    ```
    https://api.routemcp.io/api/v1/connect/oauth/callback
    ```
  </Step>

  <Step title="Enable the Gmail API">
    In **APIs & Services → Library**, search for **Gmail API** and click **Enable** on the same Google Cloud project.
  </Step>

  <Step title="Configure required scopes">
    Add these scopes on the OAuth consent screen:

    * `https://mail.google.com/` — full Gmail access (read / send / modify / delete)
    * `openid`
    * `email`
    * `profile`
  </Step>

  <Step title="Connect via the widget">
    The end user opens the Connect widget, picks Gmail, and is sent through Google's consent screen.
  </Step>
</Steps>

## Usage

### Through the chat endpoint (recommended)

```bash theme={null}
# Summarise unread mail
curl -N -X POST "https://api.routemcp.io/api/v1/mcp/<workspace_id>/chat" \
  -H "x-api-key: sk_live_your_key" \
  -H "x-session-id: user-42" \
  -H "content-type: application/json" \
  -d '{"message": "Summarise my five most recent unread emails."}'

# Compose and send
curl -N -X POST "https://api.routemcp.io/api/v1/mcp/<workspace_id>/chat" \
  -H "x-api-key: sk_live_your_key" \
  -H "x-session-id: user-42" \
  -H "content-type: application/json" \
  -d '{"message": "Email alice@example.com — subject `Lunch?`, body: pick a day this week."}'
```

The agent loop picks `GMAIL_FETCH_EMAILS` / `GMAIL_SEND_EMAIL` and streams results back as SSE.

### Direct MCP JSON-RPC (Claude Desktop / Cursor / custom MCP clients)

```json theme={null}
{
  "mcpServers": {
    "routemcp": {
      "url": "https://api.routemcp.io/api/v1/mcp/<workspace_id>",
      "headers": {
        "x-api-key": "<YOUR_API_KEY>",
        "x-session-id": "<SESSION_ID>"
      }
    }
  }
}
```

Once connected, MCP clients can invoke any of the 30 tools by slug via the standard `tools/call` JSON-RPC method.
