@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,87 @@
|
|
|
1
|
+
"""Shared Google Docs link-target resolution.
|
|
2
|
+
|
|
3
|
+
The Docs API represents external and internal links with different fields. Keep
|
|
4
|
+
that API interpretation separate from output-format-specific rendering so the
|
|
5
|
+
plain-text and Markdown readers agree about which target a link refers to.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from dataclasses import dataclass
|
|
11
|
+
from typing import Any, Literal
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
LinkTargetKind = Literal["url", "heading", "bookmark", "tab", "unknown"]
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@dataclass(frozen=True)
|
|
18
|
+
class LinkTarget:
|
|
19
|
+
"""A normalized link target returned by the Google Docs API."""
|
|
20
|
+
|
|
21
|
+
kind: LinkTargetKind
|
|
22
|
+
value: str | None = None
|
|
23
|
+
tab_id: str | None = None
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def resolve_link_target(link: dict[str, Any] | None) -> LinkTarget | None:
|
|
27
|
+
"""Resolve a Docs API link in URL, heading, bookmark, tab order.
|
|
28
|
+
|
|
29
|
+
``headingId`` and ``bookmarkId`` are legacy forms of the newer nested
|
|
30
|
+
``heading`` and ``bookmark`` targets. Empty link styles are not links;
|
|
31
|
+
non-empty shapes without a recognized target are retained as ``unknown``.
|
|
32
|
+
"""
|
|
33
|
+
if not link:
|
|
34
|
+
return None
|
|
35
|
+
|
|
36
|
+
url = link.get("url")
|
|
37
|
+
if url:
|
|
38
|
+
return LinkTarget("url", str(url))
|
|
39
|
+
|
|
40
|
+
heading = link.get("heading")
|
|
41
|
+
heading_id, heading_tab_id = _internal_target_values(heading)
|
|
42
|
+
if not heading_id:
|
|
43
|
+
heading_id = _as_string(link.get("headingId"))
|
|
44
|
+
heading_tab_id = heading_tab_id or _as_string(link.get("tabId"))
|
|
45
|
+
if heading_id:
|
|
46
|
+
return LinkTarget("heading", heading_id, heading_tab_id)
|
|
47
|
+
|
|
48
|
+
bookmark = link.get("bookmark")
|
|
49
|
+
bookmark_id, bookmark_tab_id = _internal_target_values(bookmark)
|
|
50
|
+
if not bookmark_id:
|
|
51
|
+
bookmark_id = _as_string(link.get("bookmarkId"))
|
|
52
|
+
bookmark_tab_id = bookmark_tab_id or _as_string(link.get("tabId"))
|
|
53
|
+
if bookmark_id:
|
|
54
|
+
return LinkTarget("bookmark", bookmark_id, bookmark_tab_id)
|
|
55
|
+
|
|
56
|
+
tab_id = _as_string(link.get("tabId"))
|
|
57
|
+
if tab_id:
|
|
58
|
+
return LinkTarget("tab", tab_id)
|
|
59
|
+
|
|
60
|
+
return LinkTarget("unknown")
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def text_run_link(elements: list[dict[str, Any]], index: int) -> dict[str, Any] | None:
|
|
64
|
+
"""Return the link of the paragraph element at ``index`` if it is a text run.
|
|
65
|
+
|
|
66
|
+
Style changes split one link into several runs, so renderers compare
|
|
67
|
+
neighboring runs to annotate a link once rather than once per run.
|
|
68
|
+
"""
|
|
69
|
+
if 0 <= index < len(elements):
|
|
70
|
+
return elements[index].get("textRun", {}).get("textStyle", {}).get("link")
|
|
71
|
+
return None
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _internal_target_values(target: Any) -> tuple[str | None, str | None]:
|
|
75
|
+
"""Extract a target ID and optional tab from scalar or nested API fields."""
|
|
76
|
+
if isinstance(target, dict):
|
|
77
|
+
target_id = _as_string(target.get("id"))
|
|
78
|
+
tab_id = _as_string(target.get("tabId"))
|
|
79
|
+
return target_id, tab_id
|
|
80
|
+
return _as_string(target), None
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def _as_string(value: Any) -> str | None:
|
|
84
|
+
"""Normalize a populated API identifier while treating empty values as absent."""
|
|
85
|
+
if value is None or value == "":
|
|
86
|
+
return None
|
|
87
|
+
return str(value)
|