@yashpatel28/mail-mcp
v1.1.0
Published
Read-only Outlook and Gmail MCP server
Maintainers
Readme
Mail MCP
Read-only Gmail and Outlook MCP. Gmail uses the Gmail API and Google OAuth; Outlook uses Microsoft Graph delegated permissions. Both providers cache tokens locally, so normal mail queries do not start a new browser sign-in.
Gmail setup
For a personal Gmail account, use Google's Personal mode onboarding to create a project and a Desktop app OAuth client for your account. Personal mode avoids the External testing-user cap, app verification, and seven-day test-token expiration. Personal mode is only for the Google account that creates it.
For a multi-user setup, create or select a Google Cloud project, enable Gmail API, configure Google Auth Platform > Branding/Audience/Data Access, and create a Desktop app client under Clients. Choose Internal only for users in your Google Workspace organization; otherwise use External and add your own account as a test user while the app is in Testing. Google's Gmail Python quickstart shows where to create the desktop credentials.
The MCP requests only https://www.googleapis.com/auth/gmail.readonly. Google classifies this as a restricted scope; production distribution to other users may require OAuth app verification. External apps in Testing also have refresh tokens that expire after seven days. See Google's Gmail scope requirements and OAuth token expiration rules.
Set the downloaded Desktop app credentials in your Windows user environment (then fully restart OpenCode):
setx GMAIL_CLIENT_ID "your-client-id.apps.googleusercontent.com"
setx GMAIL_CLIENT_SECRET "your-client-secret"The example OpenCode config references these as {env:GMAIL_CLIENT_ID} and {env:GMAIL_CLIENT_SECRET}. Do not commit the client secret or downloaded credential JSON.
Outlook setup
- Register an Entra app for your account type and add Microsoft Graph delegated permissions
Mail.ReadandUser.Read. - Enable Allow public client flows in the app's Authentication settings.
- Set
MAIL_MCP_CLIENT_IDandMAIL_MCP_TENANT_IDin OpenCode. No Outlook client secret is needed. - Organization policy may require an administrator to consent to the app before sign-in.
OpenCode configuration
Use the mail-server entry from ../configuration/opencode.json. It launches the published npm package. Replace the IDs with your own app's IDs when needed. Version 1.1.0 includes Gmail support; publish that version before using the npm command. OpenCode must be restarted after setting Google environment variables.
First Gmail sign-in
- Call
begin_gmail_sign_in. - Open the returned authorization URL, sign in to the intended Google account, and approve Gmail read-only access.
- The browser redirects to the MCP's local callback. Call
complete_gmail_sign_into confirm.
The Google OAuth tokens are stored under %LOCALAPPDATA%\OutlookMailMCP\gmail-token.bin on Windows and protected with Windows data protection. The Outlook token cache is stored beside it. Set MAIL_MCP_HOME to choose a different location. The token cache persists across projects on the same Windows user account.
Tools
- Gmail:
begin_gmail_sign_in,complete_gmail_sign_in,get_gmail_profile,list_gmail_labels,search_gmail,get_gmail_message. - Outlook:
begin_outlook_sign_in,complete_outlook_sign_in,get_outlook_profile,list_mail_folders,search_emails,get_email. search_gmailaccepts Gmail search syntax and defaults to inbox mail when the query is omitted. Both message detail tools cap body output at 20,000 characters.
Both providers expose read-only operations. Never commit local token caches, OAuth credentials, or passwords.
Local development
python -m venv .venv
.\.venv\Scripts\python.exe -m pip install -r requirements.txtFor local development, point OpenCode's command at the virtual environment's Python and server.py, using the same environment settings from ../configuration/opencode.json.
