Skip to main content

Gmail

8 tools using the Gmail API with OAuth2 — search, read, send, reply, forward. Implemented in tools/gmailOps.js.

Setup​

Gmail uses OAuth2 instead of a simple API key, because access is tied to a specific Google account. Gmail, Calendar and Search Console share one OAuth client that you create once:

  1. In Google Cloud Console, create a project or pick an existing one.
  2. Enable the Gmail API.
  3. Under Google Auth Platform, fill in Branding, and under Audience choose External and add your own Google account as a test user.
  4. Under Clients, create a client of type Desktop app. A "Web application" client fails with redirect_uri_mismatch.
  5. Save the client id and secret: causly-server setup gmail.
  6. Sign in once in your browser:
causly-server login google

This saves GMAIL_REFRESH_TOKEN for you. While your Google app is in Testing status, Google expires the token every 7 days. Run causly-server login google again to renew it, or publish the app in Audience to stop the expiry. See Environment variables.

Tools​

ToolRiskWhat it does
gmail_get_profileREADGet the authenticated account's profile — connectivity check
gmail_searchREADSearch messages using Gmail search syntax (from:, subject:, etc.)
gmail_list_messagesREADList recent messages, optionally scoped to a label
gmail_get_messageREADGet a single message's decoded content by message ID
gmail_get_threadREADGet a full thread (all messages in it) by thread ID
gmail_sendHIGHSend a new email
gmail_replyHIGHReply to an existing message in the same thread
gmail_forwardHIGHForward an existing message to a new recipient

Example​

"Find the latest email from our Vercel billing alerts and forward it to me
with a summary."

Claude calls gmail_search with a query like from:vercel.com subject:billing → gmail_forward (confirm: true) with the matched message ID.