Skip to content

Overview

CI

Surfski MCP server

Many Gmail inboxes, one Claude connector. · surfski.io

Surfski is a small, self-hosted remote MCP server. You add it to Claude once as a custom connector. After that, Claude can search, read and draft email across several Gmail / Google Workspace mailboxes for each user, and users never see each other’s mailboxes.

  • Works from claude.ai on the web, desktop and mobile. Any client that speaks MCP Streamable HTTP with OAuth works too.
  • Each Claude user signs in with Google, and only allowlisted addresses get in.
  • Each user links any number of mailboxes under short aliases such as work, personal or support.
  • Drafts only by default. Claude saves drafts and you send them from Gmail. An operator can turn on opt-in sending, and each mailbox then picks off, confirm (you click a link to send) or auto.

Tools: list_accounts, link_account, relink_account, rename_account, unlink_account, search_threads, search_all_accounts, find_contact, get_thread, get_message, list_labels, create_draft, list_drafts, get_draft, update_draft, delete_draft, list_addresses, set_address_label, set_default_from, forward_message, get_attachment, unsubscribe, export_my_data, delete_my_data. With SENDING_ENABLED=true also: send_draft, send_email, set_send_policy (and forward_message(send=true)). With TRIAGE_ENABLED=true also: enable_triage, disable_triage, mark_read, mark_unread, star, unstar, archive, move_to_inbox, apply_label, remove_label, create_label, trash, untrash (see Triage). With FEATURES=mail,calendar also: enable_calendar, disable_calendar, set_calendar_policy, list_calendars, list_events, get_event, find_free_time, create_event, update_event, respond_to_event, delete_event (see Calendar).

Find an address. find_contact("Alice") (or part of an address, or a name in any script, e.g. 王伟) looks through the From/To/Cc/Reply-To headers of your own recent mail in all your mailboxes (or the aliases you pass) and returns likely addresses with their display names, message count, last seen date, mailboxes and whether you’ve written to them, ranked by frequency, recency and that “sent to” boost. It needs no extra Google scope. Each mailbox scans at most 50 threads / 200 messages. Your own addresses and no-reply senders are left out unless you pass include_self / include_noreply. The audit log records only counts, never the name or addresses.

Unsubscribe. unsubscribe(alias, message_id) reads only the message’s List-Unsubscribe and List-Unsubscribe-Post headers (never links in the body) and reports what it would do; nothing happens until it’s called again with confirm=true, which re-reads the headers. It then uses, in order: the RFC 8058 one-click POST to the sender’s https endpoint; a mailto unsubscribe, saved as a draft and sent only if the mailbox’s send policy allows it (confirm goes through the usual approval; with sending off the draft is kept for you to send); or, for a plain https link, it returns the URL for you to open (it never loads web pages). Unsubscribing tells the sender the address is live, so for spam, report it instead. See Unsubscribe safety.

Send from an alias. create_draft and update_draft take from_address (a verified “Send mail as” address or a label set with set_address_label) and include_signature. Replies default to the address the original was sent to; new drafts use set_default_from, then Gmail’s default. New addresses are added in Gmail → Settings → Accounts → Send mail as.

Attach files from your mail. create_draft, send_email and forward_message take attachments, and update_draft takes add_attachments. Each entry is {message_id, part_id}, using the part_id that get_message / get_thread list. Files can only come from messages in the same mailbox; a message id from another alias fails with a clear error. There are no local or arbitrary uploads. Duplicate entries are attached once. The total is limited to 20 MB, checked from the declared sizes before anything is downloaded, and large drafts go up as media uploads. update_draft keeps the draft’s current attachments. Inline images are kept as regular attachments, as in forward_message. Pass remove_attachments (a filename as get_draft lists it, which removes every attachment with that name, or a part_id) to drop some. The audit log records only the attachment count and total bytes.

Gmail’s read scopes are restricted scopes. To offer them to the public, an app needs Google OAuth verification plus a third-party CASA security assessment that is renewed every year. A self-hosted instance avoids all of that:

  • you use your own Google Cloud project and OAuth client;
  • an unverified app works for up to 100 users over the app’s lifetime, which is plenty for a person, family or small team;
  • refresh tokens never leave your server.

The only cost is an “unverified app” warning on the Google consent screen. Your users click Advanced → continue once per mailbox.

Claude ─HTTPS─► your reverse proxy :443 ─► container :8000 (published on 127.0.0.1:38000)
/mcp MCP endpoint (bearer auth)
/auth/callback Google login for Claude users (layer A)
/gmail/callback Gmail mailbox linking (layer B)
/healthz returns "ok"
volume → /data
data.db accounts (Fernet-encrypted refresh tokens), audit_log
oauth/ FastMCP OAuth client storage (Fernet-encrypted)

There are two separate OAuth layers, and both use the same Google OAuth client:

LayerProvesScopesRedirect URI
A. MCP loginwhich Claude user is calling, checked against ALLOWED_USERS / ALLOWED_DOMAINSopenid, userinfo.emailhttps://<host>/auth/callback
B. Mailbox linkaccess to one mailboxgmail.readonly, gmail.composehttps://<host>/gmail/callback

MIT


Synced from rayhu/surfski/README.md@0165816. The repository is the source of truth.