For the complete documentation index, see llms.txt. This page is also available as Markdown.

Google Workspace Connector

Use the platform's built-in Google Workspace connector (MCP) to let an Agent search Gmail messages, Google Calendar events, and Google Drive files

Use Case: A Work Agent That Checks Email, Looks Up Schedules, and Finds Files

Much of daily work is really "finding things": where is the quote attached to the email a customer sent last week, what time is this afternoon's meeting, which version of that SOP in the shared drive is the latest. This information is scattered across Gmail, Google Calendar, and Google Drive, and employees have to switch between multiple tabs to search.

With MaiAgent's built-in Google Workspace connector, an Agent can access these services using an authorized Google account, and complete lookups and summaries from a single sentence, for example:

  • "Find the email a supplier sent last week with a quote attached, and organize the amounts into a table"

  • "What meetings do I have tomorrow afternoon? Are there any video calls with customers?"

  • "Is there a new-hire training presentation in the shared drive? Give me the link"

What this page covers

This page demonstrates how to attach the Google Workspace connector as an MCP tool to a custom-built Agent. For a full description of tool fields and the OAuth authorization flow, see Create an MCP Tool; for members connecting on their own in MaiGPT, see Connectors; for connectors of official built-in Agents, see Enablement and Management › Connectors.

How It Works

The Google Workspace connector is a Remote MCP server maintained by MaiAgent and already registered in the platform's connector list (its source is labeled "Built-in"), so you do not need to host anything or enter a server URL. It uses OAuth 2.0 authorization:

  1. After you click to authorize, you are redirected to Google's sign-in and consent screen

  2. Select a Google account, review the permissions listed on the screen, and consent

  3. You return to MaiAgent; the credentials are encrypted and stored by the backend, not in the browser

  4. From then on, the Agent calls services such as Gmail, Calendar, and Drive as this Google account

Authorizable Services and Access Levels

When a member authorizes the Google Workspace connector in MaiGPT, a "Select Authorization Scope" window appears first, where you can adjust the access level of each service following the principle of least privilege:

Service
Selectable access levels (default)

Google Drive

Read-only / Only files created by this app / Full access (default: Full access)

Gmail

Send only / Send and manage (default: Send and manage)

Google Calendar

Read-only / Full access (default: Full access)

Google Sheets, Docs, Slides, Forms

Each can be turned on or off (all on by default)

If you choose "Send only" for Gmail, the Agent can only send email and cannot search or read messages; to let the Agent look up email, keep "Send and manage".

When authorizing as a tool (the "Organization-shared" or "Per-contact authorization" options below), confirm the permissions being granted on Google's consent screen.

Prerequisites

  • Your role has the Tool permission and can create and edit tools (ask your organization administrator to confirm this in Role Permission Management)

  • A Google account for authorization, whose Google Workspace allows third-party application access. If the Workspace administrator restricts third-party OAuth applications, authorization will be rejected on Google's side and you will need to ask the administrator to allow it

  • Decide on the "authorization subject": whether this Agent operates with one organization-shared account, or each user signs in with their own account (see below)

Workflow

1. Create a Google Workspace Tool

Open Tool Management and Select the MCP Type

From the left menu, go to AI Features → Tools, and click Add Tool in the upper right. Select MCP as the tool type, then enter a display name (for example, Google Workspace Work Assistant) and a tool description.

Select Google Workspace from the Connector Cards

Under "Select a service to connect", click the Google Workspace card. The system fills in the MCP server URL automatically, and authentication is handled by OAuth, so you do not need to enter a key in the headers.

The Google Workspace connector card is selected, labeled OAuth 2.0 and 'Search Gmail messages, query calendar events, read Drive files'
Select the Google Workspace card

Choose the Authorization Subject

After selecting the card, use "Authorization Subject" to decide whose Google account the Agent operates with. For the general rules for both authorization subjects, see Create an MCP Tool: Choose the Authorization Subject; applied to Google Workspace:

Authorization subject
Suitable scenarios
Notes

Organization-shared

Searching a shared mailbox, shared calendar, or department shared drive; Agents open to anonymous visitors on LINE or Web Chat

All users access data as "the authorizer's account", so do not use a personal mailbox for shared authorization

Per-contact authorization

Employees looking up their own emails, schedules, and files

Requires a signed-in user; in conversations with anonymous, signed-out visitors, the Agent does not receive this tool

Authorization subject set to per-contact authorization, with a notice that per-contact authorization requires a signed-in user
When "Per-contact authorization" is selected, the screen reminds you that anonymous visitors will not receive this tool

Complete Authorization and Pick Tools

  • Organization-shared: Click "Authorize", then sign in and consent in the Google window. When finished, the screen shows "Authorized", and the system automatically retrieves and saves the tool list. Open the tool again, enable only the tools this Agent truly needs under "Allowed Tools", and click "Confirm".

  • Per-contact authorization: No authorization is needed here. When a contact first uses the tool in a conversation, an authorization card appears in the conversation, and they complete authorization with their own Google account. Web Chat users can later view or disconnect it in Connected Services; administrators can view, revoke, or trigger re-authorization in the "Connector Authorization" tab of the "Contacts" edit window.

2. Create an Agent and Configure the Tool

Create a new Agent (or edit an existing one). Under "Response Mode Settings", switch the response mode to Agent, then go to the "Tools" tab and select the Google Workspace tool you just created. For detailed steps, see Configure Tools for an Agent.

You can refer to the following role instructions. The key is to clearly state "what to do before authorization" and "do not pretend to have done something":

If this Agent is for organization members to use in MaiGPT or for internal Q&A, besides attaching the tool, you can also bind connectors already enabled by the organization in the Agent settings' "MaiGPT Connectors" tab (Agent mode only), and members authorize them individually. To enable connectors for the organization, see Manage Connectors (Administrators).

3. Go Live

Once finished, you can test in the Agent's chat interface. Here are some common questions and how the Agent handles them:

User question
What the Agent does

"Find the email from Finance last week with an Excel attachment"

Searches emails by sender, time, and attachment conditions, and lists the subject, date, and attachment names

"What is this email's attachment about? Summarize it for me"

Reads the attachment content and summarizes the key points

"What free slots do I have this week for a 1-hour meeting?"

Reads calendar events and organizes the available time slots

"Is there a spreadsheet about 'annual budget' in the drive?"

Searches Drive and returns file names and links

You can review the parameters and return content of each tool call in Tool Execution Records to confirm whether the Agent used the right tool and whether the authorization is still valid.

Reading Gmail Attachments

For example, a sales assistant connects Google Workspace in MaiGPT and asks: "Find the quote email the demo supplier sent last week and summarize the items and amounts in the PDF attachment." The Agent finds the email and downloads the attachment, which is saved as a file in this conversation. The Agent then reads the PDF content and replies with the items and amounts organized for her.

Members connect Google Workspace in MaiGPT from the chat input box via + → Connectors: a service that is not yet authorized shows Authorize on the right, and after authorization it shows Enabled with a toggle. For the steps, see Connectors.

The + menu expanded to 'Connectors'; the connected services list Google Workspace (Enabled, toggle on), Microsoft 365 (an 'Authorize' button on the right), and Google Analytics
MaiGPT + → Connectors: Google Workspace is authorized and enabled

How Attachments Are Read

  1. After the Agent downloads an attachment through the connector, the attachment is saved as a file in this conversation and is used only in this conversation. The tool response in the conversation shows just one line with the save result (file name, type, and size), not the raw encoding of the attachment. The file name saved to the conversation is assigned by the system (for example, gmail_get_attachment-1.pdf), not the original file name in the email.

  2. The Agent then reads the content with the system function Parse Attachment Content (plain text files can also be read with Read Plain Text Attachment). Both are under the Agent's Advanced Settings → System Functions; see Control System Functions. If both are turned off, the attachment is still saved to the conversation, but the Agent will explain that it cannot read it here.

  3. If you later ask a follow-up about the same attachment in the same conversation, the Agent can find it again from this conversation's file list without downloading it again; see Retrieve Files in This Conversation.

A MaiGPT conversation: the user asks the Agent to summarize the PDF attachment of the docs-line demo supplier's quote email; the execution steps are Gmail List Messages, Gmail Get Message, Gmail Get Attachment, and Processed File, and the reply lists Item A 1,200, Item B 3,400, and a total of 4,600
The Agent downloads the Gmail PDF attachment, saves it to the conversation, then reads and summarizes the content

Supported Attachment Formats

Type
Formats

Documents

PDF; Word (.docx, .doc, .odt); Excel (.xlsx, .xls, .ods); PowerPoint (.pptx, .ppt, .odp)

Email files

Outlook messages (.msg)

Text and tables

CSV and plain text, in either UTF-8 or Big5 encoding (CSV files saved from Traditional Chinese Excel are also read correctly)

Images

PNG, JPEG, GIF, WebP, TIFF, BMP; the content is read with image recognition

Audio

MP3, WAV, M4A, AAC, handled as audio attachments; M4A recordings from both iPhone and Android phones are supported

Attachments That Cannot Be Read

The following attachments are not saved to the conversation. The Agent receives the attachment's size and the reason it cannot be read (for example, it exceeds the limit, or it is an unsupported format such as an archive or a video), and explains this to the user accordingly:

  • Exceeding the size limit: attachments larger than the platform's attachment parsing size limit (10 MB by default)

  • Corrupted Office files, and encrypted .docx, .xlsx, and .pptx files

  • Archives and executables: for example, ZIP, RAR, 7-Zip, and gzip archives, as well as executable files

  • Videos: MP4 or QuickTime videos with picture (M4A recordings with audio only are not affected)

The tool response of Gmail Get Attachment shows the attachment was not saved to the conversation (not saved as an attachment), with a file size of 11 MB; the Agent replies that the attachment is an 11 MB ZIP that exceeds the 10 MB attachment processing limit, so the content cannot be read
When an attachment exceeds the size limit, the Agent explains why it cannot be read

Encrypted legacy .doc and .xls files are saved to the conversation, but their content likewise cannot be read when parsed.

For the Agent to search and read email attachments, Gmail must keep "Send and manage" when the member authorizes; see Authorizable Services and Access Levels.

FAQ

Q: During authorization, Google shows "This app is blocked", or I cannot select my company account? A: This means your company's Google Workspace administrator has restricted third-party OAuth applications. Ask the Workspace administrator to allow the MaiAgent application in the Admin console, then authorize again.

Q: It worked before, but now the Agent says authorization is invalid? A: Google's authorization token may have expired or been revoked. For organization-shared authorization, open the tool, click "Revoke", and then click "Authorize" again. For per-contact authorization, the user can click "Re-authorize" in Connected Services, or an administrator can trigger re-authorization in the "Connector Authorization" tab of the "Contacts" edit window.

Q: How do I revoke authorization? A: For organization-shared authorization, click "Revoke" in the tool settings. For per-contact authorization, the user disconnects it in Connected Services, and administrators can also revoke it in the "Connector Authorization" tab of the "Contacts" edit window. To also remove the records on Google's side, go to "Third-party apps & services" in your Google Account and remove MaiAgent's access.

Q: Can the Agent send emails, create events, or write files on the user's behalf? A: It depends on the authorization scope and the retrieved tool list. First confirm that the corresponding tools (such as sending email or creating events) are actually in "Allowed Tools", then write them into the role instructions. When members authorize in MaiGPT, select "Send and manage" for Gmail and "Full access" for Calendar.

Further Reading

Last updated

Was this helpful?