gmail-sendas
This server provides Gmail sendAs alias listing, alias-based sending, and attachment download through MCP tools.
list_send_as: Lists Gmail sendAs aliases (settings sendAs).send_as: Sends a new message From a Workspace sendAs alias; requiresfrom,to,subject; optionalbody/html,cc,bcc; returns messageidand optionalthreadIdonly.get_attachment: Downloads inbound Gmail attachment bytes; decodes base64url, returnssize,filename,attachmentId, and standard base64data; optionally writes the decoded bytes to disk whenpathis set.
Allows sending emails from Gmail send-as aliases, listing configured send-as addresses, and downloading inbound email attachments via the Gmail API.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@gmail-sendas Send an email from oberonlogistics.com to john@acme.com with subject 'Contract' and body 'Please sign.'"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
gmail-sendas
Cursor plugin (Gmail sendAs + attachments) that fills gaps in the stock Gmail MCP:
From / sendAs — send a new message as a verified Workspace alias, including attach-on-send for outbound PDFs/images (
send_as)Draft From an alias (never sends) — create a Gmail draft via
users.drafts.createwith From set to a verified sendAs alias (draft_as). Does not callusers.messages.sendorusers.drafts.send.In-thread reply From the landed alias — stock Gmail
replythreads correctly but always sends From the primary mailbox. Usethread_send_aswhen inbound landed on an alias (thread_send_as)Attachment bytes — download inbound file data the stock connector cannot return (
get_attachment)
Keep stock Gmail MCP for inbox search, labels, and triage (including stock reply when From the primary mailbox is fine). This plugin is not a Gmail replacement.
File tree
.
├── .cursor-plugin/plugin.json # name, displayName, OAuth variables (no secrets)
├── mcp.json # stdio MCP; env wires ${GOOGLE_*} into Node
├── skills/gmail-sendas/SKILL.md
├── src/
│ ├── index.js # stdio entry
│ ├── server.js # MCP JSON-RPC + five tools
│ ├── gmail.js # fetch + MIME + OAuth refresh
│ └── secrets.js # creds check + redaction
├── scripts/oauth-setup.js # one-time helper; prints refresh token only
├── test/ # mocked; no live Google calls
├── assets/logo.svg
├── package.json
├── LICENSE # MIT
└── README.mdNo rules, hooks, agents, or commands.
Related MCP server: google-workspace-mcp-server
Tools
Tool | API | Returns |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CallDynamicTool must use namespace user-gmail-sendas toolName draft_as (or thread_send_as / send_as).
When to use which send/reply/draft tool
Need | Tool |
New message that must From a Workspace alias |
|
Draft that must From a Workspace alias (leave in Drafts; do not send) |
|
In-thread reply that must From the address the mail landed on (or another sendAs) |
|
In-thread reply when From the primary mailbox is OK | stock Gmail |
Inbox search, labels, triage | stock Gmail MCP |
send_as required arguments: from (sendAs alias email), to, subject, and body (plain text) and/or html. Optional: cc, bcc, attachments. The From header is set to the alias.
draft_as required arguments: from (must be a verified sendAs alias from the same list_send_as list; unknown or unverified aliases are rejected), to, subject, and body and/or html. Optional: cc, bcc, attachments (same shape and ~25MB cap as send_as), and an in-thread variant: threadId plus inReplyTo / references (RFC In-Reply-To / References, derived with the same helper thread_send_as uses). MIME is built by the shared buildRfc2822 path. Body parts use 8bit (not quoted-printable) so URLs in the body are stored exactly as written — no google.com/url wrapping. Returns { id, threadId } where id is the draft id. This tool never calls users.messages.send or users.drafts.send.
thread_send_as required arguments: messageId (inbound Gmail message to reply to) and body and/or html. Optional: threadId (defaults to the parent message's threadId), from, to, cc, bcc, replyAll, attachments (same shape as send_as). messageId is required; threadId is optional.
From resolution (thread_send_as)
If
fromis provided, use it — it must be an allowed sendAs alias (list_send_as).Else infer from the inbound headers, preferring in order: Delivered-To, X-Original-To, then To (parse the address). Use the first that matches a sendAs alias (case-insensitive).
If none match: fail clearly — pass explicit
from, or the landed address is not a sendAs on this mailbox.
Threading: RFC2822 In-Reply-To / References from the parent, Subject prefixed with Re: when needed, and users.messages.send with threadId set so the reply stays in the Gmail thread. Default recipients are reply-to-sender (parent Reply-To or From); replyAll adds original To/Cc except our sendAs address.
Attach-on-send (when the caller already has a local file and must send From an alias — do not fall back to the Gmail compose UI):
Preferred:
{ path }(e.g./workspace/outbox/invoice.PDF), plus optionalfilenameandmimeTypeFallback:
{ contentBase64 }(orcontent) +filename+mimeTypeFirst-class types: PDF, JPG/JPEG, PNG.
mimeTypeis inferred from those extensions when omitted; other types are fine ifmimeTypeis providedCombined RFC2822 message (headers + body + encoded attachments) must be under Gmail's ~25MB limit; oversize is rejected before
messages.sendReturn value is still
{ id, threadId }only — never tokens or file bytes
Example call shape for agents (Consola / Inbox):
{
"from": "ops@oberonlogistics.com",
"to": "ap@counterparty.com",
"subject": "Invoice 1042",
"body": "Please find the invoice attached.",
"attachments": [
{ "path": "/workspace/outbox/invoice.PDF" }
]
}Base64 fallback when no local path is available:
{
"from": "ops@oberonlogistics.com",
"to": "ap@counterparty.com",
"subject": "Signed rate con",
"html": "<p>Signed copy attached.</p>",
"attachments": [
{
"filename": "rate-con.pdf",
"mimeType": "application/pdf",
"contentBase64": "<standard-base64-bytes>"
}
]
}Example thread_send_as (omit from so Delivered-To can infer the logistics alias):
{
"messageId": "18f2c0ab1234def0",
"body": "Got it — confirming pickup."
}Example draft_as (creates a Draft; does not send):
{
"from": "ops@oberonlogistics.com",
"to": "ap@counterparty.com",
"subject": "Invoice 1042",
"body": "Please find the invoice attached.",
"html": "<p>Please find the invoice attached. <a href=\"https://ptycoin.com/some/path?utm_source=x&utm_medium=y\">View</a></p>",
"attachments": [
{ "path": "/workspace/outbox/invoice.PDF" }
]
}In-thread draft (same header derivation as thread_send_as):
{
"from": "ops@oberonlogistics.com",
"to": "dispatch@carrier.com",
"subject": "Re: Load 1042",
"body": "Draft reply — not sent.",
"threadId": "18f2c0abthread",
"inReplyTo": "<abc@carrier.com>",
"references": "<root@carrier.com> <abc@carrier.com>"
}After merge, restart / reinstall the MCP server for stdio installs. Tool schemas are loaded at process start (tools/list from TOOL_DEFS); an already-running stdio process will not advertise draft_as, thread_send_as, or attachments until it is restarted.
OAuth tokens are never returned or logged.
Data shapes
/** @typedef {{ sendAsEmail: string, displayName?: string, isPrimary?: boolean, isDefault?: boolean, verificationStatus?: string }} SendAs */
/** @typedef {{ id: string, threadId?: string }} SendResult */
/** @typedef {{ id: string, threadId?: string }} DraftResult */
/** @typedef {{ path?: string, filename?: string, mimeType?: string, contentBase64?: string, content?: string }} SendAttachment */
/** @typedef {{ size: number, data: string, attachmentId: string, filename?: string, path?: string }} AttachmentBody */AttachmentBody.data is standard base64 of the decoded bytes (Gmail's wire format is base64url). path is present only when a disk write was requested.
Implementation choice
Zero runtime npm dependencies. Node 18+ fetch refreshes the access token and calls Gmail REST. googleapis is not used — these endpoints do not justify the install. The MCP layer is a small stdio JSON-RPC 2.0 shim (newline-delimited, plus Content-Length read for older clients) instead of @modelcontextprotocol/sdk.
Auth (Jim — one-time, local)
Sign in as the Google Workspace user who owns the sendAs aliases (the Oberon mailbox that sends as oberonlogistics.com / ogholdings.biz / oberon.group — typically the primary Workspace user). Do this on a trusted machine. Never commit tokens or paste them into git, issues, or screenshots.
1. Google Cloud project
Open Google Cloud Console.
Create or select a project.
APIs & Services → Library → enable Gmail API.
OAuth consent screen: User type Internal (Workspace). App name can be
gmail-sendas.Add scopes (minimum for send / list / attachment download):
https://www.googleapis.com/auth/gmail.sendhttps://www.googleapis.com/auth/gmail.readonlyhttps://www.googleapis.com/auth/gmail.settings.basic
draft_asextra scope (not covered by the three above):users.drafts.createrequireshttps://www.googleapis.com/auth/gmail.composeorhttps://www.googleapis.com/auth/gmail.modify.gmail.sendcan send mail but cannot create drafts. Existing refresh tokens issued with only the three documented send/readonly/settings.basic scopes will get a Gmail API 403 until the OAuth client adds compose (or modify) and the mailbox user re-consents.scripts/oauth-setup.jsstill requests the original three scopes; add compose (or modify) on the consent screen and re-run setup if this mailbox should usedraft_as.Credentials → Create credentials → OAuth client ID → application type Desktop app (or Web).
Add authorized redirect URI:
http://127.0.0.1:53682/oauth2callbackCopy the client ID and client secret. Leave them out of the repo.
2. Print a refresh token (stdout only)
cd /path/to/gmail-sendas-connector
export GOOGLE_CLIENT_ID='your-client-id.apps.googleusercontent.com'
export GOOGLE_CLIENT_SECRET='your-client-secret'
node scripts/oauth-setup.jsThe script prints an authorization URL on stderr. Open it, sign in as the Workspace user, and approve. On success, stdout is a single refresh token — nothing else. Copy that value.
If Google does not return a refresh token, revoke the app under Google Account → Apps with access and re-run. The helper always uses access_type=offline and prompt=consent.
Optional: OAUTH_PORT (default 53682) if that port is busy. The redirect URI in Cloud Console must match.
3. Cursor → Plugins → Configure
Install or enable this plugin, then set:
Variable | Value |
| from Cloud Console |
| from Cloud Console |
| stdout from |
mcp.json injects those ${VAR} placeholders into the Node process. The server exchanges the refresh token for a short-lived access token at runtime.
Tests (no live Google)
npm testRequires Node 18+. Coverage (all mocked):
list_send_asresponse parsingsend_asbuilds the From header andusers.messages.send{ raw }bodysend_asattachments: multipart/mixed Content-Type / Content-Disposition, path read, base64 fallback, ~25MB oversize reject; no-attachment MIME unchangeddraft_asvalidatesfromagainst sendAs (rejects unknown/unverified), text-only / html-only / multipart/alternative / multipart/mixed attachments, in-threadthreadId+ In-Reply-To / References, URL bytes kept intact, and never callsmessages.sendordrafts.sendthread_send_asFrom inference (Delivered-To / To), explicitfromwins, fail when inferred address is not sendAs, In-Reply-To / References / threadId set, attachments on replyget_attachmentdecodes base64url and writes a file of the expected byte lengthMissing-credential / refresh errors never echo secrets or file contents
Live demo (after Jim finishes auth)
Not run in CI. After Configure is filled:
In Cursor, ask: List my Gmail sendAs aliases. Expect verified rows for the logistics / holdings / group domains as configured on the mailbox.
Send a test: Send a short test to myself From the logistics alias (
send_aswithfrom= that*.oberonlogistics.comaddress). Confirm the message in Gmail shows the alias as From. Note the returnedidonly.Reply-as smoke (Jim): pick an inbound thread that landed on the logistics alias (
jim.phillips@oberonlogistics.com). Ask: Reply on that thread saying “got it” From the address it landed on (thread_send_aswith that message’smessageId; omitfromso inference can run). Confirm Sent / From is the logistics alias, notjim.phillips@oberon.group, and that the reply stayed in the same Gmail thread. No live send in CI.Download a known inbound PDF: use stock Gmail to find a message and its
attachmentId, then Save that attachment to/tmp/rate-con.pdfviaget_attachment. Confirm the file opens and the byte length is non-zero.
From-routing (no secrets)
Logistics / carrier / dispatch →
*.oberonlogistics.comsendAsHoldings / entity →
*.ogholdings.bizsendAsDefault workspace identity →
*.oberon.groupsendAs
Always prefer list_send_as over hardcoding addresses.
Non-goals
Full Gmail replacement (filters, drafts UI, label management)
Calendar
Cursor Marketplace publish — owner decides later
License
MIT
Available Tools
3 toolsget_attachmentA
Download Gmail attachment bytes (GET users.me.messages.attachments). Stock Gmail MCP cannot return file bytes. Decodes base64url; writes to disk when path is set; returns size, filename, attachmentId, and standard base64.
Inputs: messageId (required), attachmentId (required), path, filename.
list_send_asA
List Gmail sendAs aliases (GET users.me.settings.sendAs). Use this plugin only for sendAs + attachment bytes. Use stock Gmail MCP for inbox search, labels, and triage.
Inputs: no named parameters.
send_asA
Send mail From a Workspace sendAs alias via users.messages.send (RFC2822 MIME raw, base64url). Required: from (alias email), to, subject, and body text and/or html. Optional: cc, bcc. Returns message id (and threadId) only — never tokens.
Inputs: to (required), from (required), subject (required), cc, +3 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
Each tool has a distinct purpose: list_send_as retrieves aliases, send_as sends email from an alias, and get_attachment downloads attachment bytes. There is no functional overlap between them.
Tool names follow a consistent verb_noun pattern (list_send_as, send_as, get_attachment). Minor deviation: send_as uses a verb+preposition rather than verb_noun, but it remains clear and predictable.
Three tools is a small but focused set for a specialized server that explicitly complements a stock Gmail MCP. The count is appropriate for the narrow scope, though it is on the lean side.
The server covers its stated domain: listing aliases, sending from an alias, and retrieving attachment bytes. It intentionally defers inbox search, labels, and triage to another MCP, so the only minor gap is lack of an update/delete operation for sendAs aliases, which is likely out of scope.
Maintenance
Related MCP Connectors
Email: search, read, fetch attachments; attach files when the MCP client supports inputs.
Email infrastructure for AI agents — send, receive, search, and reply to email over MCP.
Your agent needs a mailbox of its own — to receive, thread, draft and send, with attachments, without borrowing your personal inbox or your company's SMTP. **What you can ask for** • "Create an inbox for this agent and tell me its address." • "Read the new messages in this thread and draft a reply." • "Send this message with the attachment and wait for the response." • "Search this inbox for everything from that domain." • "Show delivery metrics and the events on this inbox." **How to use it** Point any MCP client at https://mcp.aisa.one/mail/mcp and sign in with OAuth — there is no key to create or paste. 49 tools: create and delete inboxes, list and read messages, raw message bodies, attachments, threads, drafts and draft attachments, send and reply, message search, inbox events, metrics, and list entries — reads and writes. **Why this rather than the source** A real inbox an agent owns, rather than an SMTP credential it borrows from a human. **It is also a door to the rest** The same login reaches 26 sources and 580+ operations. Find the contact elsewhere in the catalogue, then write to them from here — without adding a second server. **What it costs** Finding and inspecting an operation is free. Running one is billed per call at API prices, with no seat and no monthly minimum, and every call takes max_price_usd so an agent cannot overspend by accident. **Where else it reaches** https://mcp.aisa.one/sales/mcp finds the person to write to.
Hosted email MCP for your own Gmail, Outlook.com, Microsoft 365, iCloud or IMAP inbox: read, search, draft, reply in thread, forward and file mail. It moves or flags up to 500 messages in one call, and a send leaves exactly one copy in Sent. A calendar is a separate connection, and connecting one adds diary and scheduling tools.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables interaction with Gmail through the MCP protocol, supporting sending, reading, searching, replying, forwarding, managing drafts and labels, and saving attachments.6 npm3MIT
- AlicenseNot gradedqualityDmaintenanceEnables sending emails and managing drafts in Gmail, and appending content to Google Docs, via MCP-compatible clients.MIT
- FlicenseNot gradedqualityDmaintenanceEnables reading, searching, sending, and drafting Gmail emails via MCP tools, with support for multiple accounts and background notifications.-
- AlicenseNot gradedqualityCmaintenanceMCP server for Gmail with full read/write coverage: search, send, reply, drafts, labels, filters, vacation responder, auto-forwarding, signature, and attachment handling (download and PDF export). Uses the Gmail API with the gmail.modify scope to prevent permanent deletion, and requires explicit confirmation for sensitive actions.MIT