@mutallip/google-workspace-mcp 0.0.0-stage → 2.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +353 -2
  3. package/README.npm.md +34 -0
  4. package/auth/__init__.py +1 -0
  5. package/auth/auth_info_middleware.py +419 -0
  6. package/auth/client_secrets.py +76 -0
  7. package/auth/credential_store.py +598 -0
  8. package/auth/external_oauth_provider.py +369 -0
  9. package/auth/gateway_identity.py +164 -0
  10. package/auth/google_auth.py +1550 -0
  11. package/auth/google_oauth_provider.py +20 -0
  12. package/auth/mcp_session_middleware.py +95 -0
  13. package/auth/oauth21_session_store.py +1332 -0
  14. package/auth/oauth_callback_server.py +466 -0
  15. package/auth/oauth_config.py +693 -0
  16. package/auth/oauth_proxy_config.py +122 -0
  17. package/auth/oauth_responses.py +230 -0
  18. package/auth/oauth_types.py +92 -0
  19. package/auth/permissions.py +330 -0
  20. package/auth/port_resolver.py +153 -0
  21. package/auth/request_identity.py +89 -0
  22. package/auth/scopes.py +369 -0
  23. package/auth/service_decorator.py +1109 -0
  24. package/bin/google-workspace-mcp.cjs +123 -0
  25. package/core/__init__.py +1 -0
  26. package/core/api_enablement.py +108 -0
  27. package/core/attachment_storage.py +496 -0
  28. package/core/camel_case_middleware.py +98 -0
  29. package/core/cli.py +161 -0
  30. package/core/comments.py +609 -0
  31. package/core/config.py +57 -0
  32. package/core/context.py +43 -0
  33. package/core/file_limits.py +632 -0
  34. package/core/gcs_attachment_storage.py +253 -0
  35. package/core/http_utils.py +339 -0
  36. package/core/log_formatter.py +270 -0
  37. package/core/portable_schema_middleware.py +67 -0
  38. package/core/server.py +1192 -0
  39. package/core/startup_ui.py +239 -0
  40. package/core/storage.py +23 -0
  41. package/core/telemetry.py +194 -0
  42. package/core/tool_descriptions.py +19 -0
  43. package/core/tool_registry.py +311 -0
  44. package/core/tool_tier_loader.py +197 -0
  45. package/core/tool_tiers.yaml +179 -0
  46. package/core/toolset_header_middleware.py +67 -0
  47. package/core/utils.py +1537 -0
  48. package/core/valkey_storage.py +271 -0
  49. package/core/warning_filters.py +19 -0
  50. package/fastmcp_server.py +198 -0
  51. package/gappsscript/README.md +512 -0
  52. package/gappsscript/TESTING.md +254 -0
  53. package/gappsscript/__init__.py +0 -0
  54. package/gappsscript/apps_script_tools.py +1940 -0
  55. package/gcalendar/__init__.py +1 -0
  56. package/gcalendar/calendar_helpers.py +1323 -0
  57. package/gcalendar/calendar_tools.py +2252 -0
  58. package/gchat/__init__.py +7 -0
  59. package/gchat/chat_helpers.py +410 -0
  60. package/gchat/chat_tools.py +798 -0
  61. package/gcontacts/__init__.py +1 -0
  62. package/gcontacts/contacts_helpers.py +765 -0
  63. package/gcontacts/contacts_tools.py +1685 -0
  64. package/gdocs/__init__.py +0 -0
  65. package/gdocs/docs_anchors.py +163 -0
  66. package/gdocs/docs_comments.py +89 -0
  67. package/gdocs/docs_helpers.py +2201 -0
  68. package/gdocs/docs_links.py +87 -0
  69. package/gdocs/docs_markdown.py +828 -0
  70. package/gdocs/docs_markdown_writer.py +592 -0
  71. package/gdocs/docs_plain_text.py +463 -0
  72. package/gdocs/docs_structure.py +621 -0
  73. package/gdocs/docs_tables.py +425 -0
  74. package/gdocs/docs_tools.py +3300 -0
  75. package/gdocs/managers/__init__.py +18 -0
  76. package/gdocs/managers/batch_operation_manager.py +1694 -0
  77. package/gdocs/managers/header_footer_manager.py +526 -0
  78. package/gdocs/managers/table_operation_manager.py +488 -0
  79. package/gdocs/managers/validation_manager.py +1504 -0
  80. package/gdocs/operation_schemas.py +594 -0
  81. package/gdrive/__init__.py +0 -0
  82. package/gdrive/drive_helpers.py +1738 -0
  83. package/gdrive/drive_tools.py +3085 -0
  84. package/gforms/__init__.py +3 -0
  85. package/gforms/forms_tools.py +575 -0
  86. package/gmail/__init__.py +1 -0
  87. package/gmail/gmail_helpers.py +2107 -0
  88. package/gmail/gmail_tools.py +4895 -0
  89. package/gmail/gmail_web_mime.py +441 -0
  90. package/gsearch/__init__.py +0 -0
  91. package/gsearch/search_tools.py +253 -0
  92. package/gsheets/__init__.py +31 -0
  93. package/gsheets/sheets_helpers.py +2236 -0
  94. package/gsheets/sheets_tools.py +3280 -0
  95. package/gslides/__init__.py +0 -0
  96. package/gslides/slides_digest.py +390 -0
  97. package/gslides/slides_helpers.py +392 -0
  98. package/gslides/slides_markup.py +770 -0
  99. package/gslides/slides_tools.py +376 -0
  100. package/gtasks/__init__.py +5 -0
  101. package/gtasks/tasks_tools.py +936 -0
  102. package/main.py +1170 -0
  103. package/package.json +43 -4
  104. package/pyproject.toml +173 -0
  105. package/uv.lock +2504 -0
package/auth/scopes.py ADDED
@@ -0,0 +1,369 @@
1
+ """
2
+ Google Workspace OAuth Scopes
3
+
4
+ This module centralizes OAuth scope definitions for Google Workspace integration.
5
+ Separated from service_decorator.py to avoid circular imports.
6
+ """
7
+
8
+ import logging
9
+
10
+ logger = logging.getLogger(__name__)
11
+
12
+ # Global variable to store enabled tools (set by main.py)
13
+ _ENABLED_TOOLS = None
14
+
15
+ # Individual OAuth Scope Constants
16
+ USERINFO_EMAIL_SCOPE = "https://www.googleapis.com/auth/userinfo.email"
17
+ USERINFO_PROFILE_SCOPE = "https://www.googleapis.com/auth/userinfo.profile"
18
+ OPENID_SCOPE = "openid"
19
+ CALENDAR_SCOPE = "https://www.googleapis.com/auth/calendar"
20
+ CALENDAR_READONLY_SCOPE = "https://www.googleapis.com/auth/calendar.readonly"
21
+ CALENDAR_EVENTS_SCOPE = "https://www.googleapis.com/auth/calendar.events"
22
+
23
+ # Google Drive scopes
24
+ DRIVE_SCOPE = "https://www.googleapis.com/auth/drive"
25
+ DRIVE_READONLY_SCOPE = "https://www.googleapis.com/auth/drive.readonly"
26
+ DRIVE_FILE_SCOPE = "https://www.googleapis.com/auth/drive.file"
27
+
28
+ # Google Docs scopes
29
+ DOCS_READONLY_SCOPE = "https://www.googleapis.com/auth/documents.readonly"
30
+ DOCS_WRITE_SCOPE = "https://www.googleapis.com/auth/documents"
31
+
32
+ # Gmail API scopes
33
+ GMAIL_READONLY_SCOPE = "https://www.googleapis.com/auth/gmail.readonly"
34
+ GMAIL_SEND_SCOPE = "https://www.googleapis.com/auth/gmail.send"
35
+ GMAIL_COMPOSE_SCOPE = "https://www.googleapis.com/auth/gmail.compose"
36
+ GMAIL_MODIFY_SCOPE = "https://www.googleapis.com/auth/gmail.modify"
37
+ GMAIL_LABELS_SCOPE = "https://www.googleapis.com/auth/gmail.labels"
38
+ GMAIL_SETTINGS_BASIC_SCOPE = "https://www.googleapis.com/auth/gmail.settings.basic"
39
+
40
+ # Google Chat API scopes
41
+ CHAT_READONLY_SCOPE = "https://www.googleapis.com/auth/chat.messages.readonly"
42
+ CHAT_WRITE_SCOPE = "https://www.googleapis.com/auth/chat.messages"
43
+ CHAT_SPACES_SCOPE = "https://www.googleapis.com/auth/chat.spaces"
44
+ CHAT_SPACES_READONLY_SCOPE = "https://www.googleapis.com/auth/chat.spaces.readonly"
45
+ CHAT_MEMBERSHIPS_READONLY_SCOPE = (
46
+ "https://www.googleapis.com/auth/chat.memberships.readonly"
47
+ )
48
+
49
+ # Google Sheets API scopes
50
+ SHEETS_READONLY_SCOPE = "https://www.googleapis.com/auth/spreadsheets.readonly"
51
+ SHEETS_WRITE_SCOPE = "https://www.googleapis.com/auth/spreadsheets"
52
+
53
+ # Google Forms API scopes
54
+ FORMS_BODY_SCOPE = "https://www.googleapis.com/auth/forms.body"
55
+ FORMS_BODY_READONLY_SCOPE = "https://www.googleapis.com/auth/forms.body.readonly"
56
+ FORMS_RESPONSES_READONLY_SCOPE = (
57
+ "https://www.googleapis.com/auth/forms.responses.readonly"
58
+ )
59
+
60
+ # Google Slides API scopes
61
+ SLIDES_SCOPE = "https://www.googleapis.com/auth/presentations"
62
+ SLIDES_READONLY_SCOPE = "https://www.googleapis.com/auth/presentations.readonly"
63
+
64
+ # Google Tasks API scopes
65
+ TASKS_SCOPE = "https://www.googleapis.com/auth/tasks"
66
+ TASKS_READONLY_SCOPE = "https://www.googleapis.com/auth/tasks.readonly"
67
+
68
+ # Google Contacts (People API) scopes
69
+ CONTACTS_SCOPE = "https://www.googleapis.com/auth/contacts"
70
+ CONTACTS_READONLY_SCOPE = "https://www.googleapis.com/auth/contacts.readonly"
71
+ CONTACTS_OTHER_READONLY_SCOPE = (
72
+ "https://www.googleapis.com/auth/contacts.other.readonly"
73
+ )
74
+
75
+ # Google Custom Search API scope
76
+ CUSTOM_SEARCH_SCOPE = "https://www.googleapis.com/auth/cse"
77
+
78
+ # Google Apps Script API scopes
79
+ SCRIPT_PROJECTS_SCOPE = "https://www.googleapis.com/auth/script.projects"
80
+ SCRIPT_PROJECTS_READONLY_SCOPE = (
81
+ "https://www.googleapis.com/auth/script.projects.readonly"
82
+ )
83
+ SCRIPT_DEPLOYMENTS_SCOPE = "https://www.googleapis.com/auth/script.deployments"
84
+ SCRIPT_DEPLOYMENTS_READONLY_SCOPE = (
85
+ "https://www.googleapis.com/auth/script.deployments.readonly"
86
+ )
87
+ SCRIPT_PROCESSES_READONLY_SCOPE = "https://www.googleapis.com/auth/script.processes"
88
+ SCRIPT_METRICS_SCOPE = "https://www.googleapis.com/auth/script.metrics"
89
+ SCRIPT_EXTERNAL_REQUEST_SCOPE = (
90
+ "https://www.googleapis.com/auth/script.external_request"
91
+ )
92
+ SCRIPT_SCRIPTAPP_SCOPE = "https://www.googleapis.com/auth/script.scriptapp"
93
+
94
+ # Google scope hierarchy: broader scopes that implicitly cover narrower ones.
95
+ # See https://developers.google.com/gmail/api/auth/scopes,
96
+ # https://developers.google.com/drive/api/guides/api-specific-auth, etc.
97
+ SCOPE_HIERARCHY = {
98
+ GMAIL_MODIFY_SCOPE: {
99
+ GMAIL_READONLY_SCOPE,
100
+ GMAIL_SEND_SCOPE,
101
+ GMAIL_COMPOSE_SCOPE,
102
+ GMAIL_LABELS_SCOPE,
103
+ },
104
+ DRIVE_SCOPE: {DRIVE_READONLY_SCOPE, DRIVE_FILE_SCOPE},
105
+ CALENDAR_SCOPE: {CALENDAR_READONLY_SCOPE, CALENDAR_EVENTS_SCOPE},
106
+ DOCS_WRITE_SCOPE: {DOCS_READONLY_SCOPE},
107
+ SHEETS_WRITE_SCOPE: {SHEETS_READONLY_SCOPE},
108
+ SLIDES_SCOPE: {SLIDES_READONLY_SCOPE},
109
+ TASKS_SCOPE: {TASKS_READONLY_SCOPE},
110
+ CONTACTS_SCOPE: {CONTACTS_READONLY_SCOPE},
111
+ CHAT_WRITE_SCOPE: {CHAT_READONLY_SCOPE},
112
+ CHAT_SPACES_SCOPE: {CHAT_SPACES_READONLY_SCOPE},
113
+ FORMS_BODY_SCOPE: {FORMS_BODY_READONLY_SCOPE},
114
+ SCRIPT_PROJECTS_SCOPE: {SCRIPT_PROJECTS_READONLY_SCOPE},
115
+ SCRIPT_DEPLOYMENTS_SCOPE: {SCRIPT_DEPLOYMENTS_READONLY_SCOPE},
116
+ }
117
+
118
+
119
+ def has_required_scopes(available_scopes, required_scopes):
120
+ """
121
+ Check if available scopes satisfy all required scopes, accounting for
122
+ Google's scope hierarchy (e.g., gmail.modify covers gmail.readonly).
123
+
124
+ Args:
125
+ available_scopes: Scopes the credentials have (set, list, or frozenset).
126
+ required_scopes: Scopes that are required (set, list, or frozenset).
127
+
128
+ Returns:
129
+ True if all required scopes are satisfied.
130
+ """
131
+ available = set(available_scopes or [])
132
+ required = set(required_scopes or [])
133
+ # Expand available scopes with implied narrower scopes
134
+ expanded = set(available)
135
+ for broad_scope, covered in SCOPE_HIERARCHY.items():
136
+ if broad_scope in available:
137
+ expanded.update(covered)
138
+ return all(scope in expanded for scope in required)
139
+
140
+
141
+ # Base OAuth scopes required for user identification
142
+ BASE_SCOPES = [USERINFO_EMAIL_SCOPE, USERINFO_PROFILE_SCOPE, OPENID_SCOPE]
143
+
144
+ # Minimal scopes required to accept an MCP bearer token at the protocol layer.
145
+ PROTOCOL_AUTH_SCOPES = [USERINFO_EMAIL_SCOPE, OPENID_SCOPE]
146
+
147
+ # Service-specific scope groups
148
+ DOCS_SCOPES = [
149
+ DOCS_READONLY_SCOPE,
150
+ DOCS_WRITE_SCOPE,
151
+ DRIVE_READONLY_SCOPE,
152
+ DRIVE_FILE_SCOPE,
153
+ ]
154
+
155
+ CALENDAR_SCOPES = [CALENDAR_SCOPE, CALENDAR_READONLY_SCOPE, CALENDAR_EVENTS_SCOPE]
156
+
157
+ DRIVE_SCOPES = [DRIVE_SCOPE, DRIVE_READONLY_SCOPE, DRIVE_FILE_SCOPE]
158
+
159
+ GMAIL_SCOPES = [
160
+ GMAIL_READONLY_SCOPE,
161
+ GMAIL_SEND_SCOPE,
162
+ GMAIL_COMPOSE_SCOPE,
163
+ GMAIL_MODIFY_SCOPE,
164
+ GMAIL_LABELS_SCOPE,
165
+ GMAIL_SETTINGS_BASIC_SCOPE,
166
+ ]
167
+
168
+ CHAT_SCOPES = [
169
+ CHAT_READONLY_SCOPE,
170
+ CHAT_WRITE_SCOPE,
171
+ CHAT_SPACES_SCOPE,
172
+ CHAT_SPACES_READONLY_SCOPE,
173
+ CHAT_MEMBERSHIPS_READONLY_SCOPE, # Names DMs after their members
174
+ CONTACTS_READONLY_SCOPE, # Resolves sender and member names via People API
175
+ ]
176
+
177
+ SHEETS_SCOPES = [
178
+ SHEETS_READONLY_SCOPE,
179
+ SHEETS_WRITE_SCOPE,
180
+ DRIVE_READONLY_SCOPE,
181
+ DRIVE_FILE_SCOPE, # create_spreadsheet places new files in a folder
182
+ ]
183
+
184
+ FORMS_SCOPES = [
185
+ FORMS_BODY_SCOPE,
186
+ FORMS_BODY_READONLY_SCOPE,
187
+ FORMS_RESPONSES_READONLY_SCOPE,
188
+ ]
189
+
190
+ SLIDES_SCOPES = [SLIDES_SCOPE, SLIDES_READONLY_SCOPE]
191
+
192
+ TASKS_SCOPES = [TASKS_SCOPE, TASKS_READONLY_SCOPE]
193
+
194
+ CONTACTS_SCOPES = [
195
+ CONTACTS_SCOPE,
196
+ CONTACTS_READONLY_SCOPE,
197
+ CONTACTS_OTHER_READONLY_SCOPE,
198
+ ]
199
+
200
+ CUSTOM_SEARCH_SCOPES = [CUSTOM_SEARCH_SCOPE]
201
+
202
+ SCRIPT_SCOPES = [
203
+ SCRIPT_PROJECTS_SCOPE,
204
+ SCRIPT_PROJECTS_READONLY_SCOPE,
205
+ SCRIPT_DEPLOYMENTS_SCOPE,
206
+ SCRIPT_DEPLOYMENTS_READONLY_SCOPE,
207
+ SCRIPT_PROCESSES_READONLY_SCOPE, # Required for get_script_activity (processes)
208
+ SCRIPT_METRICS_SCOPE, # Required for get_script_activity (metrics)
209
+ SCRIPT_EXTERNAL_REQUEST_SCOPE, # Required for scripts.run (execution API)
210
+ SCRIPT_SCRIPTAPP_SCOPE, # Required for scripts.run (execution API)
211
+ DRIVE_SCOPE, # Required for manage_script_project delete (uses Drive API)
212
+ ]
213
+
214
+ # Tool-to-scopes mapping
215
+ TOOL_SCOPES_MAP = {
216
+ "gmail": GMAIL_SCOPES,
217
+ "drive": DRIVE_SCOPES,
218
+ "calendar": CALENDAR_SCOPES,
219
+ "docs": DOCS_SCOPES,
220
+ "sheets": SHEETS_SCOPES,
221
+ "chat": CHAT_SCOPES,
222
+ "forms": FORMS_SCOPES,
223
+ "slides": SLIDES_SCOPES,
224
+ "tasks": TASKS_SCOPES,
225
+ "contacts": CONTACTS_SCOPES,
226
+ "search": CUSTOM_SEARCH_SCOPES,
227
+ "appscript": SCRIPT_SCOPES,
228
+ }
229
+
230
+ # Tool-to-read-only-scopes mapping
231
+ TOOL_READONLY_SCOPES_MAP = {
232
+ "gmail": [GMAIL_READONLY_SCOPE],
233
+ "drive": [DRIVE_READONLY_SCOPE],
234
+ "calendar": [CALENDAR_READONLY_SCOPE],
235
+ "docs": [DOCS_READONLY_SCOPE, DRIVE_READONLY_SCOPE],
236
+ "sheets": [SHEETS_READONLY_SCOPE, DRIVE_READONLY_SCOPE],
237
+ "chat": [
238
+ CHAT_READONLY_SCOPE,
239
+ CHAT_SPACES_READONLY_SCOPE,
240
+ CHAT_MEMBERSHIPS_READONLY_SCOPE,
241
+ CONTACTS_READONLY_SCOPE,
242
+ ],
243
+ "forms": [FORMS_BODY_READONLY_SCOPE, FORMS_RESPONSES_READONLY_SCOPE],
244
+ "slides": [SLIDES_READONLY_SCOPE],
245
+ "tasks": [TASKS_READONLY_SCOPE],
246
+ "contacts": [CONTACTS_READONLY_SCOPE, CONTACTS_OTHER_READONLY_SCOPE],
247
+ "search": CUSTOM_SEARCH_SCOPES,
248
+ "appscript": [
249
+ SCRIPT_PROJECTS_READONLY_SCOPE,
250
+ SCRIPT_DEPLOYMENTS_READONLY_SCOPE,
251
+ SCRIPT_PROCESSES_READONLY_SCOPE,
252
+ SCRIPT_METRICS_SCOPE,
253
+ DRIVE_READONLY_SCOPE,
254
+ ],
255
+ }
256
+
257
+
258
+ def set_enabled_tools(enabled_tools):
259
+ """
260
+ Set the globally enabled tools list.
261
+
262
+ Args:
263
+ enabled_tools: List of enabled tool names.
264
+ """
265
+ global _ENABLED_TOOLS
266
+ _ENABLED_TOOLS = enabled_tools
267
+ # Debug level: the startup screen already reports the loaded service count.
268
+ logger.debug(f"Scope management active for {len(enabled_tools)} services")
269
+
270
+
271
+ # Global variable to store read-only mode (set by main.py)
272
+ _READ_ONLY_MODE = False
273
+
274
+
275
+ def set_read_only(enabled: bool):
276
+ """
277
+ Set the global read-only mode.
278
+
279
+ Args:
280
+ enabled: Boolean indicating if read-only mode should be enabled.
281
+ """
282
+ global _READ_ONLY_MODE
283
+ _READ_ONLY_MODE = enabled
284
+ # Debug level: the startup banner already flags read-only mode.
285
+ logger.debug(f"Read-only mode set to: {enabled}")
286
+
287
+
288
+ def is_read_only_mode() -> bool:
289
+ """Check if read-only mode is enabled."""
290
+ return _READ_ONLY_MODE
291
+
292
+
293
+ def get_all_read_only_scopes() -> list[str]:
294
+ """Get all possible read-only scopes across all tools."""
295
+ all_scopes = set(BASE_SCOPES)
296
+ for scopes in TOOL_READONLY_SCOPES_MAP.values():
297
+ all_scopes.update(scopes)
298
+ return list(all_scopes)
299
+
300
+
301
+ def get_current_scopes():
302
+ """
303
+ Returns scopes for currently enabled tools.
304
+ Uses globally set enabled tools or all tools if not set.
305
+
306
+ .. deprecated::
307
+ This function is a thin wrapper around get_scopes_for_tools() and exists
308
+ for backwards compatibility. Prefer using get_scopes_for_tools() directly
309
+ for new code, which allows explicit control over the tool list parameter.
310
+
311
+ Returns:
312
+ List of unique scopes for the enabled tools plus base scopes.
313
+ """
314
+ return get_scopes_for_tools(_ENABLED_TOOLS)
315
+
316
+
317
+ def get_scopes_for_tools(enabled_tools=None):
318
+ """
319
+ Returns scopes for enabled tools only.
320
+
321
+ Args:
322
+ enabled_tools: List of enabled tool names. If None, returns all scopes.
323
+
324
+ Returns:
325
+ List of unique scopes for the enabled tools plus base scopes.
326
+ """
327
+ # Granular permissions mode overrides both full and read-only scope maps.
328
+ # Lazy import with guard to avoid circular dependency during module init
329
+ # (SCOPES = get_scopes_for_tools() runs at import time before auth.permissions
330
+ # is fully loaded, but permissions mode is never active at that point).
331
+ try:
332
+ from auth.permissions import is_permissions_mode, get_all_permission_scopes
333
+
334
+ if is_permissions_mode():
335
+ scopes = BASE_SCOPES.copy()
336
+ scopes.extend(get_all_permission_scopes())
337
+ logger.debug(
338
+ "Generated scopes from granular permissions: %d unique scopes",
339
+ len(set(scopes)),
340
+ )
341
+ return list(set(scopes))
342
+ except ImportError:
343
+ pass
344
+
345
+ if enabled_tools is None:
346
+ # Default behavior - return all scopes
347
+ enabled_tools = TOOL_SCOPES_MAP.keys()
348
+
349
+ # Start with base scopes (always required)
350
+ scopes = BASE_SCOPES.copy()
351
+
352
+ # Determine which map to use based on read-only mode
353
+ scope_map = TOOL_READONLY_SCOPES_MAP if _READ_ONLY_MODE else TOOL_SCOPES_MAP
354
+ mode_str = "read-only" if _READ_ONLY_MODE else "full"
355
+
356
+ # Add scopes for each enabled tool
357
+ for tool in enabled_tools:
358
+ if tool in scope_map:
359
+ scopes.extend(scope_map[tool])
360
+
361
+ logger.debug(
362
+ f"Generated {mode_str} scopes for tools {list(enabled_tools)}: {len(set(scopes))} unique scopes"
363
+ )
364
+ # Return unique scopes
365
+ return list(set(scopes))
366
+
367
+
368
+ # Combined scopes for all supported Google Workspace operations (backwards compatibility)
369
+ SCOPES = get_scopes_for_tools()