How to integrate Gmail MCP with OpenCode

How to integrate Gmail MCP with OpenCode This guide explains how to connect Gmail MCP to OpenCode using Composio Connect, which simplifies OAuth, API changes, and reliability concerns. There are two ways to set this up: Via Composio Connect MCP Via the Composio CLI

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

How to integrate Gmail MCP with OpenCode

This guide explains how to connect Gmail MCP to OpenCode using Composio Connect, which simplifies OAuth, API changes, and reliability concerns.

There are two ways to set this up:

Also integrate Gmail with

Why use Composio?

Composio provides a single MCP server or CLI tool that exposes a set of meta-tools, allowing you to:

  • Connect to 1,000+ apps with on-demand tool loading, so you do not fill your LLM context window with unnecessary tool definitions.
  • Use programmatic tool calling through a remote Bash tool, letting LLMs write their own code to handle complex tool chaining. This reduces back-and-forth for frequent tool calls.
  • Handle large tool responses outside the LLM context to keep conversations lean.

Connect Gmail with OpenCode

Option 1: Using Composio CLI

1. Install Composio CLI

Install the Composio CLI, authenticate, and initialize your project:

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

# Authenticate with Composio
composio login

During login, you will be redirected to the sign-in page. Finish the flow and you are all set.

Composio CLI authorization screen

2. Authorize Gmail

Once the CLI is installed, it is essentially done. Give OpenCode access to your apps with these steps:

  1. Launch OpenCode.
  2. Prompt it to "Authenticate with Gmail Composio".
  3. Complete the authentication and authorization flow, and your Gmail integration is all set.
  4. Start asking anything you want.

Option 2: Using Composio MCP

You can also connect Gmail to OpenCode by adding Composio as an MCP server through the OpenCode CLI.

1. Add the Composio MCP server

bash
opencode mcp add

This launches an interactive prompt.

2. Fill in the fields

FieldValue
Namecomposio
Typeremote
URLhttps://connect.composio.dev/mcp
Require OAuthYes
Have client IDNo
OpenCode MCP server interactive prompt for Composio

Alternatively, you can skip the interactive prompt and paste the configuration directly into your OpenCode config file.

Open your global OpenCode config:

bash
open ~/.config/opencode/opencode.json

Add this under the mcp key and save the file.

bash
{
  "mcp": {
    "composio": {
      "type": "remote",
      "url": "https://connect.composio.dev/mcp",
      "enabled": true
    }
  }
}

3. Authenticate

Authenticate the Composio MCP server you just added:

bash
opencode mcp auth composio

This opens a browser session. Authorize Composio and you are done.

Composio browser authorization for OpenCode MCP

4. Verify installation

bash
opencode mcp list

5. Connect Gmail with OpenCode

Now, in the chat, ask the agent to connect to Gmail or give it any Gmail-related task.

For example, ask it to:

  • "Summarize unread emails from this morning"
  • "Create draft replies to urgent messages"
  • "Fetch contact details for recent senders"

It will prompt you to authenticate and authorize access to Gmail.

That is it. Composio tools are now available in OpenCode, and your Gmail account is ready to use.

Way Forward

Now that Gmail is connected, extend your setup by connecting the other apps you already use every day, so your agent can run true cross-app workflows end to end.

  • Connect Calendar to turn threads into scheduled meetings automatically.
  • Connect Slack or Teams to post summaries, approvals, and alerts where your team works.
  • Connect Notion, Linear, Jira, or Asana to convert requests into tickets, tasks, and docs.
  • Connect Drive, Dropbox, or OneDrive to fetch, file, and share attachments without manual steps.

Start with one workflow you do repeatedly, then keep adding apps as you find new handoffs. With everything behind a single MCP endpoint, your agent can coordinate multiple tools safely and reliably in one conversation.

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