@mutallip/google-workspace-mcp 0.0.0-stage → 2.8.0
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.
- package/LICENSE +21 -0
- package/README.md +353 -2
- package/README.npm.md +28 -0
- package/auth/__init__.py +1 -0
- package/auth/auth_info_middleware.py +419 -0
- package/auth/client_secrets.py +76 -0
- package/auth/credential_store.py +598 -0
- package/auth/external_oauth_provider.py +369 -0
- package/auth/gateway_identity.py +164 -0
- package/auth/google_auth.py +1550 -0
- package/auth/google_oauth_provider.py +20 -0
- package/auth/mcp_session_middleware.py +95 -0
- package/auth/oauth21_session_store.py +1332 -0
- package/auth/oauth_callback_server.py +466 -0
- package/auth/oauth_config.py +693 -0
- package/auth/oauth_proxy_config.py +122 -0
- package/auth/oauth_responses.py +230 -0
- package/auth/oauth_types.py +92 -0
- package/auth/permissions.py +330 -0
- package/auth/port_resolver.py +153 -0
- package/auth/request_identity.py +89 -0
- package/auth/scopes.py +369 -0
- package/auth/service_decorator.py +1109 -0
- package/bin/google-workspace-mcp.cjs +123 -0
- package/core/__init__.py +1 -0
- package/core/api_enablement.py +108 -0
- package/core/attachment_storage.py +496 -0
- package/core/camel_case_middleware.py +98 -0
- package/core/cli.py +161 -0
- package/core/comments.py +609 -0
- package/core/config.py +57 -0
- package/core/context.py +43 -0
- package/core/file_limits.py +632 -0
- package/core/gcs_attachment_storage.py +253 -0
- package/core/http_utils.py +339 -0
- package/core/log_formatter.py +270 -0
- package/core/portable_schema_middleware.py +67 -0
- package/core/server.py +1192 -0
- package/core/startup_ui.py +239 -0
- package/core/storage.py +23 -0
- package/core/telemetry.py +194 -0
- package/core/tool_descriptions.py +19 -0
- package/core/tool_registry.py +311 -0
- package/core/tool_tier_loader.py +197 -0
- package/core/tool_tiers.yaml +179 -0
- package/core/toolset_header_middleware.py +67 -0
- package/core/utils.py +1537 -0
- package/core/valkey_storage.py +271 -0
- package/core/warning_filters.py +19 -0
- package/fastmcp_server.py +198 -0
- package/gappsscript/README.md +512 -0
- package/gappsscript/TESTING.md +254 -0
- package/gappsscript/__init__.py +0 -0
- package/gappsscript/apps_script_tools.py +1940 -0
- package/gcalendar/__init__.py +1 -0
- package/gcalendar/calendar_helpers.py +1323 -0
- package/gcalendar/calendar_tools.py +2252 -0
- package/gchat/__init__.py +7 -0
- package/gchat/chat_helpers.py +410 -0
- package/gchat/chat_tools.py +798 -0
- package/gcontacts/__init__.py +1 -0
- package/gcontacts/contacts_helpers.py +765 -0
- package/gcontacts/contacts_tools.py +1685 -0
- package/gdocs/__init__.py +0 -0
- package/gdocs/docs_anchors.py +163 -0
- package/gdocs/docs_comments.py +89 -0
- package/gdocs/docs_helpers.py +2201 -0
- package/gdocs/docs_links.py +87 -0
- package/gdocs/docs_markdown.py +828 -0
- package/gdocs/docs_markdown_writer.py +592 -0
- package/gdocs/docs_plain_text.py +463 -0
- package/gdocs/docs_structure.py +621 -0
- package/gdocs/docs_tables.py +425 -0
- package/gdocs/docs_tools.py +3300 -0
- package/gdocs/managers/__init__.py +18 -0
- package/gdocs/managers/batch_operation_manager.py +1694 -0
- package/gdocs/managers/header_footer_manager.py +526 -0
- package/gdocs/managers/table_operation_manager.py +488 -0
- package/gdocs/managers/validation_manager.py +1504 -0
- package/gdocs/operation_schemas.py +594 -0
- package/gdrive/__init__.py +0 -0
- package/gdrive/drive_helpers.py +1738 -0
- package/gdrive/drive_tools.py +3085 -0
- package/gforms/__init__.py +3 -0
- package/gforms/forms_tools.py +575 -0
- package/gmail/__init__.py +1 -0
- package/gmail/gmail_helpers.py +2107 -0
- package/gmail/gmail_tools.py +4895 -0
- package/gmail/gmail_web_mime.py +441 -0
- package/gsearch/__init__.py +0 -0
- package/gsearch/search_tools.py +253 -0
- package/gsheets/__init__.py +31 -0
- package/gsheets/sheets_helpers.py +2236 -0
- package/gsheets/sheets_tools.py +3280 -0
- package/gslides/__init__.py +0 -0
- package/gslides/slides_digest.py +390 -0
- package/gslides/slides_helpers.py +392 -0
- package/gslides/slides_markup.py +770 -0
- package/gslides/slides_tools.py +376 -0
- package/gtasks/__init__.py +5 -0
- package/gtasks/tasks_tools.py +936 -0
- package/main.py +1170 -0
- package/package.json +43 -4
- package/pyproject.toml +173 -0
- package/uv.lock +2504 -0
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Tool Registry for Conditional Tool Registration
|
|
3
|
+
|
|
4
|
+
This module provides a registry system that allows tools to be conditionally registered
|
|
5
|
+
based on tier configuration, replacing direct @server.tool() decorators.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import logging
|
|
9
|
+
import os
|
|
10
|
+
import re
|
|
11
|
+
from typing import Callable, Iterable, Optional, Set
|
|
12
|
+
|
|
13
|
+
from fastmcp import FastMCP
|
|
14
|
+
|
|
15
|
+
from auth.oauth_config import is_oauth21_enabled
|
|
16
|
+
from auth.permissions import is_permissions_mode, get_allowed_scopes_set
|
|
17
|
+
from auth.scopes import is_read_only_mode, get_all_read_only_scopes
|
|
18
|
+
|
|
19
|
+
logger = logging.getLogger(__name__)
|
|
20
|
+
|
|
21
|
+
# Global registry of enabled tools
|
|
22
|
+
_enabled_tools: Optional[Set[str]] = None
|
|
23
|
+
|
|
24
|
+
# Tools explicitly blocked regardless of tier or permission selection
|
|
25
|
+
_disabled_tools: Set[str] = set()
|
|
26
|
+
|
|
27
|
+
_ALWAYS_LOAD_TOOLS_ENV = "WORKSPACE_MCP_ALWAYS_LOAD_TOOLS"
|
|
28
|
+
ALWAYS_LOAD_META_KEY = "anthropic/alwaysLoad"
|
|
29
|
+
_TOOL_NAME_RE = re.compile(r"[a-z0-9_]+")
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def set_enabled_tools(tool_names: Optional[Set[str]]):
|
|
33
|
+
"""Set the globally enabled tools."""
|
|
34
|
+
global _enabled_tools
|
|
35
|
+
_enabled_tools = tool_names
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def get_enabled_tools() -> Optional[Set[str]]:
|
|
39
|
+
"""Get the set of enabled tools, or None if all tools are enabled."""
|
|
40
|
+
return _enabled_tools
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def set_disabled_tools(tool_names: Set[str]):
|
|
44
|
+
"""Set the globally blocked tools."""
|
|
45
|
+
global _disabled_tools
|
|
46
|
+
_disabled_tools = tool_names
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def get_disabled_tools() -> Set[str]:
|
|
50
|
+
"""Get the set of explicitly blocked tools."""
|
|
51
|
+
return _disabled_tools
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _normalize_tool_names(names: Iterable[str]) -> Set[str]:
|
|
55
|
+
"""Return the non-blank names stripped and lowercased."""
|
|
56
|
+
return {name.strip().lower() for name in names if name.strip()}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def resolve_disabled_tools(cli_names: Optional[list[str]] = None) -> Set[str]:
|
|
60
|
+
"""Resolve the per-tool block list from CLI names, falling back to the env var.
|
|
61
|
+
|
|
62
|
+
Names are normalized to lowercase because tool names are lowercase snake_case.
|
|
63
|
+
|
|
64
|
+
Args:
|
|
65
|
+
cli_names: Tool names from --disabled-tools, or None to read the
|
|
66
|
+
WORKSPACE_MCP_DISABLED_TOOLS env var instead.
|
|
67
|
+
|
|
68
|
+
Returns:
|
|
69
|
+
The set of tool names to block, empty when nothing is configured.
|
|
70
|
+
"""
|
|
71
|
+
raw = (
|
|
72
|
+
cli_names
|
|
73
|
+
if cli_names
|
|
74
|
+
else os.getenv("WORKSPACE_MCP_DISABLED_TOOLS", "").split(",")
|
|
75
|
+
)
|
|
76
|
+
return _normalize_tool_names(raw)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def get_always_load_tools() -> Set[str]:
|
|
80
|
+
"""Parse WORKSPACE_MCP_ALWAYS_LOAD_TOOLS; ValueError on a malformed tool name."""
|
|
81
|
+
names = _normalize_tool_names(os.getenv(_ALWAYS_LOAD_TOOLS_ENV, "").split(","))
|
|
82
|
+
malformed = sorted(name for name in names if not _TOOL_NAME_RE.fullmatch(name))
|
|
83
|
+
if malformed:
|
|
84
|
+
raise ValueError(
|
|
85
|
+
f"{_ALWAYS_LOAD_TOOLS_ENV} must be a comma-separated list of tool names, "
|
|
86
|
+
f"got {malformed[0]!r}"
|
|
87
|
+
)
|
|
88
|
+
return names
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def is_tool_enabled(tool_name: str) -> bool:
|
|
92
|
+
"""Check if a specific tool is enabled."""
|
|
93
|
+
if _enabled_tools is None:
|
|
94
|
+
return True # All tools enabled by default
|
|
95
|
+
return tool_name in _enabled_tools
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def conditional_tool(server, tool_name: str):
|
|
99
|
+
"""
|
|
100
|
+
Decorator that conditionally registers a tool based on the enabled tools set.
|
|
101
|
+
|
|
102
|
+
Args:
|
|
103
|
+
server: The FastMCP server instance
|
|
104
|
+
tool_name: The name of the tool to register
|
|
105
|
+
|
|
106
|
+
Returns:
|
|
107
|
+
Either the registered tool decorator or a no-op decorator
|
|
108
|
+
"""
|
|
109
|
+
|
|
110
|
+
def decorator(func: Callable) -> Callable:
|
|
111
|
+
if is_tool_enabled(tool_name):
|
|
112
|
+
logger.debug(f"Registering tool: {tool_name}")
|
|
113
|
+
return server.tool()(func)
|
|
114
|
+
else:
|
|
115
|
+
logger.debug(f"Skipping tool registration: {tool_name}")
|
|
116
|
+
return func
|
|
117
|
+
|
|
118
|
+
return decorator
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def wrap_server_tool_method(server):
|
|
122
|
+
"""
|
|
123
|
+
Track tool registrations and filter them post-registration.
|
|
124
|
+
"""
|
|
125
|
+
original_tool = server.tool
|
|
126
|
+
server._tracked_tools = []
|
|
127
|
+
|
|
128
|
+
def tracking_tool(*args, **kwargs):
|
|
129
|
+
original_decorator = original_tool(*args, **kwargs)
|
|
130
|
+
|
|
131
|
+
def wrapper_decorator(func: Callable) -> Callable:
|
|
132
|
+
tool_name = func.__name__
|
|
133
|
+
server._tracked_tools.append(tool_name)
|
|
134
|
+
# Always apply the original decorator to register the tool
|
|
135
|
+
return original_decorator(func)
|
|
136
|
+
|
|
137
|
+
return wrapper_decorator
|
|
138
|
+
|
|
139
|
+
server.tool = tracking_tool
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def get_tool_components(server) -> dict:
|
|
143
|
+
"""Get tool components dict from server's local_provider.
|
|
144
|
+
|
|
145
|
+
Returns a dict mapping tool_name -> tool_object for introspection.
|
|
146
|
+
|
|
147
|
+
Note: Uses local_provider._components because the public list_tools()
|
|
148
|
+
is async-only, and callers (startup filtering, CLI) run synchronously.
|
|
149
|
+
"""
|
|
150
|
+
lp = getattr(server, "local_provider", None)
|
|
151
|
+
if lp is None:
|
|
152
|
+
return {}
|
|
153
|
+
components = getattr(lp, "_components", {})
|
|
154
|
+
tools = {}
|
|
155
|
+
for key, component in components.items():
|
|
156
|
+
if key.startswith("tool:"):
|
|
157
|
+
# Keys are like "tool:name@version", extract the name
|
|
158
|
+
name = key.split(":", 1)[1].rsplit("@", 1)[0]
|
|
159
|
+
tools[name] = component
|
|
160
|
+
return tools
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def filter_server_tools(server) -> int:
|
|
164
|
+
"""Remove disabled tools from the server after registration.
|
|
165
|
+
|
|
166
|
+
Returns the number of tools removed so callers can report it.
|
|
167
|
+
"""
|
|
168
|
+
enabled_tools = get_enabled_tools()
|
|
169
|
+
oauth21_enabled = is_oauth21_enabled()
|
|
170
|
+
permissions_mode = is_permissions_mode()
|
|
171
|
+
disabled_tools = get_disabled_tools()
|
|
172
|
+
if (
|
|
173
|
+
enabled_tools is None
|
|
174
|
+
and not oauth21_enabled
|
|
175
|
+
and not is_read_only_mode()
|
|
176
|
+
and not permissions_mode
|
|
177
|
+
and not disabled_tools
|
|
178
|
+
):
|
|
179
|
+
return 0
|
|
180
|
+
|
|
181
|
+
tools_removed = 0
|
|
182
|
+
tool_components = get_tool_components(server)
|
|
183
|
+
|
|
184
|
+
read_only_mode = is_read_only_mode()
|
|
185
|
+
allowed_scopes = set(get_all_read_only_scopes()) if read_only_mode else None
|
|
186
|
+
|
|
187
|
+
tools_to_remove = set()
|
|
188
|
+
|
|
189
|
+
# 1. Tier filtering
|
|
190
|
+
if enabled_tools is not None:
|
|
191
|
+
for tool_name in tool_components:
|
|
192
|
+
if not is_tool_enabled(tool_name):
|
|
193
|
+
tools_to_remove.add(tool_name)
|
|
194
|
+
|
|
195
|
+
# 2. OAuth 2.1 filtering
|
|
196
|
+
if oauth21_enabled and "start_google_auth" in tool_components:
|
|
197
|
+
tools_to_remove.add("start_google_auth")
|
|
198
|
+
logger.info("OAuth 2.1 enabled: disabling start_google_auth tool")
|
|
199
|
+
|
|
200
|
+
# 3. Read-only mode filtering (skipped when granular permissions are active)
|
|
201
|
+
if read_only_mode and not permissions_mode:
|
|
202
|
+
for tool_name, tool_obj in tool_components.items():
|
|
203
|
+
if tool_name in tools_to_remove:
|
|
204
|
+
continue
|
|
205
|
+
|
|
206
|
+
# Check if tool has required scopes attached (from @require_google_service)
|
|
207
|
+
func_to_check = tool_obj
|
|
208
|
+
if hasattr(tool_obj, "fn"):
|
|
209
|
+
func_to_check = tool_obj.fn
|
|
210
|
+
|
|
211
|
+
required_scopes = getattr(func_to_check, "_required_google_scopes", [])
|
|
212
|
+
|
|
213
|
+
if required_scopes:
|
|
214
|
+
# If ANY required scope is not in the allowed read-only scopes, disable the tool
|
|
215
|
+
if not all(scope in allowed_scopes for scope in required_scopes):
|
|
216
|
+
logger.debug(
|
|
217
|
+
f"Read-only mode: Disabling tool '{tool_name}' (requires write scopes: {required_scopes})"
|
|
218
|
+
)
|
|
219
|
+
tools_to_remove.add(tool_name)
|
|
220
|
+
|
|
221
|
+
# 4. Granular permissions filtering
|
|
222
|
+
# No scope hierarchy expansion here — permission levels are already cumulative
|
|
223
|
+
# and explicitly define allowed scopes. Hierarchy expansion would defeat the
|
|
224
|
+
# purpose (e.g. gmail.modify in the hierarchy covers gmail.send, but the
|
|
225
|
+
# "organize" permission level intentionally excludes gmail.send).
|
|
226
|
+
if permissions_mode:
|
|
227
|
+
perm_allowed = get_allowed_scopes_set() or set()
|
|
228
|
+
|
|
229
|
+
for tool_name, tool_obj in tool_components.items():
|
|
230
|
+
if tool_name in tools_to_remove:
|
|
231
|
+
continue
|
|
232
|
+
|
|
233
|
+
func_to_check = tool_obj
|
|
234
|
+
if hasattr(tool_obj, "fn"):
|
|
235
|
+
func_to_check = tool_obj.fn
|
|
236
|
+
|
|
237
|
+
required_scopes = getattr(func_to_check, "_required_google_scopes", [])
|
|
238
|
+
if required_scopes:
|
|
239
|
+
if not all(scope in perm_allowed for scope in required_scopes):
|
|
240
|
+
logger.debug(
|
|
241
|
+
"Permissions mode: Disabling tool '%s' (requires: %s)",
|
|
242
|
+
tool_name,
|
|
243
|
+
required_scopes,
|
|
244
|
+
)
|
|
245
|
+
tools_to_remove.add(tool_name)
|
|
246
|
+
|
|
247
|
+
# 5. Explicit per-tool block list (subtractive, so it wins over tier and
|
|
248
|
+
# permission selection). Unmatched entries only warn: a name is legitimately
|
|
249
|
+
# absent when its service was not loaded by --tools or --tool-tier.
|
|
250
|
+
for tool_name in sorted(disabled_tools):
|
|
251
|
+
if tool_name in tool_components:
|
|
252
|
+
logger.info("Block list: disabling tool '%s'", tool_name)
|
|
253
|
+
tools_to_remove.add(tool_name)
|
|
254
|
+
else:
|
|
255
|
+
logger.warning(
|
|
256
|
+
"Block list entry '%s' matches no registered tool - check spelling, "
|
|
257
|
+
"or its service may not be loaded by the current tool selection",
|
|
258
|
+
tool_name,
|
|
259
|
+
)
|
|
260
|
+
|
|
261
|
+
for tool_name in tools_to_remove:
|
|
262
|
+
try:
|
|
263
|
+
server.local_provider.remove_tool(tool_name)
|
|
264
|
+
except AttributeError:
|
|
265
|
+
logger.warning(
|
|
266
|
+
"Failed to remove tool '%s': remove_tool not available on server.local_provider",
|
|
267
|
+
tool_name,
|
|
268
|
+
)
|
|
269
|
+
continue
|
|
270
|
+
except Exception as exc:
|
|
271
|
+
logger.warning(
|
|
272
|
+
"Failed to remove tool '%s': %s",
|
|
273
|
+
tool_name,
|
|
274
|
+
exc,
|
|
275
|
+
)
|
|
276
|
+
continue
|
|
277
|
+
tools_removed += 1
|
|
278
|
+
|
|
279
|
+
if tools_removed > 0:
|
|
280
|
+
enabled_count = len(enabled_tools) if enabled_tools is not None else "all"
|
|
281
|
+
if permissions_mode:
|
|
282
|
+
mode = "Permissions"
|
|
283
|
+
elif is_read_only_mode():
|
|
284
|
+
mode = "Read-Only"
|
|
285
|
+
else:
|
|
286
|
+
mode = "Full"
|
|
287
|
+
# Debug level: main.py reports the filtered count on the startup screen.
|
|
288
|
+
logger.debug(
|
|
289
|
+
f"Tool filtering: removed {tools_removed} tools, {enabled_count} enabled. Mode: {mode}"
|
|
290
|
+
)
|
|
291
|
+
|
|
292
|
+
return tools_removed
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
def mark_always_load_tools(server: FastMCP) -> int:
|
|
296
|
+
"""Mark the WORKSPACE_MCP_ALWAYS_LOAD_TOOLS tools still registered; return the count."""
|
|
297
|
+
tool_components = get_tool_components(server)
|
|
298
|
+
marked = 0
|
|
299
|
+
for tool_name in sorted(get_always_load_tools()):
|
|
300
|
+
tool = tool_components.get(tool_name)
|
|
301
|
+
if tool is None:
|
|
302
|
+
logger.warning(
|
|
303
|
+
"Always-load entry '%s' matches no registered tool - check spelling, "
|
|
304
|
+
"or it may be filtered out by the current tool selection",
|
|
305
|
+
tool_name,
|
|
306
|
+
)
|
|
307
|
+
continue
|
|
308
|
+
tool.meta = {**(tool.meta or {}), ALWAYS_LOAD_META_KEY: True}
|
|
309
|
+
logger.info("Always-load: marking tool '%s'", tool_name)
|
|
310
|
+
marked += 1
|
|
311
|
+
return marked
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Tool Tier Loader Module
|
|
3
|
+
|
|
4
|
+
This module provides functionality to load and resolve tool tiers from the YAML configuration.
|
|
5
|
+
It integrates with the existing tool enablement workflow to support tiered tool loading.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import logging
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from typing import Dict, List, Set, Literal, Optional
|
|
11
|
+
|
|
12
|
+
import yaml
|
|
13
|
+
|
|
14
|
+
logger = logging.getLogger(__name__)
|
|
15
|
+
|
|
16
|
+
TierLevel = Literal["core", "extended", "complete"]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class ToolTierLoader:
|
|
20
|
+
"""Loads and manages tool tiers from configuration."""
|
|
21
|
+
|
|
22
|
+
def __init__(self, config_path: Optional[str] = None):
|
|
23
|
+
"""
|
|
24
|
+
Initialize the tool tier loader.
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
config_path: Path to the tool_tiers.yaml file. If None, uses default location.
|
|
28
|
+
"""
|
|
29
|
+
if config_path is None:
|
|
30
|
+
# Default to core/tool_tiers.yaml relative to this file
|
|
31
|
+
config_path = Path(__file__).parent / "tool_tiers.yaml"
|
|
32
|
+
|
|
33
|
+
self.config_path = Path(config_path)
|
|
34
|
+
self._tiers_config: Optional[Dict] = None
|
|
35
|
+
|
|
36
|
+
def _load_config(self) -> Dict:
|
|
37
|
+
"""Load the tool tiers configuration from YAML file."""
|
|
38
|
+
if self._tiers_config is not None:
|
|
39
|
+
return self._tiers_config
|
|
40
|
+
|
|
41
|
+
if not self.config_path.exists():
|
|
42
|
+
raise FileNotFoundError(
|
|
43
|
+
f"Tool tiers configuration not found: {self.config_path}"
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
try:
|
|
47
|
+
with open(self.config_path, "r", encoding="utf-8") as f:
|
|
48
|
+
self._tiers_config = yaml.safe_load(f)
|
|
49
|
+
logger.debug(f"Loaded tool tiers configuration from {self.config_path}")
|
|
50
|
+
return self._tiers_config
|
|
51
|
+
except yaml.YAMLError as e:
|
|
52
|
+
raise ValueError(f"Invalid YAML in tool tiers configuration: {e}")
|
|
53
|
+
except Exception as e:
|
|
54
|
+
raise RuntimeError(f"Failed to load tool tiers configuration: {e}")
|
|
55
|
+
|
|
56
|
+
def get_available_services(self) -> List[str]:
|
|
57
|
+
"""Get list of all available services defined in the configuration."""
|
|
58
|
+
config = self._load_config()
|
|
59
|
+
return list(config.keys())
|
|
60
|
+
|
|
61
|
+
def get_tools_for_tier(
|
|
62
|
+
self, tier: TierLevel, services: Optional[List[str]] = None
|
|
63
|
+
) -> List[str]:
|
|
64
|
+
"""
|
|
65
|
+
Get all tools for a specific tier level.
|
|
66
|
+
|
|
67
|
+
Args:
|
|
68
|
+
tier: The tier level (core, extended, complete)
|
|
69
|
+
services: Optional list of services to filter by. If None, includes all services.
|
|
70
|
+
|
|
71
|
+
Returns:
|
|
72
|
+
List of tool names for the specified tier level
|
|
73
|
+
"""
|
|
74
|
+
config = self._load_config()
|
|
75
|
+
tools = []
|
|
76
|
+
|
|
77
|
+
# If no services specified, use all available services
|
|
78
|
+
if services is None:
|
|
79
|
+
services = self.get_available_services()
|
|
80
|
+
|
|
81
|
+
for service in services:
|
|
82
|
+
if service not in config:
|
|
83
|
+
logger.warning(
|
|
84
|
+
f"Service '{service}' not found in tool tiers configuration"
|
|
85
|
+
)
|
|
86
|
+
continue
|
|
87
|
+
|
|
88
|
+
service_config = config[service]
|
|
89
|
+
if tier not in service_config:
|
|
90
|
+
logger.debug(f"Tier '{tier}' not defined for service '{service}'")
|
|
91
|
+
continue
|
|
92
|
+
|
|
93
|
+
tier_tools = service_config[tier]
|
|
94
|
+
if tier_tools: # Handle empty lists
|
|
95
|
+
tools.extend(tier_tools)
|
|
96
|
+
|
|
97
|
+
return tools
|
|
98
|
+
|
|
99
|
+
def get_tools_up_to_tier(
|
|
100
|
+
self, tier: TierLevel, services: Optional[List[str]] = None
|
|
101
|
+
) -> List[str]:
|
|
102
|
+
"""
|
|
103
|
+
Get all tools up to and including the specified tier level.
|
|
104
|
+
|
|
105
|
+
Args:
|
|
106
|
+
tier: The maximum tier level to include
|
|
107
|
+
services: Optional list of services to filter by. If None, includes all services.
|
|
108
|
+
|
|
109
|
+
Returns:
|
|
110
|
+
List of tool names up to the specified tier level
|
|
111
|
+
"""
|
|
112
|
+
tier_order = ["core", "extended", "complete"]
|
|
113
|
+
max_tier_index = tier_order.index(tier)
|
|
114
|
+
|
|
115
|
+
tools = []
|
|
116
|
+
for i in range(max_tier_index + 1):
|
|
117
|
+
current_tier = tier_order[i]
|
|
118
|
+
tools.extend(self.get_tools_for_tier(current_tier, services))
|
|
119
|
+
|
|
120
|
+
# Remove duplicates while preserving order
|
|
121
|
+
seen = set()
|
|
122
|
+
unique_tools = []
|
|
123
|
+
for tool in tools:
|
|
124
|
+
if tool not in seen:
|
|
125
|
+
seen.add(tool)
|
|
126
|
+
unique_tools.append(tool)
|
|
127
|
+
|
|
128
|
+
return unique_tools
|
|
129
|
+
|
|
130
|
+
def get_services_for_tools(self, tool_names: List[str]) -> Set[str]:
|
|
131
|
+
"""
|
|
132
|
+
Get the service names that provide the specified tools.
|
|
133
|
+
|
|
134
|
+
Args:
|
|
135
|
+
tool_names: List of tool names to lookup
|
|
136
|
+
|
|
137
|
+
Returns:
|
|
138
|
+
Set of service names that provide any of the specified tools
|
|
139
|
+
"""
|
|
140
|
+
config = self._load_config()
|
|
141
|
+
services = set()
|
|
142
|
+
|
|
143
|
+
for service, service_config in config.items():
|
|
144
|
+
for tier_name, tier_tools in service_config.items():
|
|
145
|
+
if tier_tools and any(tool in tier_tools for tool in tool_names):
|
|
146
|
+
services.add(service)
|
|
147
|
+
break
|
|
148
|
+
|
|
149
|
+
return services
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def get_tools_for_tier(
|
|
153
|
+
tier: TierLevel, services: Optional[List[str]] = None
|
|
154
|
+
) -> List[str]:
|
|
155
|
+
"""
|
|
156
|
+
Convenience function to get tools for a specific tier.
|
|
157
|
+
|
|
158
|
+
Args:
|
|
159
|
+
tier: The tier level (core, extended, complete)
|
|
160
|
+
services: Optional list of services to filter by
|
|
161
|
+
|
|
162
|
+
Returns:
|
|
163
|
+
List of tool names for the specified tier level
|
|
164
|
+
"""
|
|
165
|
+
loader = ToolTierLoader()
|
|
166
|
+
return loader.get_tools_up_to_tier(tier, services)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def resolve_tools_from_tier(
|
|
170
|
+
tier: TierLevel, services: Optional[List[str]] = None
|
|
171
|
+
) -> tuple[List[str], List[str]]:
|
|
172
|
+
"""
|
|
173
|
+
Resolve tool names and service names for the specified tier.
|
|
174
|
+
|
|
175
|
+
Args:
|
|
176
|
+
tier: The tier level (core, extended, complete)
|
|
177
|
+
services: Optional list of services to filter by
|
|
178
|
+
|
|
179
|
+
Returns:
|
|
180
|
+
Tuple of (tool_names, service_names) where:
|
|
181
|
+
- tool_names: List of specific tool names for the tier
|
|
182
|
+
- service_names: List of service names that should be imported
|
|
183
|
+
"""
|
|
184
|
+
loader = ToolTierLoader()
|
|
185
|
+
|
|
186
|
+
# Get all tools for the tier
|
|
187
|
+
tools = loader.get_tools_up_to_tier(tier, services)
|
|
188
|
+
|
|
189
|
+
# Map back to service names
|
|
190
|
+
service_names = loader.get_services_for_tools(tools)
|
|
191
|
+
|
|
192
|
+
# Debug level: the startup screen reports the tier, services and tool count.
|
|
193
|
+
logger.debug(
|
|
194
|
+
f"Tier '{tier}' resolved to {len(tools)} tools across {len(service_names)} services: {sorted(service_names)}"
|
|
195
|
+
)
|
|
196
|
+
|
|
197
|
+
return tools, sorted(service_names)
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
gmail:
|
|
2
|
+
core:
|
|
3
|
+
- search_gmail_messages
|
|
4
|
+
- get_gmail_message_content
|
|
5
|
+
- get_gmail_messages_content_batch
|
|
6
|
+
- send_gmail_message
|
|
7
|
+
|
|
8
|
+
extended:
|
|
9
|
+
- get_gmail_attachment_content
|
|
10
|
+
- get_gmail_thread_content
|
|
11
|
+
- modify_gmail_message_labels
|
|
12
|
+
- list_gmail_labels
|
|
13
|
+
- manage_gmail_label
|
|
14
|
+
- draft_gmail_message
|
|
15
|
+
- list_gmail_filters
|
|
16
|
+
- manage_gmail_filter
|
|
17
|
+
|
|
18
|
+
complete:
|
|
19
|
+
- get_gmail_threads_content_batch
|
|
20
|
+
- batch_modify_gmail_message_labels
|
|
21
|
+
- start_google_auth
|
|
22
|
+
|
|
23
|
+
drive:
|
|
24
|
+
core:
|
|
25
|
+
- search_drive_files
|
|
26
|
+
- get_drive_file_content
|
|
27
|
+
- get_drive_file_download_url
|
|
28
|
+
- create_drive_file
|
|
29
|
+
- create_drive_folder
|
|
30
|
+
- import_to_google_doc
|
|
31
|
+
- import_to_google_slides
|
|
32
|
+
- import_to_google_sheets
|
|
33
|
+
- get_drive_shareable_link
|
|
34
|
+
extended:
|
|
35
|
+
- list_drive_items
|
|
36
|
+
- copy_drive_file
|
|
37
|
+
- update_drive_file
|
|
38
|
+
- manage_drive_access
|
|
39
|
+
- set_drive_file_permissions
|
|
40
|
+
complete:
|
|
41
|
+
- get_drive_file_permissions
|
|
42
|
+
- check_drive_file_public_access
|
|
43
|
+
|
|
44
|
+
calendar:
|
|
45
|
+
core:
|
|
46
|
+
- list_calendars
|
|
47
|
+
- get_events
|
|
48
|
+
- manage_event
|
|
49
|
+
extended:
|
|
50
|
+
- manage_calendar
|
|
51
|
+
- query_freebusy
|
|
52
|
+
- manage_out_of_office
|
|
53
|
+
- manage_focus_time
|
|
54
|
+
complete: []
|
|
55
|
+
|
|
56
|
+
docs:
|
|
57
|
+
core:
|
|
58
|
+
- get_doc_content
|
|
59
|
+
- create_doc
|
|
60
|
+
- modify_doc_text
|
|
61
|
+
extended:
|
|
62
|
+
- export_doc_to_pdf
|
|
63
|
+
- search_docs
|
|
64
|
+
- find_and_replace_doc
|
|
65
|
+
- list_docs_in_folder
|
|
66
|
+
- insert_doc_elements
|
|
67
|
+
- update_paragraph_style
|
|
68
|
+
- get_doc_as_markdown
|
|
69
|
+
- list_document_comments
|
|
70
|
+
- manage_document_comment
|
|
71
|
+
complete:
|
|
72
|
+
- insert_doc_image
|
|
73
|
+
- update_doc_headers_footers
|
|
74
|
+
- batch_update_doc
|
|
75
|
+
- inspect_doc_structure
|
|
76
|
+
- create_table_with_data
|
|
77
|
+
- debug_table_structure
|
|
78
|
+
- manage_doc_tab
|
|
79
|
+
|
|
80
|
+
sheets:
|
|
81
|
+
core:
|
|
82
|
+
- create_spreadsheet
|
|
83
|
+
- read_sheet_values
|
|
84
|
+
- modify_sheet_values
|
|
85
|
+
extended:
|
|
86
|
+
- list_spreadsheets
|
|
87
|
+
- get_spreadsheet_info
|
|
88
|
+
- format_sheet_range
|
|
89
|
+
- list_sheet_tables
|
|
90
|
+
complete:
|
|
91
|
+
- create_sheet
|
|
92
|
+
- manage_sheet_tab
|
|
93
|
+
- append_table_rows
|
|
94
|
+
- resize_sheet_dimensions
|
|
95
|
+
- move_sheet_rows
|
|
96
|
+
- list_spreadsheet_comments
|
|
97
|
+
- manage_spreadsheet_comment
|
|
98
|
+
- manage_conditional_formatting
|
|
99
|
+
- manage_named_range
|
|
100
|
+
|
|
101
|
+
chat:
|
|
102
|
+
core:
|
|
103
|
+
- send_message
|
|
104
|
+
- get_messages
|
|
105
|
+
- search_messages
|
|
106
|
+
- create_reaction
|
|
107
|
+
extended:
|
|
108
|
+
- list_spaces
|
|
109
|
+
- download_chat_attachment
|
|
110
|
+
complete: []
|
|
111
|
+
|
|
112
|
+
forms:
|
|
113
|
+
core:
|
|
114
|
+
- create_form
|
|
115
|
+
- get_form
|
|
116
|
+
extended:
|
|
117
|
+
- list_form_responses
|
|
118
|
+
complete:
|
|
119
|
+
- set_publish_settings
|
|
120
|
+
- get_form_response
|
|
121
|
+
- batch_update_form
|
|
122
|
+
|
|
123
|
+
slides:
|
|
124
|
+
core:
|
|
125
|
+
- create_presentation
|
|
126
|
+
- get_presentation
|
|
127
|
+
extended:
|
|
128
|
+
- batch_update_presentation
|
|
129
|
+
- render_page_to_image
|
|
130
|
+
complete:
|
|
131
|
+
- list_presentation_comments
|
|
132
|
+
- manage_presentation_comment
|
|
133
|
+
|
|
134
|
+
tasks:
|
|
135
|
+
core:
|
|
136
|
+
- get_task
|
|
137
|
+
- list_tasks
|
|
138
|
+
- manage_task
|
|
139
|
+
extended: []
|
|
140
|
+
complete:
|
|
141
|
+
- list_task_lists
|
|
142
|
+
- get_task_list
|
|
143
|
+
- manage_task_list
|
|
144
|
+
|
|
145
|
+
contacts:
|
|
146
|
+
core:
|
|
147
|
+
- search_contacts
|
|
148
|
+
- get_contact
|
|
149
|
+
- list_contacts
|
|
150
|
+
- manage_contact
|
|
151
|
+
extended:
|
|
152
|
+
- list_contact_groups
|
|
153
|
+
- get_contact_group
|
|
154
|
+
complete:
|
|
155
|
+
- manage_contacts_batch
|
|
156
|
+
- manage_contact_group
|
|
157
|
+
|
|
158
|
+
search:
|
|
159
|
+
core:
|
|
160
|
+
- search_custom
|
|
161
|
+
extended: []
|
|
162
|
+
complete:
|
|
163
|
+
- get_search_engine_info
|
|
164
|
+
|
|
165
|
+
appscript:
|
|
166
|
+
core:
|
|
167
|
+
- get_script_project
|
|
168
|
+
- manage_script_project
|
|
169
|
+
- manage_script_content
|
|
170
|
+
- run_script_function
|
|
171
|
+
- generate_trigger_code
|
|
172
|
+
extended:
|
|
173
|
+
- list_script_deployments
|
|
174
|
+
- manage_deployment
|
|
175
|
+
- get_script_version
|
|
176
|
+
- manage_script_version
|
|
177
|
+
- get_script_activity
|
|
178
|
+
- manage_script_trigger
|
|
179
|
+
complete: []
|