Gmail MCP
v1.1.2MCP server for the Gmail API: search, read and send email, manage drafts, labels and the trash.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
auth_status Google connection status
Shows whether this server is connected to Google: token presence and source (env variables or a stored in-chat login), expiry, the Google account email, granted vs missing OAuth scopes, where the credentials file lives and where the OAuth client comes from. Makes no network calls and never returns the token itself. Call it first when other tools report the server is not connected.
setup_instructions Setup instructions
Step-by-step checklist for connecting this server to Google: creating a Google Cloud project and a Desktop-app OAuth client, publishing the consent screen (mandatory — Testing-mode refresh tokens die after 7 days), downloading the client JSON and handing its PATH to set_client. Works without any credentials; with your own client already configured it shortens to 'enable the API + log in' (one client serves the whole mcp-google-* line). Never asks the user to paste secrets into the chat.
set_client Save the OAuth client
Saves the OAuth client credentials from the JSON file downloaded from Google Cloud Console ('Download JSON' on a Desktop-app client). Pass the file PATH — the secret must never be pasted into the chat. The client is stored once in the shared ~/.config/mcp-google-auth/client.json (owner-only) and reused by every mcp-google-* server; tokens stay per-server. After this, call start_login.
| Parameter | Type | Description |
|---|---|---|
path * | string | Absolute path to the client_secret_*.json file downloaded from Google Cloud Console. |
start_login Start the Google login
First step of connecting from the chat, without editing config files or restarting the client. Returns authorizeUrl — show it to the user as a clickable link and ask them to open it in the browser ON THIS MACHINE, pick the Google account and approve access. A one-shot listener on 127.0.0.1 catches Google's redirect; the code is exchanged locally and never passes through the chat. Does not open the browser itself. The attempt lives 10 minutes; when the browser shows the success page, call finish_login.
finish_login Finish the Google login
Second step: waits up to 20 s for the browser consent to finish, saves the tokens to an owner-only file and verifies the login with a read-only identity call, returning the account email and the granted scopes. After success every tool works immediately — no client restart. If the user granted only part of the requested permissions, the login is still saved and missingScopes lists what will not work. Logging in under a different Google account replaces the previous login (its refresh token is revoked best-effort) and the response carries previousAccountEmail so the change never goes unnotice…
logout Disconnect from Google
Revokes the stored token at Google (oauth2.googleapis.com/revoke) and deletes the local credentials file. Tokens supplied via env variables are NOT touched — remove them from the MCP client config manually; envTokenStillSet in the response says whether any are still in effect.
list_messages Search and list messages
Searches the mailbox with Gmail query syntax and returns one summary per message: id, threadId, labelIds, snippet, from, to, subject, date, internalDate. Filter with query (same operators as the Gmail search box: from:, to:, subject:, is:unread, is:starred, has:attachment, label:, newer_than:7d, before:/after:) and/or label_ids (all must match). Spam and trash are excluded unless include_spam_trash=true. Paginate with page_token from nextPageToken; page_size defaults to 25 (max 100 — each summary costs one metadata read, throttled to a few at a time). A message deleted between the search and…
| Parameter | Type | Description |
|---|---|---|
include_metadata | boolean | false = bare ids only, no per-message metadata reads (default true). |
include_spam_trash | boolean | Also search SPAM and TRASH (default false). |
label_ids | array | Only messages carrying ALL of these label ids (see list_labels). |
page_size | integer | Messages per page (1..100, default 25). |
page_token | string | nextPageToken from the previous page. |
query | string | Gmail query syntax, e.g. "from:amy@example.com is:unread newer_than:7d has:attachment subject:invoice". Same operators as the Gmail search box. |
get_message Read a message
Fetches one message fully decoded: headers (from, to, cc, subject, date, messageId, inReplyTo, references — RFC 2047 words decoded), the plain-text body (base64/charset decoded), the HTML body when there is no text part or include_html=true, and attachment METADATA (filename, mimeType, sizeBytes, attachmentId — never the content; download bytes via raw_request users/me/messages/<id>/attachments/<attachmentId> if truly needed). Bodies are truncated at max_body_chars (default 50000) with textTruncated/htmlTruncated flags. metadata_only=true skips bodies entirely. To reply later, keep headers…
| Parameter | Type | Description |
|---|---|---|
message_id * | string | The message id from list_messages/get_thread output (not the RFC Message-ID header). |
include_html | boolean | Return the decoded HTML body even when a text body exists (default false). |
max_body_chars | integer | Truncate each decoded body at this many characters (default 50000; a truncation flag is set when cut). |
metadata_only | boolean | Headers and structure only, no body content. |
send_message Send an email
Sends an email from the authenticated mailbox, immediately and irreversibly. Requires at least one recipient across to/cc/bcc (a bcc-only send is fine — to may be omitted) and at least a subject or a body; body_text and body_html together become multipart/alternative. TO REPLY IN A THREAD: call get_message on the message being answered first, then pass its threadId as thread_id, its headers.messageId as in_reply_to, and the same subject prefixed with "Re: " — Gmail threads the reply only when all three line up. Returns the sent message's id, threadId and labelIds. NEVER retried after a tim…
| Parameter | Type | Description |
|---|---|---|
bcc | array | Blind-copy recipients. |
body_html | string | HTML body (sent as multipart/alternative when body_text is also set). |
body_text | string | Plain-text body. |
cc | array | Carbon-copy recipients. |
in_reply_to | string | RFC Message-ID of the message being replied to (headers.messageId from get_message). |
references | string | Explicit References header chain (defaults to in_reply_to). |
subject | string | The subject line. For replies use the original subject with "Re: ". |
thread_id | string | Reply into this thread (pair with in_reply_to and a matching subject). |
to | array | Primary recipients. Optional when cc or bcc carries at least one recipient (bcc-only send). |
modify_message Change message labels / state
Changes a message's state via Gmail labels: read=true/false marks read/unread, starred=true/false stars/unstars, archived=true removes it from the inbox (archived=false moves it back), and add_label_ids/remove_label_ids apply or strip any labels from list_labels (e.g. a user label, or IMPORTANT). At least one change is required; applying the same change twice is harmless. This never deletes anything — use manage_trash for the trash. Returns the message's new id/labelIds.
| Parameter | Type | Description |
|---|---|---|
message_id * | string | The message id from list_messages/get_thread output (not the RFC Message-ID header). |
add_label_ids | array | Label ids to add. |
archived | boolean | true = archive (remove from inbox), false = move back to inbox. |
read | boolean | true = mark read, false = mark unread. |
remove_label_ids | array | Label ids to remove. |
starred | boolean | true = star, false = unstar. |
manage_trash Trash or restore mail
Moves a message or a whole thread to the Gmail trash, or restores it. action=trash is REVERSIBLE: Gmail keeps trashed mail for about 30 days, then deletes it permanently; action=untrash restores it before that happens. target=message (default) uses a message id, target=thread trashes/restores every message in the thread. This server intentionally has no permanent-delete tool — the trash is the safety net. Note: untrash does not re-add INBOX; follow up with modify_message archived=false if it should reappear in the inbox.
| Parameter | Type | Description |
|---|---|---|
action * | string | trash = move to trash (reversible), untrash = restore. |
id * | string | The message id (target=message) or thread id (target=thread). |
target | string | What the id refers to (default message). |
list_threads Search and list threads
Searches conversations (threads) with the same Gmail query syntax as list_messages and returns id, snippet (of the latest message) and historyId per thread. Use this instead of list_messages when the unit of work is a conversation — triaging an inbox, finding a discussion to reply into. Filter with query and/or label_ids; paginate with page_token from nextPageToken (page_size max 500). Read the full conversation with get_thread.
| Parameter | Type | Description |
|---|---|---|
include_spam_trash | boolean | Also search SPAM and TRASH (default false). |
label_ids | array | Only threads carrying ALL of these label ids (see list_labels). |
page_size | integer | Threads per page (1..500, API default 100). |
page_token | string | nextPageToken from the previous page. |
query | string | Gmail query syntax, e.g. "from:amy@example.com is:unread newer_than:7d has:attachment subject:invoice". Same operators as the Gmail search box. |
get_thread Read a whole conversation
Fetches a conversation with every message decoded like get_message: headers, text bodies (HTML only when a message has no text part or include_html=true), attachment metadata and truncation flags. Messages come oldest-first. To reply to the conversation, take the LAST message's threadId, headers.messageId and subject and pass them to send_message (thread_id, in_reply_to, subject with "Re: "). Long threads can be large — lower max_body_chars (it applies per message) when only the gist is needed.
| Parameter | Type | Description |
|---|---|---|
thread_id * | string | The thread id from list_threads or from a message's threadId field. |
include_html | boolean | Return decoded HTML bodies even when a text body exists (default false). |
max_body_chars | integer | Truncate each decoded body at this many characters (default 50000; a truncation flag is set when cut). |
modify_thread Change thread labels / state
Applies the same normalized state changes as modify_message — read/unread, starred, archived, add_label_ids/remove_label_ids — to EVERY message in a conversation at once. Use it to mark a whole conversation read or archive it in one call instead of looping over messages. At least one change is required; repeating the same change is harmless. Returns the thread's new id and message label state.
| Parameter | Type | Description |
|---|---|---|
thread_id * | string | The thread id from list_threads or from a message's threadId field. |
add_label_ids | array | Label ids to add to every message. |
archived | boolean | true = archive (remove from inbox), false = move back to inbox. |
read | boolean | true = mark the whole thread read, false = unread. |
remove_label_ids | array | Label ids to remove from every message. |
starred | boolean | true = star, false = unstar. |
create_draft Create a draft
Creates a draft email in the mailbox without sending anything. All fields are optional — an empty draft is legal — but a useful one carries to[], subject and a body. For a reply draft set thread_id, in_reply_to (headers.messageId of the message being answered, via get_message) and the original subject with "Re: ". Returns the draft id (needed by update_draft/send_draft/delete_draft) and the underlying message id/threadId. Drafting first and sending with send_draft after a human look is the safe path for consequential mail — prefer it over send_message when in doubt.
| Parameter | Type | Description |
|---|---|---|
bcc | array | Blind-copy recipients. |
body_html | string | HTML body (multipart/alternative when body_text is also set). |
body_text | string | Plain-text body. |
cc | array | Carbon-copy recipients. |
in_reply_to | string | RFC Message-ID of the message being replied to (headers.messageId from get_message). |
references | string | Explicit References header chain (defaults to in_reply_to). |
subject | string | The subject line. |
thread_id | string | Make it a reply draft in this thread (pair with in_reply_to and a matching subject). |
to | array | Primary recipients (optional for a draft). |
list_drafts List drafts
Lists the mailbox's drafts: draft id plus the underlying message's id and threadId (no subjects — read one with get_draft). query filters with Gmail query syntax (e.g. subject:invoice); paginate with page_token from nextPageToken.
| Parameter | Type | Description |
|---|---|---|
page_size | integer | Drafts per page (1..500, API default 100). |
page_token | string | nextPageToken from the previous page. |
query | string | Gmail query syntax, e.g. "from:amy@example.com is:unread newer_than:7d has:attachment subject:invoice". Same operators as the Gmail search box. |
get_draft Read a draft
Fetches one draft with its message decoded like get_message: headers (to, cc, subject, ...), text body, HTML only on request, attachment metadata. Use it to show the user what send_draft would send, or to read the current content before update_draft (updates REPLACE the whole draft).
| Parameter | Type | Description |
|---|---|---|
draft_id * | string | The draft id from list_drafts or create_draft output. |
include_html | boolean | Return the decoded HTML body even when a text body exists (default false). |
max_body_chars | integer | Truncate each decoded body at this many characters (default 50000; a truncation flag is set when cut). |
update_draft Update a draft
REPLACES a draft's entire message — the Gmail API has no partial draft edit, so omitted fields are dropped, not kept. Read the current content with get_draft first, then pass the complete new state (recipients, subject, body, and thread_id/in_reply_to for reply drafts). The draft id stays the same; the underlying message id changes. Returns the updated draft.
| Parameter | Type | Description |
|---|---|---|
draft_id * | string | The draft id from list_drafts or create_draft output. |
bcc | array | Blind-copy recipients. |
body_html | string | HTML body (multipart/alternative when body_text is also set). |
body_text | string | Plain-text body. |
cc | array | Carbon-copy recipients. |
in_reply_to | string | RFC Message-ID of the message being replied to (headers.messageId from get_message). |
references | string | Explicit References header chain (defaults to in_reply_to). |
subject | string | The subject line. |
thread_id | string | Make it a reply draft in this thread (pair with in_reply_to and a matching subject). |
to | array | Primary recipients (optional for a draft). |
send_draft Send a draft
Sends an existing draft exactly as it is stored, immediately and irreversibly; the draft disappears from the drafts list and becomes a sent message (returned id/threadId). Verify the content with get_draft before calling this. NEVER retried after a timeout or 5xx (a duplicate email cannot be unsent): if the outcome is unclear, check list_drafts (the draft is gone if it was sent) or list_messages in:sent before considering anything else. Daily sending limits apply (~500/day consumer, ~2000/day Workspace).
| Parameter | Type | Description |
|---|---|---|
draft_id * | string | The draft id from list_drafts or create_draft output. |
delete_draft Delete a draft
PERMANENTLY deletes a draft — drafts skip the trash, so there is no undo and no manage_trash recovery. Confirm with get_draft before deleting anything the user might still want. Returns empty on success.
| Parameter | Type | Description |
|---|---|---|
draft_id * | string | The draft id from list_drafts or create_draft output. |
list_labels List labels
Without label_id: lists every label in the mailbox — system labels (INBOX, SENT, DRAFT, SPAM, TRASH, UNREAD, STARRED, IMPORTANT, CATEGORY_*) and user labels with their ids — the vocabulary that list_messages label_ids and modify_message add/remove_label_ids speak. With label_id: fetches that one label including its counts (messagesTotal, messagesUnread, threadsTotal, threadsUnread), which the plain list does not carry.
| Parameter | Type | Description |
|---|---|---|
label_id | string | Fetch one label with counts instead of listing all. |
manage_labels Create, rename or delete a label
Manages user labels. action=create needs name (nest with "/", e.g. "Clients/Acme" — the parent must already exist). action=update needs label_id plus at least one of name, label_list_visibility (show | show_if_unread | hide — the label in the sidebar) or message_list_visibility (show | hide — its messages in the list); only the provided fields change. action=delete needs label_id and removes the label from EVERY message it was applied to — the messages survive, the label and its message-associations do not; this cannot be undone. System labels (INBOX, STARRED, ...) cannot be created, r…
| Parameter | Type | Description |
|---|---|---|
action * | string | What to do with the label. |
label_id | string | update/delete: the user label to target. |
label_list_visibility | string | Sidebar visibility of the label itself. |
message_list_visibility | string | Whether the label's messages show in the message list. |
name | string | create (required) / update: the label name, e.g. "Invoices" or nested "Clients/Acme". |
get_profile Get the mailbox profile
Returns the authenticated mailbox's profile: emailAddress (the user's own address — useful for send-to-self checks and for recognizing the user's messages in threads), messagesTotal, threadsTotal and historyId. The cheapest way to verify that the OAuth credentials work.
raw_request Raw Gmail API call
Escape hatch to call any Gmail API v1 path directly, for requests the typed tools don't cover — e.g. downloading attachment content ("gmail/v1/users/me/messages/<messageId>/attachments/<attachmentId>", returns base64url data), history.list for incremental sync ("gmail/v1/users/me/history?startHistoryId=..."), batchModify, or settings endpoints (filters, forwarding, vacation). The path may carry a query string. The Bearer token is added automatically; the method defaults to GET. CAUTION: this bypasses the typed tools' guard rails — users/me/messages/<id> DELETE is a PERMANENT delete that sk…
| Parameter | Type | Description |
|---|---|---|
path * | string | API path relative to https://gmail.googleapis.com, e.g. "gmail/v1/users/me/history?startHistoryId=123". |
body | object | JSON request body (POST/PUT/PATCH). |
method | string | HTTP method. Defaults to GET. |