@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.
Files changed (105) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +353 -2
  3. package/README.npm.md +28 -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
@@ -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)