Gmail MCP for AI Agents

Securely connect your AI agents and chatbots (Claude, ChatGPT, Cursor, etc) with Gmail MCP or direct API to read, send, search, and label emails through natural language.

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

Try Gmail now

Type what you want done — sign in and watch it run live in the Tool Router playground.

TOOL ROUTER PLAYGROUND
Gmail
Try asking
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.

SETUP GUIDE

Connect Gmail MCP Tool with your Agent

1

Install Composio

typescript
npm install @composio/core ai @ai-sdk/openai @ai-sdk/mcp
Install the Composio SDK and Claude Agent SDK
2

Create Tool Router Session

typescript
import { Composio } from '@composio/core';

const composio = new Composio({ apiKey: 'your-api-key' });

console.log("Creating Tool Router session...");
const { mcp } = await composio.create('your-user-id');
console.log(`Tool Router session created: ${mcp.url}`);
Initialize the Composio client and create a Tool Router session
3

Connect to AI Agent

typescript
import { openai } from '@ai-sdk/openai';
import { experimental_createMCPClient as createMCPClient } from '@ai-sdk/mcp';
import { generateText, stepCountIs } from 'ai';

const client = await createMCPClient({
  transport: {
    type: 'http',
    url: mcp.url,
    headers: { 'x-api-key': 'your-composio-api-key' }
  }
});

const tools = await client.tools();

const { text } = await generateText({
  model: openai('gpt-4o'),
  tools,
  messages: [{ role: 'user', content: 'Summarize unread emails from this morning' }],
  stopWhen: stepCountIs( 5 )
});

console.log(`Agent: ${text}`);
Use the MCP server with your AI agent
SETUP GUIDE

Connect Gmail API Tool with your Agent

1

Install Composio

typescript
npm install @composio/openai
Install the Composio SDK
2

Initialize Composio and Create Tool Router Session

typescript
import OpenAI from 'openai';
import { Composio } from '@composio/core';
import { OpenAIResponsesProvider } from '@composio/openai';

const composio = new Composio({
  provider: new OpenAIResponsesProvider(),
});
const openai = new OpenAI({});
const session = await composio.create('your-user-id');
Import and initialize Composio client, then create a Tool Router session
3

Execute Gmail Tools via Tool Router with Your Agent

typescript
const tools = session.tools;
const response = await openai.responses.create({
  model: 'gpt-4.1',
  tools: tools,
  input: [{
    role: 'user',
    content: 'Summarize unread emails from this morning'
  }],
});
const result = await composio.provider.handleToolCalls(
  'your-user-id',
  response.output
);
console.log(result);
Get tools from Tool Router session and execute Gmail actions with your Agent

Why Use Composio?

AI Native Gmail Integration

  • Supports both Gmail MCP and direct API based integrations
  • Structured, LLM-friendly schemas for reliable tool execution
  • Rich coverage for reading, writing, and querying your Gmail data

Managed Auth

  • Built-in OAuth handling with automatic token refresh and rotation
  • Central place to manage, scope, and revoke Gmail access
  • Per user and per environment credentials instead of hard-coded keys

Agent Optimized Design

  • Tools are tuned using real error and success rates to improve reliability over time
  • Comprehensive execution logs so you always know what ran, when, and on whose behalf

Enterprise Grade Security

  • Fine-grained RBAC so you control which agents and users can access Gmail
  • Scoped, least privilege access to Gmail resources
  • Full audit trail of agent actions to support review and compliance
FAQ

Frequently asked questions

No, you can get started immediately using Composio's built-in Gmail app. For production, we recommend configuring your own OAuth credentials.

Yes! Composio's Tool Router enables agents to use multiple toolkits. Learn more.

Composio is SOC 2 and ISO 27001 compliant with all data encrypted in transit and at rest. Learn more.

Composio maintains and updates all toolkit integrations automatically, so your agents always work with the latest API versions.

Start with Gmail.It takes 30 seconds.

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

Start building