mcp-google-assistant
If you are the rightful owner of mcp-google-assistant and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
AI-powered Google Gmail/Calendar MCP server that provides Gmail access through Bearer token authentication.
MCP Google Assistant
AI-powered Google Gmail/Calendar MCP server that provides Gmail access through Bearer token authentication.
Features
- š§ Gmail Integration: Read email lists and get individual email details
- š Email Search: Search emails using Gmail query syntax
- š Bearer Token Auth: Secure authentication using Google OAuth2 access tokens
- š MCP Protocol: Compatible with Model Context Protocol for AI integration
Gmail Functions
Available Tools
gmail-list-emails
- Get a list of emails with optional filteringgmail-get-email
- Get detailed information about a specific emailgmail-search-emails
- Search emails using Gmail query syntaxgmail-get-unread
- Get unread emails
Authentication
This server uses Bearer token authentication. External upstream services should include the Google OAuth2 access token in the Authorization header:
Authorization: Bearer <your-google-oauth2-access-token>
Required Google API Scopes
Your access token must include the following Gmail API scopes:
https://www.googleapis.com/auth/gmail.readonly
- Read access to Gmail
Installation
- Clone the repository:
git clone <repository-url>
cd mcp-google-assistant
- Install dependencies:
npm install
- Build the project:
npm run build
- Start the server:
npm start
The server will start on http://localhost:3000
by default.
Configuration
Set environment variables as needed:
# Server Configuration
PORT=3000
LOG_LEVEL=info
Usage Examples
1. Get Email List
{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "gmail-list-emails",
"arguments": {
"maxResults": 10,
"query": "is:unread"
}
},
"id": 1
}
2. Get Email Details
{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "gmail-get-email",
"arguments": {
"messageId": "1234567890abcdef",
"format": "full"
}
},
"id": 2
}
3. Search Emails
{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "gmail-search-emails",
"arguments": {
"query": "from:example@gmail.com subject:important",
"maxResults": 5
}
},
"id": 3
}
4. Get Unread Emails
{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "gmail-get-unread",
"arguments": {
"maxResults": 20
}
},
"id": 4
}
Gmail Query Syntax
The search functions support Gmail's query syntax:
from:sender@example.com
- Emails from specific senderto:recipient@example.com
- Emails to specific recipientsubject:keyword
- Emails with keyword in subjectis:unread
- Unread emailsis:important
- Important emailshas:attachment
- Emails with attachmentsafter:2023/1/1
- Emails after specific datebefore:2023/12/31
- Emails before specific date
You can combine multiple criteria: from:boss@company.com is:unread
Error Handling
The server provides detailed error messages for common scenarios:
- MISSING_AUTHORIZATION: No Authorization header provided
- INVALID_BEARER_TOKEN: Malformed bearer token
- AUTHENTICATION_FAILED: Invalid or expired access token
- PERMISSION_DENIED: Insufficient Gmail API permissions
- RATE_LIMIT_EXCEEDED: Gmail API quota exceeded
- EMAIL_NOT_FOUND: Requested email doesn't exist
Development
Scripts
npm run dev
- Start development server with hot reloadnpm run build
- Build TypeScript to JavaScriptnpm run lint
- Run ESLintnpm run lint:fix
- Fix ESLint issues automatically
Project Structure
src/
āāā config/ # Configuration management
āāā services/ # Gmail service implementation
ā āāā gmail.ts # Main Gmail API integration
āāā utils/ # Utility functions
āāā index.ts # MCP server setup
License
MIT License