feat: Add Support for Google Drive and Gmail Operations - #5
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for Google Drive and Gmail operations to the MCP server by updating OAuth scopes and introducing new tools for interacting with these services. Key changes include updating the server’s OAuth scopes in core/server.py, adding new packages (gdrive and gmail) with corresponding tool functions, and enhancing existing calendar tools for improved documentation and clarity.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| main.py | Added imports to register new gdrive and gmail tools |
| gmail/gmail_tools.py | Introduced Gmail API tools with decorator-based authentication |
| gmail/init.py | Marked the gmail directory as a Python package |
| gcalendar/calendar_tools.py | Enhanced docstrings with clearer guidance and parameter documentation |
| core/server.py | Updated OAuth scopes to include Drive and Gmail scopes |
| ] | ||
|
|
||
| # Combined scopes for all supported Google Workspace operations | ||
| SCOPES = list(set(BASE_SCOPES + CALENDAR_SCOPES + DRIVE_SCOPES + GMAIL_SCOPES + [DRIVE_FILE_SCOPE])) # Add DRIVE_FILE_SCOPE and GMAIL_SCOPES |
There was a problem hiding this comment.
Using a set to combine scopes may result in non-deterministic ordering, which could affect behavior if the order of scopes matters in downstream configuration. Consider sorting the resulting list for consistency.
| SCOPES = list(set(BASE_SCOPES + CALENDAR_SCOPES + DRIVE_SCOPES + GMAIL_SCOPES + [DRIVE_FILE_SCOPE])) # Add DRIVE_FILE_SCOPE and GMAIL_SCOPES | |
| SCOPES = sorted(set(BASE_SCOPES + CALENDAR_SCOPES + DRIVE_SCOPES + GMAIL_SCOPES + [DRIVE_FILE_SCOPE])) # Add DRIVE_FILE_SCOPE and GMAIL_SCOPES |
…mail feat: Add Support for Google Drive and Gmail Operations
taylorwilsdon#1 gmail_tools.py: remove contacts/thread fallback for sender From-name; sender name is Send-As only — bare address is correct degradation. taylorwilsdon#2 gmail_web_mime.py: pass maxlinelen=998 to Header.encode() so long non-ASCII display names are not folded with CR/LF, preventing ValueError in _safe_header for long CJK or similar names. taylorwilsdon#3 gmail_web_mime.py: escape date_str through _escape_body() in the forwarded-message attr block; all other fields were already escaped. taylorwilsdon#4 gmail_web_mime.py: drop ord("_") from _QP_SAFE exclusion set so underscore-heavy ASCII content is correctly classified as quoted-printable rather than base64. taylorwilsdon#5 test_gmail_web_mime.py: tighten BOUNDARY_RE to exactly 16 hex chars (was 16–18), matching the documented gmail_boundary() output format. taylorwilsdon#6 golden_skeleton.py: broaden EMAIL_RE to cover RFC 5321 special chars in the local part (apostrophe, bang, etc.) so o'hara@example.com is fully redacted rather than partially matched. taylorwilsdon#7 golden_skeleton.py: change _class_stack to list[set[str]] and test membership via set intersection, so multi-class markup like class="gmail_attr extra" correctly suppresses inner attribution text. Tests: add focused tests for each behavioral fix (taylorwilsdon#1–taylorwilsdon#4, taylorwilsdon#6–taylorwilsdon#7).
feat: add Google Drive & Gmail support to MCP server
Description
This pull request introduces comprehensive Google Drive and Gmail integration into the MCP server. It:
core/server.py.SCOPESlist to include Drive (readonly + per-file) and Gmail (readonly + send).gdrivepackage with tools for searching, listing, reading, and creating Drive files.gmailpackage with tools for searching messages and retrieving message content.gdrive.drive_toolsandgmail.gmail_toolsinmain.py.Changes
DRIVE_READONLY_SCOPE,DRIVE_FILE_SCOPEGMAIL_READONLY_SCOPE,GMAIL_SEND_SCOPEDRIVE_SCOPES,GMAIL_SCOPESSCOPES = list(set(BASE_SCOPES + CALENDAR_SCOPES + DRIVE_SCOPES + GMAIL_SCOPES + [DRIVE_FILE_SCOPE]))start_auth,list_calendars,get_eventswith:Args:andReturns:types_initiate_drive_auth_and_get_messagesearch_drive_files(query, …)get_drive_file_content(file_id, …)list_drive_items(folder_id, …)create_drive_file(file_name, content, folder_id, …)@require_google_authsearch_gmail_messages(query, …)get_gmail_message_content(message_id, …)How to Test
client_secret.json) in the project root (or setGOOGLE_CLIENT_SECRETSenv var).uv pip install -e . python main.py