samwang0723/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 and Google Calendar access through Bearer token authentication.
Features
- š§ Gmail Integration: Read email lists and get individual email details
- š Email Search: Search emails using Gmail query syntax
- š Google Calendar Integration: List calendars, events, create events, and manage invitations
- š DateTime Utilities: Convert datetime strings between different formats
- š Bearer Token Auth: Secure authentication using Google OAuth2 access tokens
- š MCP Protocol: Compatible with Model Context Protocol for AI integration
Available MCP Tools
Gmail Tools
gmail_list_emails
- Get a list of emails with optional filtering and batch detail fetchinggmail_get_details
- Get detailed information about a specific email with configurable word limitsgmail_search_emails
- Search emails using Gmail query syntax
Google Calendar Tools
gcalendar_list_calendars
- Get a list of all calendars in the user's calendar listgcalendar_list_events
- Get a list of events from a specified calendar with time range filteringgcalendar_create_event
- Create a new event in a calendar with attendees and notificationsgcalendar_decline_event
- Decline an invitation to a calendar event
Utility Tools
datetime_converter
- Convert datetime strings to different formats (ISO, UTC, Unix timestamp)
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 Google API scopes:
Gmail API Scopes:
https://www.googleapis.com/auth/gmail.readonly
- Read access to Gmail
Google Calendar API Scopes:
https://www.googleapis.com/auth/calendar
- Full access to Google Calendarhttps://www.googleapis.com/auth/calendar.readonly
- Read-only access to Google Calendar (minimum required)https://www.googleapis.com/auth/calendar.events
- Access to events (required for creating/modifying events)
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
Gmail Tools
1. List Emails with Details
{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "gmail_list_emails",
"arguments": {
"maxResults": 10,
"query": "is:unread",
"fetchDetails": true
}
},
"id": 1
}
2. Get Email Details
{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "gmail_get_details",
"arguments": {
"messageId": "1234567890abcdef",
"format": "full",
"maxWords": 500
}
},
"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
}
Google Calendar Tools
4. List Calendars
{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "gcalendar_list_calendars",
"arguments": {}
},
"id": 4
}
5. List Events
{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "gcalendar_list_events",
"arguments": {
"calendarId": "primary",
"maxResults": 20,
"timeMin": "2025-07-31T00:00:00Z",
"timeMax": "2025-08-31T23:59:59Z"
}
},
"id": 5
}
6. Create Event
{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "gcalendar_create_event",
"arguments": {
"calendarId": "primary",
"summary": "Team Meeting",
"description": "Weekly team sync meeting",
"location": "Conference Room A",
"start": {
"dateTime": "2025-08-01T15:00:00-07:00",
"timeZone": "America/Los_Angeles"
},
"end": {
"dateTime": "2025-08-01T16:00:00-07:00",
"timeZone": "America/Los_Angeles"
},
"attendees": ["colleague@example.com"],
"sendNotifications": true
}
},
"id": 6
}
Utility Tools
7. Convert DateTime
{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "datetime_converter",
"arguments": {
"datetime": "July 31, 2025 3:00 PM PST",
"format": "iso"
}
},
"id": 7
}
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 reload using tsxnpm run build
- Build TypeScript to JavaScript (outputs to dist/)npm start
- Start production server from built JavaScriptnpm run lint
- Run ESLint on TypeScript filesnpm run lint:fix
- Fix ESLint issues automaticallynpm run quality
- Run comprehensive quality checks (type-check + lint + format:check)npm test
- Run Jest tests
Project Structure
src/
āāā config/
ā āāā index.ts # Server configuration
āāā services/
ā āāā gmail.ts # Gmail API integration with batch operations
ā āāā gcalendar.ts # Google Calendar API integration
ā āāā types.ts # TypeScript type definitions
āāā utils/
ā āāā logger.ts # Winston logger configuration
āāā index.ts # MCP server setup and tool definitions
āāā register-paths.ts # TypeScript path aliases runtime registration
License
MIT License