How to integrate Agent mail MCP with OpenCode

Connect OpenCode to Agent mail MCP. Show me unread emails from today, send a status update to your team, and more using natural language, with authentication handled for you.

Agent mail logoAgent mail
Api Key

Agent mail provides AI agents with dedicated email inboxes for sending, receiving, and managing emails. It empowers agents to communicate autonomously with people, services, and other agents—no human intervention needed.

93 Tools1 Triggers

How to integrate Agent mail MCP with OpenCode

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

There are two ways to set this up:

Also integrate Agent mail 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,500+ 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 Agent mail 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 Agent mail

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 Agent mail Composio".
  3. Complete the authentication and authorization flow, and your Agent mail integration is all set.
  4. Start asking anything you want.

Option 2: Using Composio MCP

You can also connect Agent mail 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 Agent mail with OpenCode

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

For example, ask it to:

  • "Show me unread emails from today"
  • "Send a status update to your team"
  • "Find emails with invoice attachments"

It will prompt you to authenticate and authorize access to Agent mail.

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

Way Forward

Now that Agent mail 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 Agent mail action and event your agent gets out of the box.

Batch Get Messages

Return metadata for up to 500 messages from one inbox in a single request.

Batch Update Message Labels

Atomically add or remove the same labels on up to 50 messages in one inbox.

Complete File Upload

Mark a pending Agent Drive file ready after its bytes have been PUT to the presigned URL returned by CREATE_FILE.

Create Agent Armor Feedback

Record whether Agent Armor's completed verdict on a message was correct.

Create Calendar Event

Create a one-off or recurring event on a US-only inbox calendar.

Create Draft

Create a draft, optionally scheduling its automatic delivery with send_at.

Create File

Initialize a pending Agent Drive file and return instructions for a direct storage upload.

Create Inbox

Create a new AgentMail inbox via API.

Create Inbox API Key

Create an inbox-scoped bearer key and return its one-time secret.

Create Inbox in Pod

Create an inbox inside an explicitly selected AgentMail pod, optionally choosing its address, initial status, idempotency ID, and metadata.

Create Inbox Polling Webhook

Create or resume a polling webhook scoped to one inbox.

Create Inbox Webhook

Create a regular webhook scoped to one AgentMail inbox for a non-empty set of event types.

Create Allowlist or Blocklist Entry

Add an email address or domain to an organization-wide send, receive, or reply allowlist or blocklist.

Create Pod

Create an AgentMail pod for grouping inboxes and related resources.

Create Polling Webhook

Create or resume an organization-level polling webhook for a non-empty set of event types, optionally filtered to at most 10 inboxes and pods combined.

Create Webhook

Create an organization-level webhook for a non-empty set of event types, optionally filtered to at most 10 inboxes and pods combined.

Delete Calendar Event

Accept asynchronous deletion of a US-only calendar event or cancel recurring dates.

Delete Draft

Permanently delete one unsent draft from an inbox.

Delete File

Permanently delete a pending or ready Agent Drive file and free its path.

Delete Inbox

Permanently delete one inbox by ID.

Delete Inbox Polling Webhook

Permanently delete an inbox-scoped polling webhook by webhook_id or client_id, invalidate its polling token, and free its subscription slot.

Delete Inbox Webhook

Permanently delete a regular webhook created for a selected AgentMail inbox and stop future deliveries.

Delete Allowlist or Blocklist Entry

Remove one email address or domain from an organization-wide send, receive, or reply allowlist or blocklist.

Delete Message

Permanently delete one message from an inbox.

Delete Pod

Permanently delete one AgentMail pod by its unique ID.

Delete Pod Inbox

Permanently delete an inbox through its explicitly selected AgentMail pod, preserving the pod tenant boundary.

Delete Polling Webhook

Permanently delete an organization-level polling webhook by webhook_id or client_id, invalidate its polling token, and free its subscription slot.

Delete Thread

Permanently delete one AgentMail thread and all of its messages.

Delete Webhook

Permanently delete an organization-level webhook and stop future deliveries.

Forward Message

Immediately forward an existing message to new recipients with optional added content and attachments.

Get Agenda

Get one page of non-cancelled calendar dates in a UTC window, expanding recurring events and ordering dates by start time.

Get API Key

Retrieve API-key metadata without exposing bearer secret values.

Get Calendar

Get an inbox's US-only calendar settings, event count, and ETag.

Get Calendar Event

Get the full current form of a US-only calendar event or recurring-event date, including its opaque ETag for conditional mutations.

Get Current Identity

Return the connected AgentMail identity and its organization, pod, or inbox access boundary without exposing the credential itself.

Get Domain

Return an AgentMail custom domain, its domain and tracking verification statuses, and all required DNS records.

Get Domain Setup Link

Build a one-click Domain Connect DNS setup link when supported.

Get Domain Zone File

Download the AgentMail-generated DNS zone file for a custom domain as a bounded binary file reference.

Get Draft

Retrieve the complete contents and scheduling details of one draft.

Get Draft Attachment

Get a temporary download reference for one draft attachment.

Get File

Get Agent Drive file metadata.

Get Inbox

Retrieve one AgentMail inbox and its metadata by ID or email address.

Get Inbox Polling Webhook

Get one inbox-scoped polling webhook by webhook_id or client_id.

Get Inbox Webhook

Get one regular webhook created for a selected AgentMail inbox.

Get Inbox Webhook Headers

List only the names of custom delivery headers on an inbox-scoped regular webhook.

Get Message

Retrieve the complete details of a specific email message from an AgentMail inbox.

Get Message Attachment

Get a temporary download reference for one message attachment.

Get Organization

Return the connected AgentMail organization's identifiers, current inbox and domain counts, configured resource limits, and timestamps.

Get Pod

Retrieve one AgentMail pod by its unique ID.

Get Pod Inbox

Get an AgentMail inbox through an explicitly selected pod, preserving the pod tenant boundary.

Get Polling Webhook

Get one organization-level polling webhook by webhook_id or client_id.

Get Raw Message

Get a temporary download reference for one message's raw RFC 5322 source, including its original headers and MIME structure.

Get Thread

Retrieve one AgentMail thread and a paginated page of its messages.

Get Thread Attachment

Get a temporary download reference for an attachment using its thread and attachment IDs.

Get Webhook

Get one organization-level webhook configuration by ID.

Get Webhook Headers

List only the names of custom delivery headers on an organization-level webhook.

List Calendar Event Instances

List one page of non-cancelled dates computed for a recurring US-only calendar event in a UTC window, including dates beyond the agenda horizon.

List Calendar Events

List one US-only calendar page of stored one-off events, recurring series, and edited series dates, including cancelled events, by most recent update.

List Domains

List one page of AgentMail custom domains and return the continuation token for the next page.

List Drafts

List unsent drafts in an AgentMail inbox with filters and pagination.

List Files

List one page of an inbox's Agent Drive files in path order, including pending files.

List Inbox API Keys

List API-key metadata scoped to an inbox without exposing secret values.

List Inboxes

List all inboxes available to the authenticated AgentMail account.

List Inbox Events

List label-change events from an AgentMail inbox.

List Inbox Polling Webhooks

List polling webhooks created through one inbox route.

List Inbox Webhooks

List one page of regular webhooks created for a selected AgentMail inbox.

List Allowlist or Blocklist Entries

List one page of organization-wide send, receive, or reply allowlist or blocklist entries.

List Messages

List messages from an AgentMail inbox.

List Pod Inboxes

List one page of inboxes inside an explicitly selected AgentMail pod, or supply query to search addresses and display names.

List Pods

Return one page of AgentMail pods and its continuation token.

List Polling Webhooks

List organization-level polling webhooks created through the organization route.

List Threads

List conversation threads in an AgentMail inbox with filters.

List Webhooks

List AgentMail webhook configurations.

Query Inbox Event Metrics

Query timestamped email-event counts for an AgentMail inbox.

Query Metrics

Query organization-wide email event counts or cumulative resource-usage time series over a bounded time range.

Query Rate Metrics

Query organization-wide rolling bounce and complaint rates.

Release Held Message

Release a message that Agent Armor held for review, emit its delivery and security override events, and remove the agent-armor-held label.

Reply To Message

Reply to a selected message while preserving its AgentMail thread.

Respond to Calendar Event

Accept, decline, or tentatively accept an email invitation on a US-only inbox calendar.

Send Draft

Immediately send and consume a draft, optionally changing message labels.

Send Email

Send an email using AgentMail API

Send Message

Immediately send a new email from an AgentMail inbox with optional HTML, attachments, custom headers, labels, and open tracking.

Update Calendar

Change an inbox calendar's default time zone in US production.

Update Calendar Event

Patch a US-only calendar event, one recurring date, or that date and future dates.

Update Draft

Edit a draft, reschedule delivery, or cancel a scheduled send with null.

Update Inbox

Update an inbox's display name, status, or custom metadata.

Update Inbox Webhook

Update an inbox-scoped regular webhook's enabled state or replace its event types.

Update Inbox Webhook Headers

Atomically set, replace, or remove custom delivery headers on an inbox-scoped regular webhook.

Update Message Labels

Add or remove labels from one message in an inbox.

Update Pod Inbox

Update the display name, active or paused status, or metadata of an inbox inside an explicitly selected AgentMail pod.

Update Thread Labels

Add or remove custom labels from every message in one thread.

Update Webhook

Update an organization-level webhook's enabled state, event types, or inbox and pod subscriptions.

Update Webhook Headers

Atomically set, replace, or remove custom delivery headers on an organization-level webhook.

FAQ

Frequently asked questions

With a standalone Agent mail MCP server, the agents and LLMs can only access a fixed set of Agent mail tools tied to that server. However, with the Composio Tool Router, agents can dynamically load tools from Agent mail 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 Agent mail tools.

Yes, absolutely. You can configure which Agent mail 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 Agent mail data and credentials are handled as safely as possible.

Start with Agent mail.It takes 30 seconds.

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

Start building