When should you use this server
- Fetch recent emails or threads to surface context during agent workflows
- Draft or send emails from AI assistants with human-in-the-loop review
- Search mailboxes for specific conversations, attachments, or senders
- Manage labels and read state programmatically
Key features
- Full mailbox access (read, send, modify) based on granted OAuth scopes
- Hosted endpoint β no self-hosted binary to run
- OAuth 2.0-based access aligned with Google Workspace permissions
Authentication
- Method: OAuth 2.1 with manual OAuth metadata (Google does not use Dynamic Client Registration)
- Google Cloud app: Create an OAuth 2.0 client in Google Cloud Console, configure redirect URL and Gmail scopes
Endpoint
Remote MCP server:Connect via Portkey MCP Gateway
Portkey MCP Gateway provides centralized access control, observability, and credential management for Gmailβs MCP server. Connect once, and all agents get managed Gmail access.Step 1: Create a Google OAuth 2.0 app
1a. Create a project and enable required APIs
- Go to the Google Cloud Console.
- Click the project dropdown at the top and select New Project.
- Enter a project name (e.g.,
Portkey-Gmail-MCP) and click Create. Ensure this project is active in the top dropdown. - In the top search bar, search for and enable both of the following APIs:
- Gmail API (
gmail.googleapis.com) - Gmail MCP API (
gmailmcp.googleapis.com)
- Gmail API (
1b. Configure the OAuth consent screen
- In the left sidebar, navigate to APIs & Services β Google Auth Platform.
- Click Get Started.
- Complete the 4-part configuration wizard:
- App Information: Enter an app name (e.g.,
Portkey Gmail MCP) and select your user support email. Click Next. - Audience: Choose Internal (restricted to your Google Workspace org) or External (for
@gmail.comaccounts or external domains). Click Next. - Contact Information: Enter your developer contact email. Click Next.
- Finish: Accept the Google API services user data policy. Click Continue, then Create.
- App Information: Enter an app name (e.g.,
1c. Configure data access (Gmail scopes)
- Under Google Auth Platform, click Data Access.
- Click Add or remove scopes.
- Search for
gmailor paste the required scope URIs:https://www.googleapis.com/auth/gmail.readonlyβ Read messages and threadshttps://www.googleapis.com/auth/gmail.composeβ Create and edit draftshttps://www.googleapis.com/auth/gmail.sendβ Send emails directlyhttps://www.googleapis.com/auth/gmail.modifyβ Modify labels and read state
- Select the checkboxes and click Update.
1d. Add test users (external apps only)
If you selected βInternalβ in 1b, skip to 1e.- Click Audience in the left navigation.
- Scroll to Test users and click + Add users.
- Enter the Gmail addresses that will authenticate with the MCP integration.
- Click Save.
1e. Generate OAuth 2.0 client credentials
- Under Google Auth Platform, click Clients (or go to APIs & Services β Credentials).
- Click + Create Client (or Create Credentials β OAuth client ID).
- Set Application type to Web application.
-
Set a name (e.g.,
Portkey Gateway Client). -
Under Authorized redirect URIs, click + Add URI and enter:
- Click Create.
- Copy both the Client ID and Client Secret from the modal.
Step 2: Register the integration in Portkey
- In Portkey, go to MCP Registry β Add MCP Integration.
- Fill in the basic details:
- Expand Advanced Configuration and paste (replace placeholders):
- Configure workspace access as needed, then save the integration.
Step 3: Connect from an agent
With Portkey OAuth 2.1, agents connect without credentials in headers:Available scopes reference
Tools provided
list_messages
Lists messages in the userβs mailbox. Supports filtering by label IDs and search queries. Arguments:maxResults(number, optional) β maximum number of messages to return (default 100, max 500).labelIds(string[], optional) β only return messages with all of the specified labels applied.q(string, optional) β Gmail search query string (e.g.,from:user@example.com is:unread).pageToken(string, optional) β token for fetching the next page of results.
get_message
Retrieves a specific message by its ID, with optional format control. Arguments:id(string, required) β the ID of the message to retrieve.format(string, optional) β format of the message:full,metadata,minimal, orraw. Defaults tofull.
search_messages
Searches for messages using Gmailβs search operators. Arguments:query(string, required) β Gmail search query (e.g.,subject:invoice from:finance@company.com).maxResults(number, optional) β maximum number of messages to return.pageToken(string, optional) β token for the next page of results.
send_message
Sends an email message on behalf of the authenticated user. Arguments:to(string, required) β recipient email address.subject(string, required) β email subject line.body(string, required) β email body content.cc(string, optional) β CC recipients (comma-separated).bcc(string, optional) β BCC recipients (comma-separated).threadId(string, optional) β thread ID to reply within an existing conversation.
create_draft
Creates a new draft message without sending it. Arguments:to(string, required) β recipient email address.subject(string, required) β email subject.body(string, required) β email body content.cc(string, optional) β CC recipients (comma-separated).bcc(string, optional) β BCC recipients (comma-separated).threadId(string, optional) β thread ID to associate the draft with an existing conversation.
list_drafts
Lists draft messages in the userβs mailbox. Arguments:maxResults(number, optional) β maximum number of drafts to return.pageToken(string, optional) β token for the next page.q(string, optional) β search query to filter drafts.
trash_message
Moves a message to the trash. Arguments:id(string, required) β the ID of the message to trash.
modify_message
Adds or removes labels from a message. Use this to mark messages as read/unread, archive, or apply custom labels. Arguments:id(string, required) β the ID of the message to modify.addLabelIds(string[], optional) β list of label IDs to add.removeLabelIds(string[], optional) β list of label IDs to remove (e.g.,UNREADto mark as read).
list_threads
Lists email threads in the userβs mailbox. Arguments:maxResults(number, optional) β maximum number of threads to return.labelIds(string[], optional) β filter by label IDs.q(string, optional) β Gmail search query string.pageToken(string, optional) β token for the next page.
get_thread
Retrieves all messages in an email thread. Arguments:id(string, required) β the ID of the thread to retrieve.format(string, optional) β format for messages in the thread:full,metadata, orminimal.
list_labels
Lists all labels in the userβs mailbox (system labels like INBOX, SENT, SPAM and user-created labels). Arguments: Nonecreate_label
Creates a new user-defined label. Arguments:name(string, required) β display name for the label.labelListVisibility(string, optional) β label visibility in the label list:labelShow,labelHide, orlabelShowIfUnread.messageListVisibility(string, optional) β message list visibility:showorhide.
get_profile
Returns profile information for the authenticated userβs Gmail account, including the email address, messages total, threads total, and history ID. Arguments: NonePrerequisites
- A Google Cloud project with both Gmail API and Gmail MCP API enabled
- A compatible MCP host with remote server support
Add
"headers": { "x-portkey-api-key": "YOUR_PORTKEY_API_KEY" } when the workspace requires the Portkey API key on the MCP request β see Integrations. For self-hosted gateways, replace mcp.portkey.ai with the gateway host.Portkey is now PRISMA AIRS AI Gateway. See it in action.
Contact Us

