google-workspace-mcp-server
by: epaproditus
A Model Context Protocol server for Google Workspace integration (Gmail and Calendar)
📌Overview
Purpose: To provide a Model Context Protocol (MCP) server that facilitates programmatic interaction with Gmail and Calendar APIs.
Overview: The Google Workspace MCP Server offers a robust interface for managing emails and calendar events. It allows developers to utilize various functionalities efficiently through an organized set of tools that streamline the automation of communication and scheduling tasks.
Key Features:
-
Gmail Tools:
list_emails
: Fetch recent emails with optional filtering to enhance organization and quick access.search_emails
: Conduct advanced searches using Gmail query syntax to find specific emails easily.send_email
: Send emails reliably with additional support for CC and BCC fields.modify_email
: Adjust email labels, such as archiving or marking as read/unread, to maintain inbox order.
-
Calendar Tools:
list_events
: Retrieve upcoming events within a specified date range to stay updated on upcoming appointments.create_event
: Add new events to the calendar and include attendees for better coordination.update_event
: Modify details of existing calendar events conveniently.delete_event
: Remove calendar events that are no longer necessary, simplifying calendar management.
Google Workspace MCP Server
A Model Context Protocol (MCP) server that provides tools for interacting with Gmail and Calendar APIs, allowing you to manage your emails and calendar events programmatically.
Features
Gmail Tools
list_emails
: List recent emails from your inbox with optional filtering.search_emails
: Advanced email search with Gmail query syntax.send_email
: Send new emails with support for CC and BCC.modify_email
: Modify email labels (archive, trash, mark read/unread).
Calendar Tools
list_events
: List upcoming calendar events with date range filtering.create_event
: Create new calendar events with attendees.update_event
: Update existing calendar events.delete_event
: Delete calendar events.
Prerequisites
- Node.js: Install Node.js version 14 or higher.
- Google Cloud Console Setup:
- Create or select an existing project.
- Enable the Gmail API and Google Calendar API.
- Set up OAuth 2.0 credentials with the necessary redirect URIs.
Setup Instructions
-
Clone and Install:
git clone https://github.com/epaproditus/google-workspace-mcp-server.git cd google-workspace-mcp-server npm install
-
Create OAuth Credentials: Create a
credentials.json
file in the root directory with your Client ID and Secret. -
Get Refresh Token:
node get-refresh-token.js
This will open your browser for Google OAuth authentication and save the credentials to
token.json
. -
Configure MCP Settings: Add the server configuration to your MCP settings file:
{ "mcpServers": { "google-workspace": { "command": "node", "args": ["/path/to/google-workspace-server/build/index.js"], "env": { "GOOGLE_CLIENT_ID": "your_client_id", "GOOGLE_CLIENT_SECRET": "your_client_secret", "GOOGLE_REFRESH_TOKEN": "your_refresh_token" } } } }
-
Build and Run:
npm run build
Usage Examples
Gmail Operations
-
List Recent Emails:
{ "maxResults": 5, "query": "is:unread" }
-
Search Emails:
{ "query": "from:example@gmail.com has:attachment", "maxResults": 10 }
-
Send Email:
{ "to": "recipient@example.com", "subject": "Hello", "body": "Message content" }
-
Modify Email:
{ "id": "message_id", "addLabels": ["UNREAD"], "removeLabels": ["INBOX"] }
Calendar Operations
-
List Events:
{ "maxResults": 10, "timeMin": "2024-01-01T00:00:00Z", "timeMax": "2024-12-31T23:59:59Z" }
-
Create Event:
{ "summary": "Team Meeting", "location": "Conference Room", "start": "2024-01-24T10:00:00Z", "end": "2024-01-24T11:00:00Z" }
-
Update Event:
{ "eventId": "event_id", "summary": "Updated Meeting Title", "start": "2024-01-24T11:00:00Z" }
-
Delete Event:
{ "eventId": "event_id" }
Troubleshooting
-
Authentication Issues:
- Ensure all required OAuth scopes are granted.
- Verify client ID and secret are correct.
-
API Errors:
- Check Google Cloud Console for API quotas and limits.
- Ensure APIs are enabled for your project.
License
This project is licensed under the MIT License.