Emailgents MCP server
One remote MCP server over streamable HTTP with OAuth. 28 tools for mail, calendars, contacts and shared context, with per-mailbox action permissions, bounded bulk operations and explicit confirmation status.
https://emailgents.com/mcp- Streamable HTTP; no local process.
- OAuth 2.1 with PKCE; the client opens a browser sign-in once.
- Discovery at /.well-known/oauth-protected-resource.
Connecting a client
Pick the client for exact settings and config snippets.
Tools
Mail writes share one bounded service. Preview bulk scope, continue remaining IDs before cursors, and reconcile uncertain outcomes. Plain-text sending requires native Google/Microsoft OAuth and Send permission; Trash is recoverable. Calendar RSVP retains its separate provider-dependent route.
inbox_overview
Every mailbox with unread counts, newest mail and coverage. The right first call.
- fresh
- boolean, default true. Bounded refresh of mailboxes not synced in the last 45 s; false answers straight from the index.
Returns: Per-account unread totals (marked partial when the index is), newest messages, conversations waiting on the owner's reply (needsReply, up to 10, with the total), freshness and refresh outcome.
search_messages
Ranked full-text search across every mailbox and folder at once (junk and trash excluded unless asked), or a newest-first listing.
- query
- string ≤ 500. Words are prefix-matched and accent-insensitive; "exact phrases", -excluded, a OR b; operators from:, to:, subject:, has:attachment, filename:, is:unread, is:starred, is:important, is:needs-reply, is:replied, in:inbox|sent|archive|junk|trash|anywhere, after:/before: (YYYY-MM-DD), newer_than:7d|2w|3m|1y, label:, category:, account:. Omit to list newest first.
- scope
- index (default): answers from the index in milliseconds. everywhere: also asks each mailbox directly for matches of any age (bounded, ~12 s), indexes what was missing and answers from the wider index.
- account_ids
- uuid[] ≤ 50. Default all.
- folder
- inbox | sent | drafts | archive | trash | junk | all | starred | important | other
- folder_id
- uuid from list_folders.
- provider_label
- Exact provider label/category name, separate from AI label: search. Restrict account_ids for mailbox-local meaning.
- from, to
- substring match on sender or To/Cc.
- after, before
- ISO-8601 date or datetime; a date in before means end of that day.
- unread_only, starred_only, has_attachments, calendar
- boolean filters.
- reply
- needs_reply: conversations whose newest message waits on the owner's answer; replied: conversations the owner answered last. One row per conversation, each with reply { state, since, source: you | sent | answered_flag | ai }.
- include_facets
- boolean. Counts per mailbox, folder, year and top sender (first page only).
- fuzzy
- boolean, default true. When nothing matches exactly, close spellings are returned and query.fuzzy is true.
- limit
- 1–100, default 25.
- cursor
- opaque nextCursor from the previous page, bound to the first page's snapshot and query: no duplicates or skips while new mail arrives.
- order
- relevance (default with a query) or date.
- fresh
- boolean, default true (scope=index only).
Returns: total, hasMore, nextCursor, snapshotAt, query (parsed filters, warnings, fuzzy, highlight words), coverage (complete for the query when every mailbox answered a live search), live (per-mailbox outcome), facets, and messages with matchedIn, score and cleaned snippets.
get_message
Headers, body and attachment metadata for one message.
- message_id
- uuid from search_messages or get_thread.
- format
- text (default) | html | both.
- max_chars
- 500–400000, default 60000.
- body_offset
- continue a truncated body from bodyInfo.nextOffset.
- mark_read
- boolean, default false.
Returns: message, body, bodyInfo (source: cached | fetched | truncated | unavailable, nextOffset), attachments with size, downloadable flag and an authenticated downloadUrl, and a webUrl into Emailgents.
get_thread
The whole conversation, oldest first, with coverage so a partial thread is never mistaken for a complete one.
- message_id
- any message id in the thread.
- include_bodies
- boolean, default false.
- max_chars_per_message
- 500–100000, default 12000.
Returns: threadId, messages, per-message bodyInfo (not_requested | cached | fetched | truncated | unavailable), coverage, and the conversation's reply status (needs_reply | replied | null).
get_attachment
One attachment inline, up to 4 MB.
- message_id
- uuid.
- attachment_id
- from get_message.
Returns: Text for text-like files, base64 resource otherwise. Larger files fail with too_large; use downloadUrl (up to 25 MB, authenticated).
set_flags
Set desired read and starred values on up to 500 unique messages, with the mailbox's flags permission.
- message_ids OR anchor_message_ids OR filter
- At most 500 unique message IDs; conversation anchors expand complete membership in the captured view. A filter uses query, account_ids, folder_id/folder_roles, provider_label, from/to, before/after, unread, starred, calendar, has_attachments, ai_category/ai_label, important, reply and inbox_group/inbox_sorting. Empty account_ids grants no access.
- max, dry_run, cursor
- max 1–500, filter default 200. dry_run previews without writes. Finish remainingMessageIds before continuing selection.nextCursor with the same action and captured scope.
- read
- boolean.
- starred
- boolean.
Returns: Per-message operationStatus, providerState, indexState and retry guidance; separate applied, accepted, uncertain, failed and not-attempted counts, remaining IDs and snapshot continuation. Accepted is not confirmed; reconcile uncertainty before repeating a write.
list_accounts
Connected mailboxes, agent permissions and shared context availability. Call first.
- detail
- true adds effective transport, consent, mail capabilities and full coverage; default false is compact.
Returns: accounts[] with id, email, provider, status, lastSyncedAt, counts, permissions, context discovery and coverage.
list_folders
Folders and labels per account with counts and per-folder sync state.
- account_id
- uuid, optional.
Returns: folders[] with role, counts, syncEnabled, lastSyncedAt and whether the initial pass is complete.
sync_account
Force a bounded sync of one mailbox now.
- account_id
- uuid.
Returns: added, updated, removed, duration and whether work remains.
list_calendars
Every calendar per mailbox: synced provider calendars (iCloud, Google, Outlook, CalDAV) plus the 'From email' calendar, with sync status and effective capabilities.
No parameters.
Returns: accounts[] with status, lastSyncedAt, capabilities (sync, respond, create, edit, delete, via) and setup; calendars[] with id, name, colour, readOnly, visible, eventCount.
list_events
A time range from the unified calendar: provider events merged with invitations and bookings found in mail, repeating events expanded, one entry per event per account.
- from, to
- ISO-8601; default now → +30 days, at most 120 days.
- account_ids, calendar_ids
- uuid[] filters.
- query
- match on title or location.
- include_cancelled, include_hidden
- booleans, default false.
- time_zone
- IANA zone for local times in the text output.
- limit
- 1–500, default 100.
Returns: events[] with instance_id, times, zone, myStatus, organizer, attendeeCount, conference, conflictsWith, alsoIn and webUrl; coverage for mailboxes without a synced calendar; hasMore and clipped.
get_event
One event or occurrence in full: attendees and answers, join link / id / passcode, notes, reminders, repeat rule and changed occurrences, the mail that created or updated it, actions taken, and what you can do with it.
- instance_id
- from list_events; an occurrence is <event_id>@<occurrence>.
- time_zone
- IANA zone for the text output.
Returns: The event with can (respond, edit, delete, addToProvider), responseRoute (how an answer would reach the organizer: label, ordered steps, fallbacks, nextStep) with responseVia (caldav | google | graph | imip | local), providerState (synced | mail_only | local_only), history[] with message ids, actions[] and webUrl.
find_free_time
Open slots of a given length inside working hours across all connected calendars.
- from, to
- ISO-8601 window.
- duration_minutes
- 5–1440.
- time_zone
- IANA zone for the working hours.
- working_hours
- { start, end, days[] } default 09:00–18:00 Mon–Fri.
- account_ids, max_slots
- optional.
Returns: slots[] with start, end and length, the busy blocks considered, and a note when a mailbox has no synced calendar.
respond_to_event
Accept, tentatively accept or decline. Attempts the first supported response route: the synced calendar copy, the copy the calendar service filed on arrival, an import into the calendar, or a standard calendar reply email from the mailbox. Otherwise noted in Emailgents only, and the result says so with a next step.
- instance_id
- from list_events.
- answer
- accepted | tentative | declined.
- scope
- this | series for repeating events.
- comment
- ≤ 500 characters when the provider supports it.
Returns: status sent | local, via, mode (provider | lookup | import | imip | local), notified, attempts[], nextStep, myStatus and a plain-language note.
create_event
Create an event in a writable provider calendar. Attendees are invited by the provider, not by Emailgents.
- calendar_id
- writable id from list_calendars.
- title, start, end, time_zone
- wall-clock times in time_zone, or dates for all-day.
- all_day, location, description, attendees[], reminder_minutes, rrule, conference_url, transparent
- optional.
Returns: The stored event as get_event returns it.
archive_messages
Archive Inbox mail and mark it read; requires archive permission.
- message_ids OR anchor_message_ids OR filter
- At most 500 unique message IDs; conversation anchors expand complete membership in the captured view. A filter uses query, account_ids, folder_id/folder_roles, provider_label, from/to, before/after, unread, starred, calendar, has_attachments, ai_category/ai_label, important, reply and inbox_group/inbox_sorting. Empty account_ids grants no access.
- max, dry_run, cursor
- max 1–500, filter default 200. dry_run previews without writes. Finish remainingMessageIds before continuing selection.nextCursor with the same action and captured scope.
Returns: Per-message operationStatus, providerState, indexState and retry guidance; separate applied, accepted, uncertain, failed and not-attempted counts, remaining IDs and snapshot continuation. Accepted is not confirmed; reconcile uncertainty before repeating a write.
restore_messages
Restore Archive mail to Inbox, preserving flags; requires archive permission.
- message_ids OR anchor_message_ids OR filter
- At most 500 unique message IDs; conversation anchors expand complete membership in the captured view. A filter uses query, account_ids, folder_id/folder_roles, provider_label, from/to, before/after, unread, starred, calendar, has_attachments, ai_category/ai_label, important, reply and inbox_group/inbox_sorting. Empty account_ids grants no access.
- max, dry_run, cursor
- max 1–500, filter default 200. dry_run previews without writes. Finish remainingMessageIds before continuing selection.nextCursor with the same action and captured scope.
Returns: Per-message operationStatus, providerState, indexState and retry guidance; separate applied, accepted, uncertain, failed and not-attempted counts, remaining IDs and snapshot continuation. Accepted is not confirmed; reconcile uncertainty before repeating a write.
trash_messages
Move mail to recoverable Trash; requires trash permission. Permanent removal remains opt-in housekeeping.
- message_ids OR anchor_message_ids OR filter
- At most 500 unique message IDs; conversation anchors expand complete membership in the captured view. A filter uses query, account_ids, folder_id/folder_roles, provider_label, from/to, before/after, unread, starred, calendar, has_attachments, ai_category/ai_label, important, reply and inbox_group/inbox_sorting. Empty account_ids grants no access.
- max, dry_run, cursor
- max 1–500, filter default 200. dry_run previews without writes. Finish remainingMessageIds before continuing selection.nextCursor with the same action and captured scope.
Returns: Per-message operationStatus, providerState, indexState and retry guidance; separate applied, accepted, uncertain, failed and not-attempted counts, remaining IDs and snapshot continuation. Accepted is not confirmed; reconcile uncertainty before repeating a write.
untrash_messages
Undo confirmed restorable moves using their original folder, preserving later flags and labels.
- receipt_ids
- 1–500 authorized move receipt UUIDs. Requires the original action's permission and unchanged current folder identity.
Returns: Per-message operationStatus, providerState, indexState and retry guidance; separate applied, accepted, uncertain, failed and not-attempted counts, remaining IDs and snapshot continuation. Accepted is not confirmed; reconcile uncertainty before repeating a write.
list_labels
Provider labels/categories/keywords, separate from AI labels.
- account_id, folder_id
- Mailbox UUID; IMAP also requires folder UUID. IMAP keyword catalogues are incomplete; Gmail over IMAP label editing is unsupported.
Returns: Account-local label references and names, writable flags and catalogue completeness.
set_labels
Add/remove existing provider references within one account; requires labels permission. Does not create labels or edit AI/system labels.
- message_ids OR anchor_message_ids OR filter
- At most 500 unique message IDs; conversation anchors expand complete membership in the captured view. A filter uses query, account_ids, folder_id/folder_roles, provider_label, from/to, before/after, unread, starred, calendar, has_attachments, ai_category/ai_label, important, reply and inbox_group/inbox_sorting. Empty account_ids grants no access.
- max, dry_run, cursor
- max 1–500, filter default 200. dry_run previews without writes. Finish remainingMessageIds before continuing selection.nextCursor with the same action and captured scope.
- account_id, add, remove
- Mailbox UUID and arrays of writable references from list_labels.
Returns: Per-message operationStatus, providerState, indexState and retry guidance; separate applied, accepted, uncertain, failed and not-attempted counts, remaining IDs and snapshot continuation. Accepted is not confirmed; reconcile uncertainty before repeating a write.
send_message
Submit plain-text mail through native Google/Microsoft OAuth with Send permission. App-password and legacy sending are unsupported.
- request_id, account_id, text
- UUID for one immutable submission, native Google/Microsoft mailbox UUID and plain text ≤ 200 KiB UTF-8.
- to, cc, bcc, subject
- Address arrays, at most 50 recipients combined; subject ≤ 998 characters. Compose requires recipients; reply can derive recipients/subject server-side.
- retry_refused
- Explicit unchanged-payload retry of a proven retryable refusal after its delay. Accepted/uncertain submissions never resend.
Returns: Submission identity, status, provider/index evidence, retry timing and nextStep. Provider acceptance is not delivery.
reply_message
Reply or reply-all through native Google/Microsoft OAuth with Send permission. Derives Reply-To/From and visible To/Cc, removing self addresses; never infers received Bcc.
- request_id, account_id, text
- UUID for one immutable submission, native Google/Microsoft mailbox UUID and plain text ≤ 200 KiB UTF-8.
- to, cc, bcc, subject
- Address arrays, at most 50 recipients combined; subject ≤ 998 characters. Compose requires recipients; reply can derive recipients/subject server-side.
- retry_refused
- Explicit unchanged-payload retry of a proven retryable refusal after its delay. Accepted/uncertain submissions never resend.
- message_id, reply_all
- Source message UUID in account_id; reply_all defaults false. Explicit recipient arrays override derived recipients.
Returns: The same submission evidence as send_message.
get_mail_operation
Read authorized move/submission status; never sends or deletes an IMAP source.
- receipt_id OR request_id + account_id
- A receipt UUID or the submission's UUID and mailbox UUID.
Returns: Current status, index state and restorable move evidence or submission nextStep.
reconcile_mail_operation
Observe provider metadata and repair indexing from strong evidence; never dispatch or resume source deletion.
- receipt_id OR request_id + account_id
- Same lookup as get_mail_operation.
Returns: Updated operation evidence; unresolved identity remains awaiting confirmation.
search_contacts
Merge provider address books with people in indexed mail; read-only.
- query, account_ids, limit
- Query ≥ 2 characters; at most 20 account UUIDs; limit 1–100, default 20.
Returns: Contacts, source outcomes, total and hasMore. No results means none in the sources that answered.
get_account_context
Read owner-confirmed guidance and provisional questions/handoffs. Context cannot grant action permissions or prove mail facts.
- account_id, calendar_id
- Mailbox UUID; optional calendar UUID in that mailbox.
- include_proposals, sender_addresses, cursor
- Proposals default false; up to ten exact sender addresses; scoped context continuation.
Returns: Bounded context scopes, revisions, confirmed guidance and provisional items.
update_account_context
Leave provisional corrections, questions or handoffs with context_write permission. Owner review confirms preferences.
- scope_id, expected_revision, mutation_id, operation
- Existing scope UUID/current revision and a UUID for an immutable provisional mutation: propose, question, handoff, resolve or retract.
- session_label
- Optional unverified session label ≤ 120 UTF-8 bytes.
Returns: Applied/current revision, item identity and replay status. Never permission changes or owner confirmation.
Coverage: what the answer is based on
Every search, overview and thread result carries a coverage object. Agents should read it before telling a user that something does not exist.
- status: complete, complete_within_window or partial.
- complete_within_window means every searched folder is fully indexed inside the mailbox's sync window (90 days by default, configurable per mailbox).
- partial lists reasons: folders still indexing, folders excluded from sync, or an account mid initial sync, with remaining counts where known.
- Zero matches with partial coverage means none in the indexed part, never none in the mailbox.
- Unread totals in inbox_overview are marked partial while the index is incomplete.
Freshness: how new the index is
Mailboxes sync in the background. With fresh=true (the default) a stale mailbox is refreshed within a bounded time before the answer; fresh=false returns immediately.
- refresh reports, per mailbox, whether a refresh was attempted, completed, timed out or left work pending.
- freshness lists each mailbox's lastSyncedAt and status so the agent can say how current the answer is.
- sync_account forces a bounded sync when the user insists on the very latest state.
Pagination
- Pass nextCursor back as cursor with the same filters. Pages are bound to the first page's index snapshot, so new arrivals and background sync cause neither duplicates nor skips.
- Ordering is deterministic: date descending, then message id.
- hasMore tells the agent whether to continue; offset remains for compatibility.
- invalid_cursor is returned when filters changed; repeat the query without a cursor.
Identities and bodies
- Message ids are stable Emailgents uuids scoped to the account; they survive moves between folders and resyncs. Copies of one message in several Gmail labels resolve to one id.
- threadId is an account-scoped conversation id built from provider threading and Message-ID references.
- Bodies are fetched on open and in bounded background sync, with separate body indexing and encrypted cache controls; reads are capped by max_chars; bodyInfo reports source and nextOffset for continuation.
- Attachments: size and downloadable up front; 4 MB inline through get_attachment, 25 MB through the authenticated downloadUrl.
Errors
Failures return isError with a structured error: code, retryable, retry_after, target, next_step and a correlation_id that matches the server log. No credentials or raw provider payloads ever appear in messages.
| code | retryable | next step |
|---|---|---|
| unauthenticated | no | Reconnect this MCP server with the user's Emailgents account. |
| not_found | no | Check the id; get fresh ids from list_accounts or search_messages. |
| forbidden | no | Use an account this connection is allowed to read. |
| permission_missing | no | Ask the owner to enable this specific action for the mailbox. |
| invalid_input | no | Fix the listed argument and call again. |
| invalid_cursor | no | Repeat the original query without a cursor. |
| reauth_required | no | Ask the user to reconnect this mailbox in Emailgents. |
| provider_error | reads only | For writes follow per-message retry evidence; never replay an unknown dispatch. |
| provider_timeout | reads only | Read indexed data with fresh=false; check operation status for interrupted writes. |
| uncertain | no | Check/reconcile the operation. Missing confirmation never authorizes another send or copy. |
| index_pending | no | Provider evidence exists; refresh/reconcile indexing without repeating the write. |
| rate_limited | explicit delay | Follow retry_after and per-item retry guidance; only proven refused sends may retry. |
| receipt_conflict | no | Read current receipt/message identity before requesting another action. |
| too_large | no | Use downloadUrl or ask the user to open the item. |
| unsupported | no | This transport or mailbox cannot perform the action; read its capability reason. |
| conflict | no | Reload the event with get_event and apply the change to the current version. |
| server_unavailable | evidence-dependent | Retry reads or explicitly not-attempted IDs; check status for interrupted submissions. |
| internal | evidence-dependent | Report correlation_id; check status before repeating any write. |
Provider capabilities
list_accounts reports the effective capabilities of each mailbox so agents do not plan on features a provider lacks.
| Provider | Transport | Threads | Flags written back | Change detection |
|---|---|---|---|---|
| Gmail (OAuth) | Gmail API | Gmail conversations | read, starred | history id |
| Outlook / Microsoft 365 | Microsoft Graph | conversationId | read, flagged | delta queries |
| iCloud, Yahoo, Fastmail, AOL, Zoho, GMX, IMAP | IMAP over TLS | References / In-Reply-To | \Seen, \Flagged | UIDs, CONDSTORE where offered |
Reference questions
Does get_message mark mail as read?
Not unless the agent passes mark_read=true. The default leaves read state untouched.
How does an agent open a message for the user?
get_message returns a webUrl that opens the message in the Emailgents app after the user signs in. There are no public share links.
What is the rate limit?
Searches answer from the index and are cheap. Provider fetches (bodies, attachments, fresh refreshes) are bounded per call and per mailbox; a provider_timeout tells the agent to retry or use fresh=false.
Is there a REST equivalent?
Yes. Every tool has an HTTP route under /api/public/v1 with the same shapes, authenticated with a scoped API key.
Looking for HTTP? REST API reference.