Features
- Send Emails: Agents can send emails on behalf of the user.
- Organization Support: Support for organization-wide email accounts.
- Multi-Agent Support: Multiple agents can be authenticated with different Gmail accounts.
- Authentication: Secure OAuth2 authentication with Google.
Setup
Prerequisites
- Google Cloud Project: You need a Google Cloud Project with the Gmail API enabled.
- Credentials: Create OAuth 2.0 credentials (Client ID and Client Secret) and download the
credentials.jsonfile. - Environment Variables: Ensure the
Environmentvariable is set correctly (productionorlocal).
Installation
The Gmail MCP server is located inintegrations/mcp_gmail.
- Place your
credentials.jsonfile in theintegrations/mcp_gmaildirectory. - Install dependencies (if not already installed):
Usage
Authentication
Agents need to be authenticated before they can send emails.-
Agent Authentication:
Navigate to the dashboard (default:
http://localhost:8101/) or use the authentication URL:Replace{agent_id}with the ID of the agent you want to authenticate. -
Organization Authentication:
For organization-wide access:
Available Tools
The MCP server exposes the following tools to the agents:send_email
Sends an email from the authenticated agent’s account.
- Arguments:
agent_id(string): The ID of the agent sending the email.to(string): The recipient’s email address.subject(string): The subject of the email.body(string): The body of the email.
send_email_org
Sends an HTML email from the authenticated organization’s account.
- Arguments:
org_id(string): The ID of the organization.to(string): The recipient’s email address.subject(string): The subject of the email.body(string): The HTML body of the email.
get_agent_status
Checks the authentication status of an agent.
- Arguments:
agent_id(string): The ID of the agent.
Dashboard
The Gmail MCP server provides a web dashboard for managing authentications.- URL:
http://localhost:8101/(or your deployed URL) - Features:
- List registered agents and their status.
- Authenticate new agents.
- Test MCP connection.
- Delete agent credentials.
Architecture
The integration uses thefastmcp library to expose tools. It manages Google OAuth2 tokens, refreshing them automatically when expired. Credentials and tokens are stored in Supabase via the McpService.
Key Files
mcp_server.py: The main server file containing tool definitions and OAuth logic.mcp_client.py: Client for testing or interacting with the server.credentials.json: Google OAuth credentials.