Gmail Integration 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 Logo
Gradient Top
Gradient Middle
Gradient Bottom
divider

Supported Tools and Triggers

Tools
Triggers
Modify email labelsAdds and/or removes specified gmail labels for a message; ensure `message id` and all `label ids` are valid (use 'listlabels' for custom label ids).
Create email draftCreates a gmail email draft, supporting to/cc/bcc, subject, plain/html body (ensure `is html=true` for html), attachments, and threading.
Create labelCreates a new label with a unique name in the specified user's gmail account.
Delete DraftPermanently deletes a specific gmail draft using its id; ensure the draft exists and the user has necessary permissions for the given `user id`.
Delete messagePermanently 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.
Fetch emailsFetches a list of email messages from a gmail account, supporting filtering, pagination, and optional full content retrieval.
Fetch message by message IDFetches a specific email message by its id, provided the `message id` exists and is accessible to the authenticated `user id`.
Fetch Message by Thread IDRetrieves messages from a gmail thread using its `thread id`, where the thread must be accessible by the specified `user id`.
Get Gmail attachmentRetrieves a specific attachment by id from a message in a user's gmail mailbox, requiring valid message and attachment ids.
Get contactsFetches contacts (connections) for the authenticated google account, allowing selection of specific data fields and pagination.
Get PeopleRetrieves 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 ProfileRetrieves key gmail profile information (email address, message/thread totals, history id) for a user.
List draftsRetrieves a paginated list of email drafts from a user's gmail account.
List Gmail labelsRetrieves a list of all system and user-created labels for the specified gmail account.
List threadsRetrieves a list of email threads from a gmail account, identified by `user id` (email address or 'me'), supporting filtering and pagination.
Modify thread labelsAdds or removes specified existing label ids from a gmail thread, affecting all its messages; ensure the thread id is valid.
Move to TrashMoves an existing, non-deleted email message to the trash for the specified user.
Patch LabelPatches the specified label.
Remove labelPermanently deletes a specific, existing user-created gmail label by its id for a user; cannot delete system labels.
Reply to email threadSends a reply within a specific gmail thread using the original thread's subject, requiring a valid `thread id` and correctly formatted email addresses.
Search PeopleSearches contacts by matching the query against names, nicknames, emails, phone numbers, and organizations, optionally including 'other contacts'.
Send DraftSends the specified, existing draft to the recipients in the to, cc, and bcc headers.
Send EmailSends an email via gmail api using the authenticated user's google profile display name, requiring `is html=true` if the body contains html and valid `s3key`, `mimetype`, `name` for any attachment.

Connect Gmail MCP Tool with your Agent

Python
TypeScript

Install Composio

python
pip install composio claude-agent-sdk
Install the Composio SDK and Claude Agent SDK

Create Tool Router Session

python
from composio import Composio
from claude_agent_sdk import ClaudeSDKClient, ClaudeAgentOptions

composio = Composio(api_key='your-composio-api-key')
session = composio.create(user_id='your-user-id')
url = session.mcp.url
Initialize the Composio client and create a Tool Router session

Connect to AI Agent

python
import asyncio

options = ClaudeAgentOptions(
    permission_mode='bypassPermissions',
    mcp_servers={
        'tool_router': {
            'type': 'http',
            'url': url,
            'headers': {
                'x-api-key': 'your-composio-api-key'
            }
        }
    },
    system_prompt='You are a helpful assistant with access to Gmail tools.',
    max_turns=10
)

async def main():
    async with ClaudeSDKClient(options=options) as client:
        await client.query('Summarize unread emails from this morning')
        async for message in client.receive_response():
            if hasattr(message, 'content'):
                for block in message.content:
                    if hasattr(block, 'text'):
                        print(block.text)

asyncio.run(main())
Use the MCP server with your AI agent

Connect Gmail API Tool with your Agent

Python
TypeScript

Install Composio

python
pip install composio_openai
Install the Composio SDK

Initialize Composio and Create Tool Router Session

python
from openai import OpenAI
from composio import Composio
from composio_openai import OpenAIResponsesProvider

composio = Composio(provider=OpenAIResponsesProvider())
openai = OpenAI()
session = composio.create(user_id='your-user-id')
Import and initialize Composio client, then create a Tool Router session

Execute Gmail Tools via Tool Router with Your Agent

python
tools = session.tools
response = openai.responses.create(
  model='gpt-4.1',
  tools=tools,
  input=[{
    'role': 'user',
    'content': 'Summarize unread emails from this morning'
  }]
)
result = composio.provider.handle_tool_calls(
  response=response,
  user_id='your-user-id'
)
print(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

Frequently Asked Questions

Do I need my own developer credentials to use Gmail with Composio?

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

Can I use multiple toolkits together?

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

Is Composio secure?

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

What if the API changes?

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

Used by agents from

Context
ASU
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai
Context
ASU
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai
Context
ASU
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai

Never worry about agent reliability

We handle tool reliability, observability, and security so you never have to second-guess an agent action.