How to integrate Gmail MCP with Pi

Connect Pi to Gmail MCP. Summarize unread emails from this morning, create draft replies to urgent messages, and more using natural language, with authentication handled for you.

Gmail logoGmail
Oauth2

Gmail is Google's email service with powerful spam protection, search, and G Suite integration. It keeps your inbox organized and makes communication fast and reliable.

61 Tools2 Triggers

Introduction

Pi is a minimal, self-extensible coding agent that lives in your terminal — one agent loop over Claude, GPT-5, Gemini, Grok, DeepSeek, and 20+ other providers, with maximum extension surface and minimum product opinion. Its core ships four tools (read, write, edit, bash) and self-extends at runtime through skills, extensions, and packages.

This guide explains the easiest and most robust way to connect your Gmail account to Pi. You can do this through either Composio Connect CLI or Composio Connect MCP. Because Pi already runs shell commands as first-class tools and ships no built-in MCP, the CLI is the recommended path — it's faster to set up, needs no server config, and chains multi-step tasks more reliably. The MCP path is also fully supported through Pi's official pi-mcp-adapter extension.

Also integrate Gmail with

What is Composio Connect?

Composio Connect is a consumer offering that lets anyone plug 1,000+ applications directly into their agent harness — including Pi. It can:

  • Search and load tools from relevant toolkits on-demand, reducing context usage.
  • Chain multiple tools to accomplish complex workflows via a remote workbench, without excessive back-and-forth with the LLM.
  • Manage app authentication end-to-end with zero manual overhead.

Connect Gmail to Pi with Composio

Prerequisites: Install Pi

Pi needs Node.js 18+ (Node 22 recommended). Install the agent globally with npm:

bash
npm install -g --ignore-scripts @earendil-works/pi-coding-agent

On Linux or macOS you can use the installer script instead:

bash
curl -fsSL https://pi.dev/install.sh | sh

Then run pi in any project directory and authenticate your model provider — use /login inside Pi for subscription providers (Claude Pro/Max, ChatGPT, GitHub Copilot), or set an API key such as ANTHROPIC_API_KEY before starting. Confirm it's working:

bash
pi --version

Full first-run details are in the Pi Quickstart.

Option 1: Composio CLI (recommended)

Pi runs shell commands as first-class tools, so the Composio Universal CLI is the most natural fit — no MCP server to configure and reliable multi-step tool chaining. Install and authenticate:

bash
# Install the Composio CLI
curl -fsSL https://composio.dev/install | bash

# Log in to Composio
composio login

Connect to Gmail

Ask Pi to connect to Gmail, or simply request any Gmail-related task. Under the hood Pi calls Composio commands like any other shell tool:

bash
composio search "what can I do with Gmail?"
composio link gmail

On the first Gmail call, composio link gmail opens an OAuth prompt so you can authorize access. After that, every Gmail command works with your stored credentials automatically — just talk to Pi and it will search, execute, and chain Gmail tools as needed.

Option 2: Composio MCP

Pi's core intentionally ships no built-in MCP, but the official pi-mcp-adapter extension adds full MCP support — exposing every server through a single lightweight proxy tool (~200 tokens) instead of loading hundreds of tool definitions into context.

1. Install the MCP adapter extension

bash
pi install npm:pi-mcp-adapter

Restart Pi after installation.

2. Add the Composio MCP server

Create (or edit) a .mcp.json file in your project root, or ~/.config/mcp/mcp.json for a user-global setup:

bash
{
  "mcpServers": {
    "composio": {
      "url": "https://connect.composio.dev/mcp"
    }
  }
}

The adapter connects lazily by default — the server won't start until Pi actually calls one of its tools, and cached metadata keeps search and describe working without a live connection.

3. Authenticate

Run /mcp-auth inside Pi to open the authentication modal and select composio from the list. Complete the sign-in in your browser, then on the consent screen click Allow access to authorize Composio. Once approved, the server shows as connected inside Pi:

Pi /mcp-auth modal listing the composio MCP server
Composio OAuth consent screen with the Allow access button
Composio MCP server connected inside Pi

4. Done!

Confirm the server is live with /mcp to open the interactive panel, then ask Pi to connect to Gmail or request any Gmail-related task — it will prompt you to authorize Gmail on first use.

What is the Gmail MCP server, and what's possible with it?

The Gmail MCP server is an implementation of the Model Context Protocol that connects your AI agent and assistants like Claude, Cursor, etc directly to your Gmail account. It provides structured and secure access to your email, so your agent can search, read, draft, organize, and even manage contacts in your mailbox—all on your behalf.

  • Advanced email search and retrieval: Effortlessly instruct your agent to fetch emails by sender, subject, label, date, or keywords, and even retrieve full message content or threads.
  • Automated drafting and sending: Have your agent create new email drafts, craft replies, add CC/BCC, include attachments, and handle threading to streamline communication.
  • Smart label and inbox organization: Let the agent create new labels, apply or remove labels from emails, and keep your inbox clutter-free by archiving or moving messages.
  • Contact and thread management: Fetch your Gmail contacts, pull entire conversation threads, or download specific attachments to make follow-ups a breeze.
  • Email and draft cleanup: Direct your agent to permanently delete emails or drafts, helping you maintain a tidy mailbox with minimal effort.

Way Forward

With Gmail connected, Pi can now act on your behalf whenever you ask it to.

From here, you can extend Pi further:

  • Connect more apps: Calendar, Slack, Notion, Linear, and hundreds of others are available through the same Composio Connect setup. Each new integration compounds what Pi can do for you.
  • Build workflows across tools: Once multiple apps are connected, Pi can chain actions together — turn an email into a calendar invite, a Slack message into a Linear ticket, or a meeting note into a follow-up draft.
  • Lean into Pi's extension surface: Wrap common Gmail flows as Pi skills or prompt templates so recurring tasks become one-line commands, and use directTools in the MCP adapter to promote your most-used Gmail tools into Pi's tool list directly.

If you run into trouble or want to share what you've built, join the community or check out the Docs for deeper configuration options.

TOOLS & TRIGGERS

Supported Tools and Triggers

Every Gmail action and event your agent gets out of the box.

Modify email labels

Adds and/or removes specified Gmail labels for a message; ensure `message_id` and all `label_ids` are valid (use 'listLabels' for custom label IDs).

Batch delete Gmail messages

Tool to permanently delete multiple Gmail messages in bulk, bypassing Trash with no recovery possible.

Batch modify Gmail messages

Modify labels on multiple Gmail messages in one efficient API call.

Create email draft

Creates a Gmail email draft.

Create Gmail filter

Tool to create a new Gmail filter with specified criteria and actions.

Create label

Creates a new label with a unique name in the specified user's Gmail account.

Create Prompt Post

Send a one-shot prompt to the Sanity Content Agent.

Delete Draft

Permanently deletes a specific Gmail draft using its ID with no recovery possible; verify the correct `draft_id` and obtain explicit user confirmation before calling.

Delete Gmail filter

Tool to permanently delete a Gmail filter by its ID.

Delete label from account (permanent)

Permanently DELETES a user-created Gmail label from the account (not from a message).

Delete message

Permanently deletes a specific email message by its ID from a Gmail mailbox; for `user_id`, use 'me' for the authenticated user or an email address to which the authenticated user has delegated access.

Delete thread

Tool to immediately and permanently delete a specified thread and all its messages.

Fetch emails

Fetches a list of email messages from a Gmail account, supporting filtering, pagination, and optional full content retrieval.

Fetch message by message ID

Fetches a specific email message by its ID, provided the `message_id` exists and is accessible to the authenticated `user_id`.

Fetch Message by Thread ID

Retrieves messages from a Gmail thread using its `thread_id`, where the thread must be accessible by the specified `user_id`.

Forward email message

Forward an existing Gmail message to specified recipients, preserving original body and attachments.

Get Gmail attachment

Retrieves a specific attachment by ID from a message in a user's Gmail mailbox, requiring valid message and attachment IDs.

Get Auto-Forwarding Settings

Tool to get the auto-forwarding setting for the specified account.

Get contacts

Fetches contacts (connections) for the authenticated Google account, allowing selection of specific data fields and pagination.

Get Draft

Retrieves a single Gmail draft by its ID.

Get Gmail filter

Tool to retrieve a specific Gmail filter by its ID.

Get label details

Gets details for a specified Gmail label.

Get Language Settings

Tool to retrieve the language settings for a Gmail user.

Get People

Retrieves either a specific person's details (using `resource_name`) or lists 'Other Contacts' (if `other_contacts` is true), with `person_fields` specifying the data to return.

Get Profile

Retrieves Gmail profile information (email address, aggregate messagesTotal/threadsTotal, historyId) for a user.

Get Vacation Settings

Tool to retrieve vacation responder settings for a Gmail user.

Import message

Tool to import a message into the user's mailbox with standard email delivery scanning and classification.

Insert message into mailbox

Tool to insert a message into the user's mailbox similar to IMAP APPEND.

List CSE identities

Tool to list client-side encrypted identities for an authenticated user.

List CSE key pairs

Tool to list client-side encryption key pairs for an authenticated user.

List Drafts

Retrieves a paginated list of email drafts from a user's Gmail account.

List Gmail filters

Tool to list all Gmail filters (rules) in the mailbox.

List forwarding addresses

Tool to list all forwarding addresses for the specified Gmail account.

List Gmail history

Tool to list Gmail mailbox change history since a known startHistoryId.

List Gmail labels

Retrieves all system and user-created labels for a Gmail account in a single unpaginated response.

List send-as aliases

Lists the send-as aliases for a Gmail account, including the primary address and custom 'from' aliases.

List S/MIME configs

Lists S/MIME configs for the specified send-as alias.

List threads

Retrieves a list of email threads from a Gmail account, identified by `user_id` (email address or 'me'), supporting filtering and pagination.

Modify thread labels

Adds or removes specified existing label IDs from a Gmail thread, affecting all its messages; ensure the thread ID is valid.

Trash thread

Moves the specified thread to the trash.

Move to Trash

Moves an existing, non-deleted email message to the trash for the specified user.

Patch Label

Patches the specified user-created label.

Patch send-as alias

Tool to patch the specified send-as alias for a Gmail user.

Reply to email thread

Sends a reply within a specific Gmail thread using the original thread's subject; do not provide a custom subject as it will start a new conversation instead of replying in-thread.

Search People

Searches contacts by matching the query against names, nicknames, emails, phone numbers, and organizations, optionally including 'Other Contacts'.

Send Draft

Sends an existing draft email AS-IS to recipients already defined within the draft.

Send Email

Sends an email via Gmail API using the authenticated user's Google profile display name.

Get IMAP Settings

Retrieves the IMAP settings for a Gmail user account, including whether IMAP is enabled, auto-expunge behavior, expunge behavior, and maximum folder size.

Get POP settings

Tool to retrieve POP settings for a Gmail account.

Get send-as alias

Tool to retrieve a specific send-as alias configuration for a Gmail user.

Stop watch notifications

Tool to stop receiving push notifications for a Gmail mailbox.

Untrash Message

Tool to remove a message from trash in Gmail.

Untrash thread

Tool to remove a thread from trash in Gmail.

Update draft

Updates (replaces) an existing Gmail draft's content in-place by draft ID.

Update IMAP settings

Tool to update IMAP settings for a Gmail account.

Update Label

Tool to update the properties of an existing Gmail label.

Update Language Settings

Tool to update the language settings for a Gmail user.

Update POP settings

Tool to update POP settings for a Gmail account.

Update send-as alias

Tool to update a send-as alias for a Gmail user.

Update User Attributes Values

Update user attribute values for a resource.

Update Vacation Settings

Tool to update vacation responder settings for a Gmail user.

FAQ

Frequently asked questions

With a standalone Gmail MCP server, the agents and LLMs can only access a fixed set of Gmail tools tied to that server. However, with the Composio Tool Router, agents can dynamically load tools from Gmail and many other apps based on the task at hand, all through a single MCP endpoint.

Yes, you can. Pi fully supports MCP integration. You get structured tool calling, message history handling, and model orchestration while Tool Router takes care of discovering and serving the right Gmail tools.

Yes, absolutely. You can configure which Gmail scopes and actions are allowed when connecting your account to Composio. You can also bring your own OAuth credentials or API configuration so you keep full control over what the agent can do.

All sensitive data such as tokens, keys, and configuration is fully encrypted at rest and in transit. Composio is SOC 2 Type 2 compliant and follows strict security practices so your Gmail data and credentials are handled as safely as possible.

Start with Gmail.It takes 30 seconds.

Managed auth, hosted MCP servers, and every Gmail tool your agent needs.Free to start.

Start building