workspace-mcp 1.0.2__py3-none-any.whl → 1.0.3__py3-none-any.whl
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.
- auth/google_auth.py +120 -12
- auth/oauth_callback_server.py +7 -3
- core/context.py +22 -0
- core/server.py +5 -7
- gdocs/docs_tools.py +178 -0
- {workspace_mcp-1.0.2.dist-info → workspace_mcp-1.0.3.dist-info}/METADATA +57 -8
- {workspace_mcp-1.0.2.dist-info → workspace_mcp-1.0.3.dist-info}/RECORD +11 -10
- {workspace_mcp-1.0.2.dist-info → workspace_mcp-1.0.3.dist-info}/WHEEL +0 -0
- {workspace_mcp-1.0.2.dist-info → workspace_mcp-1.0.3.dist-info}/entry_points.txt +0 -0
- {workspace_mcp-1.0.2.dist-info → workspace_mcp-1.0.3.dist-info}/licenses/LICENSE +0 -0
- {workspace_mcp-1.0.2.dist-info → workspace_mcp-1.0.3.dist-info}/top_level.txt +0 -0
auth/google_auth.py
CHANGED
@@ -27,7 +27,7 @@ DEFAULT_CREDENTIALS_DIR = ".credentials"
|
|
27
27
|
# This should be more robust in a production system once OAuth2.1 is implemented in client.
|
28
28
|
_SESSION_CREDENTIALS_CACHE: Dict[str, Credentials] = {}
|
29
29
|
# Centralized Client Secrets Path Logic
|
30
|
-
_client_secrets_env = os.getenv("GOOGLE_CLIENT_SECRETS")
|
30
|
+
_client_secrets_env = os.getenv("GOOGLE_CLIENT_SECRET_PATH") or os.getenv("GOOGLE_CLIENT_SECRETS")
|
31
31
|
if _client_secrets_env:
|
32
32
|
CONFIG_CLIENT_SECRETS_PATH = _client_secrets_env
|
33
33
|
else:
|
@@ -151,22 +151,128 @@ def load_credentials_from_session(session_id: str) -> Optional[Credentials]:
|
|
151
151
|
logger.debug(f"No credentials found in session cache for session_id: {session_id}")
|
152
152
|
return credentials
|
153
153
|
|
154
|
+
def load_client_secrets_from_env() -> Optional[Dict[str, Any]]:
|
155
|
+
"""
|
156
|
+
Loads the client secrets from environment variables.
|
157
|
+
|
158
|
+
Environment variables used:
|
159
|
+
- GOOGLE_OAUTH_CLIENT_ID: OAuth 2.0 client ID
|
160
|
+
- GOOGLE_OAUTH_CLIENT_SECRET: OAuth 2.0 client secret
|
161
|
+
- GOOGLE_OAUTH_REDIRECT_URI: (optional) OAuth redirect URI
|
162
|
+
|
163
|
+
Returns:
|
164
|
+
Client secrets configuration dict compatible with Google OAuth library,
|
165
|
+
or None if required environment variables are not set.
|
166
|
+
"""
|
167
|
+
client_id = os.getenv("GOOGLE_OAUTH_CLIENT_ID")
|
168
|
+
client_secret = os.getenv("GOOGLE_OAUTH_CLIENT_SECRET")
|
169
|
+
redirect_uri = os.getenv("GOOGLE_OAUTH_REDIRECT_URI")
|
170
|
+
|
171
|
+
if client_id and client_secret:
|
172
|
+
# Create config structure that matches Google client secrets format
|
173
|
+
web_config = {
|
174
|
+
"client_id": client_id,
|
175
|
+
"client_secret": client_secret,
|
176
|
+
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
177
|
+
"token_uri": "https://oauth2.googleapis.com/token",
|
178
|
+
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs"
|
179
|
+
}
|
180
|
+
|
181
|
+
# Add redirect_uri if provided via environment variable
|
182
|
+
if redirect_uri:
|
183
|
+
web_config["redirect_uris"] = [redirect_uri]
|
184
|
+
|
185
|
+
# Return the full config structure expected by Google OAuth library
|
186
|
+
config = {"web": web_config}
|
187
|
+
|
188
|
+
logger.info("Loaded OAuth client credentials from environment variables")
|
189
|
+
return config
|
190
|
+
|
191
|
+
logger.debug("OAuth client credentials not found in environment variables")
|
192
|
+
return None
|
193
|
+
|
154
194
|
def load_client_secrets(client_secrets_path: str) -> Dict[str, Any]:
|
155
|
-
"""
|
195
|
+
"""
|
196
|
+
Loads the client secrets from environment variables (preferred) or from the client secrets file.
|
197
|
+
|
198
|
+
Priority order:
|
199
|
+
1. Environment variables (GOOGLE_OAUTH_CLIENT_ID, GOOGLE_OAUTH_CLIENT_SECRET)
|
200
|
+
2. File-based credentials at the specified path
|
201
|
+
|
202
|
+
Args:
|
203
|
+
client_secrets_path: Path to the client secrets JSON file (used as fallback)
|
204
|
+
|
205
|
+
Returns:
|
206
|
+
Client secrets configuration dict
|
207
|
+
|
208
|
+
Raises:
|
209
|
+
ValueError: If client secrets file has invalid format
|
210
|
+
IOError: If file cannot be read and no environment variables are set
|
211
|
+
"""
|
212
|
+
# First, try to load from environment variables
|
213
|
+
env_config = load_client_secrets_from_env()
|
214
|
+
if env_config:
|
215
|
+
# Extract the "web" config from the environment structure
|
216
|
+
return env_config["web"]
|
217
|
+
|
218
|
+
# Fall back to loading from file
|
156
219
|
try:
|
157
220
|
with open(client_secrets_path, 'r') as f:
|
158
221
|
client_config = json.load(f)
|
159
222
|
# The file usually contains a top-level key like "web" or "installed"
|
160
223
|
if "web" in client_config:
|
224
|
+
logger.info(f"Loaded OAuth client credentials from file: {client_secrets_path}")
|
161
225
|
return client_config["web"]
|
162
226
|
elif "installed" in client_config:
|
163
|
-
|
227
|
+
logger.info(f"Loaded OAuth client credentials from file: {client_secrets_path}")
|
228
|
+
return client_config["installed"]
|
164
229
|
else:
|
165
230
|
logger.error(f"Client secrets file {client_secrets_path} has unexpected format.")
|
166
231
|
raise ValueError("Invalid client secrets file format")
|
167
232
|
except (IOError, json.JSONDecodeError) as e:
|
168
233
|
logger.error(f"Error loading client secrets file {client_secrets_path}: {e}")
|
169
234
|
raise
|
235
|
+
def check_client_secrets() -> Optional[str]:
|
236
|
+
"""
|
237
|
+
Checks for the presence of OAuth client secrets, either as environment
|
238
|
+
variables or as a file.
|
239
|
+
|
240
|
+
Returns:
|
241
|
+
An error message string if secrets are not found, otherwise None.
|
242
|
+
"""
|
243
|
+
env_config = load_client_secrets_from_env()
|
244
|
+
if not env_config and not os.path.exists(CONFIG_CLIENT_SECRETS_PATH):
|
245
|
+
logger.error(f"OAuth client credentials not found. No environment variables set and no file at {CONFIG_CLIENT_SECRETS_PATH}")
|
246
|
+
return f"OAuth client credentials not found. Please set GOOGLE_OAUTH_CLIENT_ID and GOOGLE_OAUTH_CLIENT_SECRET environment variables or provide a client secrets file at {CONFIG_CLIENT_SECRETS_PATH}."
|
247
|
+
return None
|
248
|
+
|
249
|
+
def create_oauth_flow(scopes: List[str], redirect_uri: str, state: Optional[str] = None) -> Flow:
|
250
|
+
"""Creates an OAuth flow using environment variables or client secrets file."""
|
251
|
+
# Try environment variables first
|
252
|
+
env_config = load_client_secrets_from_env()
|
253
|
+
if env_config:
|
254
|
+
# Use client config directly
|
255
|
+
flow = Flow.from_client_config(
|
256
|
+
env_config,
|
257
|
+
scopes=scopes,
|
258
|
+
redirect_uri=redirect_uri,
|
259
|
+
state=state
|
260
|
+
)
|
261
|
+
logger.debug("Created OAuth flow from environment variables")
|
262
|
+
return flow
|
263
|
+
|
264
|
+
# Fall back to file-based config
|
265
|
+
if not os.path.exists(CONFIG_CLIENT_SECRETS_PATH):
|
266
|
+
raise FileNotFoundError(f"OAuth client secrets file not found at {CONFIG_CLIENT_SECRETS_PATH} and no environment variables set")
|
267
|
+
|
268
|
+
flow = Flow.from_client_secrets_file(
|
269
|
+
CONFIG_CLIENT_SECRETS_PATH,
|
270
|
+
scopes=scopes,
|
271
|
+
redirect_uri=redirect_uri,
|
272
|
+
state=state
|
273
|
+
)
|
274
|
+
logger.debug(f"Created OAuth flow from client secrets file: {CONFIG_CLIENT_SECRETS_PATH}")
|
275
|
+
return flow
|
170
276
|
|
171
277
|
# --- Core OAuth Logic ---
|
172
278
|
|
@@ -206,8 +312,7 @@ async def start_auth_flow(
|
|
206
312
|
OAUTH_STATE_TO_SESSION_ID_MAP[oauth_state] = mcp_session_id
|
207
313
|
logger.info(f"[start_auth_flow] Stored mcp_session_id '{mcp_session_id}' for oauth_state '{oauth_state}'.")
|
208
314
|
|
209
|
-
flow =
|
210
|
-
CONFIG_CLIENT_SECRETS_PATH, # Use module constant
|
315
|
+
flow = create_oauth_flow(
|
211
316
|
scopes=SCOPES, # Use global SCOPES
|
212
317
|
redirect_uri=redirect_uri, # Use passed redirect_uri
|
213
318
|
state=oauth_state
|
@@ -240,7 +345,7 @@ async def start_auth_flow(
|
|
240
345
|
return "\n".join(message_lines)
|
241
346
|
|
242
347
|
except FileNotFoundError as e:
|
243
|
-
error_text = f"OAuth client
|
348
|
+
error_text = f"OAuth client credentials not found: {e}. Please either:\n1. Set environment variables: GOOGLE_OAUTH_CLIENT_ID and GOOGLE_OAUTH_CLIENT_SECRET\n2. Ensure '{CONFIG_CLIENT_SECRETS_PATH}' file exists"
|
244
349
|
logger.error(error_text, exc_info=True)
|
245
350
|
raise Exception(error_text)
|
246
351
|
except Exception as e:
|
@@ -249,12 +354,12 @@ async def start_auth_flow(
|
|
249
354
|
raise Exception(error_text)
|
250
355
|
|
251
356
|
def handle_auth_callback(
|
252
|
-
client_secrets_path: str,
|
253
357
|
scopes: List[str],
|
254
358
|
authorization_response: str,
|
255
|
-
redirect_uri: str,
|
359
|
+
redirect_uri: str,
|
256
360
|
credentials_base_dir: str = DEFAULT_CREDENTIALS_DIR,
|
257
|
-
session_id: Optional[str] = None
|
361
|
+
session_id: Optional[str] = None,
|
362
|
+
client_secrets_path: Optional[str] = None # Deprecated: kept for backward compatibility
|
258
363
|
) -> Tuple[str, Credentials]:
|
259
364
|
"""
|
260
365
|
Handles the callback from Google, exchanges the code for credentials,
|
@@ -262,12 +367,12 @@ def handle_auth_callback(
|
|
262
367
|
and returns them.
|
263
368
|
|
264
369
|
Args:
|
265
|
-
client_secrets_path: Path to the Google client secrets JSON file.
|
266
370
|
scopes: List of OAuth scopes requested.
|
267
371
|
authorization_response: The full callback URL from Google.
|
268
372
|
redirect_uri: The redirect URI.
|
269
373
|
credentials_base_dir: Base directory for credential files.
|
270
374
|
session_id: Optional MCP session ID to associate with the credentials.
|
375
|
+
client_secrets_path: (Deprecated) Path to client secrets file. Ignored if environment variables are set.
|
271
376
|
|
272
377
|
Returns:
|
273
378
|
A tuple containing the user_google_email and the obtained Credentials object.
|
@@ -278,13 +383,16 @@ def handle_auth_callback(
|
|
278
383
|
HttpError: If fetching user info fails.
|
279
384
|
"""
|
280
385
|
try:
|
386
|
+
# Log deprecation warning if old parameter is used
|
387
|
+
if client_secrets_path:
|
388
|
+
logger.warning("The 'client_secrets_path' parameter is deprecated. Use GOOGLE_OAUTH_CLIENT_ID and GOOGLE_OAUTH_CLIENT_SECRET environment variables instead.")
|
389
|
+
|
281
390
|
# Allow HTTP for localhost in development
|
282
391
|
if 'OAUTHLIB_INSECURE_TRANSPORT' not in os.environ:
|
283
392
|
logger.warning("OAUTHLIB_INSECURE_TRANSPORT not set. Setting it for localhost development.")
|
284
393
|
os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1'
|
285
394
|
|
286
|
-
flow =
|
287
|
-
client_secrets_path,
|
395
|
+
flow = create_oauth_flow(
|
288
396
|
scopes=scopes,
|
289
397
|
redirect_uri=redirect_uri
|
290
398
|
)
|
auth/oauth_callback_server.py
CHANGED
@@ -15,7 +15,7 @@ import socket
|
|
15
15
|
from fastapi import FastAPI, Request
|
16
16
|
import uvicorn
|
17
17
|
|
18
|
-
from auth.google_auth import handle_auth_callback,
|
18
|
+
from auth.google_auth import handle_auth_callback, check_client_secrets
|
19
19
|
from auth.scopes import OAUTH_STATE_TO_SESSION_ID_MAP, SCOPES
|
20
20
|
from auth.oauth_responses import create_error_response, create_success_response, create_server_error_response
|
21
21
|
|
@@ -59,6 +59,11 @@ class MinimalOAuthServer:
|
|
59
59
|
return create_error_response(error_message)
|
60
60
|
|
61
61
|
try:
|
62
|
+
# Check if we have credentials available (environment variables or file)
|
63
|
+
error_message = check_client_secrets()
|
64
|
+
if error_message:
|
65
|
+
return create_server_error_response(error_message)
|
66
|
+
|
62
67
|
logger.info(f"OAuth callback: Received code (state: {state}). Attempting to exchange for tokens.")
|
63
68
|
|
64
69
|
mcp_session_id: Optional[str] = OAUTH_STATE_TO_SESSION_ID_MAP.pop(state, None)
|
@@ -69,7 +74,6 @@ class MinimalOAuthServer:
|
|
69
74
|
|
70
75
|
# Exchange code for credentials
|
71
76
|
verified_user_id, credentials = handle_auth_callback(
|
72
|
-
client_secrets_path=CONFIG_CLIENT_SECRETS_PATH,
|
73
77
|
scopes=SCOPES,
|
74
78
|
authorization_response=str(request.url),
|
75
79
|
redirect_uri=f"{self.base_uri}:{self.port}/oauth2callback",
|
@@ -106,7 +110,7 @@ class MinimalOAuthServer:
|
|
106
110
|
hostname = parsed_uri.hostname or 'localhost'
|
107
111
|
except Exception:
|
108
112
|
hostname = 'localhost'
|
109
|
-
|
113
|
+
|
110
114
|
try:
|
111
115
|
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
112
116
|
s.bind((hostname, self.port))
|
core/context.py
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# core/context.py
|
2
|
+
import contextvars
|
3
|
+
from typing import Optional
|
4
|
+
|
5
|
+
# Context variable to hold injected credentials for the life of a single request.
|
6
|
+
_injected_oauth_credentials = contextvars.ContextVar(
|
7
|
+
"injected_oauth_credentials", default=None
|
8
|
+
)
|
9
|
+
|
10
|
+
def get_injected_oauth_credentials():
|
11
|
+
"""
|
12
|
+
Retrieve injected OAuth credentials for the current request context.
|
13
|
+
This is called by the authentication layer to check for request-scoped credentials.
|
14
|
+
"""
|
15
|
+
return _injected_oauth_credentials.get()
|
16
|
+
|
17
|
+
def set_injected_oauth_credentials(credentials: Optional[dict]):
|
18
|
+
"""
|
19
|
+
Set or clear the injected OAuth credentials for the current request context.
|
20
|
+
This is called by the service decorator.
|
21
|
+
"""
|
22
|
+
_injected_oauth_credentials.set(credentials)
|
core/server.py
CHANGED
@@ -11,7 +11,7 @@ from mcp import types
|
|
11
11
|
from mcp.server.fastmcp import FastMCP
|
12
12
|
from starlette.requests import Request
|
13
13
|
|
14
|
-
from auth.google_auth import handle_auth_callback, start_auth_flow,
|
14
|
+
from auth.google_auth import handle_auth_callback, start_auth_flow, check_client_secrets
|
15
15
|
from auth.oauth_callback_server import get_oauth_redirect_uri, ensure_oauth_callback_available
|
16
16
|
from auth.oauth_responses import create_error_response, create_success_response, create_server_error_response
|
17
17
|
|
@@ -119,11 +119,10 @@ async def oauth2_callback(request: Request) -> HTMLResponse:
|
|
119
119
|
return create_error_response(error_message)
|
120
120
|
|
121
121
|
try:
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
return HTMLResponse(content="Server Configuration Error: Client secrets not found.", status_code=500)
|
122
|
+
# Check if we have credentials available (environment variables or file)
|
123
|
+
error_message = check_client_secrets()
|
124
|
+
if error_message:
|
125
|
+
return create_server_error_response(error_message)
|
127
126
|
|
128
127
|
logger.info(f"OAuth callback: Received code (state: {state}). Attempting to exchange for tokens.")
|
129
128
|
|
@@ -136,7 +135,6 @@ async def oauth2_callback(request: Request) -> HTMLResponse:
|
|
136
135
|
# Exchange code for credentials. handle_auth_callback will save them.
|
137
136
|
# The user_id returned here is the Google-verified email.
|
138
137
|
verified_user_id, credentials = handle_auth_callback(
|
139
|
-
client_secrets_path=client_secrets_path,
|
140
138
|
scopes=SCOPES, # Ensure all necessary scopes are requested
|
141
139
|
authorization_response=str(request.url),
|
142
140
|
redirect_uri=get_oauth_redirect_uri_for_current_mode(),
|
gdocs/docs_tools.py
CHANGED
@@ -214,3 +214,181 @@ async def create_doc(
|
|
214
214
|
msg = f"Created Google Doc '{title}' (ID: {doc_id}) for {user_google_email}. Link: {link}"
|
215
215
|
logger.info(f"Successfully created Google Doc '{title}' (ID: {doc_id}) for {user_google_email}. Link: {link}")
|
216
216
|
return msg
|
217
|
+
|
218
|
+
|
219
|
+
@server.tool()
|
220
|
+
@require_google_service("drive", "drive_read")
|
221
|
+
@handle_http_errors("read_doc_comments")
|
222
|
+
async def read_doc_comments(
|
223
|
+
service,
|
224
|
+
user_google_email: str,
|
225
|
+
document_id: str,
|
226
|
+
) -> str:
|
227
|
+
"""
|
228
|
+
Read all comments from a Google Doc.
|
229
|
+
|
230
|
+
Args:
|
231
|
+
document_id: The ID of the Google Document
|
232
|
+
|
233
|
+
Returns:
|
234
|
+
str: A formatted list of all comments and replies in the document.
|
235
|
+
"""
|
236
|
+
logger.info(f"[read_doc_comments] Reading comments for document {document_id}")
|
237
|
+
|
238
|
+
response = await asyncio.to_thread(
|
239
|
+
service.comments().list(
|
240
|
+
fileId=document_id,
|
241
|
+
fields="comments(id,content,author,createdTime,modifiedTime,resolved,replies(content,author,id,createdTime,modifiedTime))"
|
242
|
+
).execute
|
243
|
+
)
|
244
|
+
|
245
|
+
comments = response.get('comments', [])
|
246
|
+
|
247
|
+
if not comments:
|
248
|
+
return f"No comments found in document {document_id}"
|
249
|
+
|
250
|
+
output = [f"Found {len(comments)} comments in document {document_id}:\n"]
|
251
|
+
|
252
|
+
for comment in comments:
|
253
|
+
author = comment.get('author', {}).get('displayName', 'Unknown')
|
254
|
+
content = comment.get('content', '')
|
255
|
+
created = comment.get('createdTime', '')
|
256
|
+
resolved = comment.get('resolved', False)
|
257
|
+
comment_id = comment.get('id', '')
|
258
|
+
status = " [RESOLVED]" if resolved else ""
|
259
|
+
|
260
|
+
output.append(f"Comment ID: {comment_id}")
|
261
|
+
output.append(f"Author: {author}")
|
262
|
+
output.append(f"Created: {created}{status}")
|
263
|
+
output.append(f"Content: {content}")
|
264
|
+
|
265
|
+
# Add replies if any
|
266
|
+
replies = comment.get('replies', [])
|
267
|
+
if replies:
|
268
|
+
output.append(f" Replies ({len(replies)}):")
|
269
|
+
for reply in replies:
|
270
|
+
reply_author = reply.get('author', {}).get('displayName', 'Unknown')
|
271
|
+
reply_content = reply.get('content', '')
|
272
|
+
reply_created = reply.get('createdTime', '')
|
273
|
+
reply_id = reply.get('id', '')
|
274
|
+
output.append(f" Reply ID: {reply_id}")
|
275
|
+
output.append(f" Author: {reply_author}")
|
276
|
+
output.append(f" Created: {reply_created}")
|
277
|
+
output.append(f" Content: {reply_content}")
|
278
|
+
|
279
|
+
output.append("") # Empty line between comments
|
280
|
+
|
281
|
+
return "\n".join(output)
|
282
|
+
|
283
|
+
|
284
|
+
@server.tool()
|
285
|
+
@require_google_service("drive", "drive_file")
|
286
|
+
@handle_http_errors("reply_to_comment")
|
287
|
+
async def reply_to_comment(
|
288
|
+
service,
|
289
|
+
user_google_email: str,
|
290
|
+
document_id: str,
|
291
|
+
comment_id: str,
|
292
|
+
reply_content: str,
|
293
|
+
) -> str:
|
294
|
+
"""
|
295
|
+
Reply to a specific comment in a Google Doc.
|
296
|
+
|
297
|
+
Args:
|
298
|
+
document_id: The ID of the Google Document
|
299
|
+
comment_id: The ID of the comment to reply to
|
300
|
+
reply_content: The content of the reply
|
301
|
+
|
302
|
+
Returns:
|
303
|
+
str: Confirmation message with reply details.
|
304
|
+
"""
|
305
|
+
logger.info(f"[reply_to_comment] Replying to comment {comment_id} in document {document_id}")
|
306
|
+
|
307
|
+
body = {'content': reply_content}
|
308
|
+
|
309
|
+
reply = await asyncio.to_thread(
|
310
|
+
service.replies().create(
|
311
|
+
fileId=document_id,
|
312
|
+
commentId=comment_id,
|
313
|
+
body=body,
|
314
|
+
fields="id,content,author,createdTime,modifiedTime"
|
315
|
+
).execute
|
316
|
+
)
|
317
|
+
|
318
|
+
reply_id = reply.get('id', '')
|
319
|
+
author = reply.get('author', {}).get('displayName', 'Unknown')
|
320
|
+
created = reply.get('createdTime', '')
|
321
|
+
|
322
|
+
return f"Reply posted successfully!\nReply ID: {reply_id}\nAuthor: {author}\nCreated: {created}\nContent: {reply_content}"
|
323
|
+
|
324
|
+
|
325
|
+
@server.tool()
|
326
|
+
@require_google_service("drive", "drive_file")
|
327
|
+
@handle_http_errors("create_doc_comment")
|
328
|
+
async def create_doc_comment(
|
329
|
+
service,
|
330
|
+
user_google_email: str,
|
331
|
+
document_id: str,
|
332
|
+
comment_content: str,
|
333
|
+
) -> str:
|
334
|
+
"""
|
335
|
+
Create a new comment on a Google Doc.
|
336
|
+
|
337
|
+
Args:
|
338
|
+
document_id: The ID of the Google Document
|
339
|
+
comment_content: The content of the comment
|
340
|
+
|
341
|
+
Returns:
|
342
|
+
str: Confirmation message with comment details.
|
343
|
+
"""
|
344
|
+
logger.info(f"[create_doc_comment] Creating comment in document {document_id}")
|
345
|
+
|
346
|
+
body = {"content": comment_content}
|
347
|
+
|
348
|
+
comment = await asyncio.to_thread(
|
349
|
+
service.comments().create(
|
350
|
+
fileId=document_id,
|
351
|
+
body=body,
|
352
|
+
fields="id,content,author,createdTime,modifiedTime"
|
353
|
+
).execute
|
354
|
+
)
|
355
|
+
|
356
|
+
comment_id = comment.get('id', '')
|
357
|
+
author = comment.get('author', {}).get('displayName', 'Unknown')
|
358
|
+
created = comment.get('createdTime', '')
|
359
|
+
|
360
|
+
return f"Comment created successfully!\nComment ID: {comment_id}\nAuthor: {author}\nCreated: {created}\nContent: {comment_content}"
|
361
|
+
|
362
|
+
|
363
|
+
@server.tool()
|
364
|
+
@require_google_service("drive", "drive_file")
|
365
|
+
@handle_http_errors("resolve_comment")
|
366
|
+
async def resolve_comment(
|
367
|
+
service,
|
368
|
+
user_google_email: str,
|
369
|
+
document_id: str,
|
370
|
+
comment_id: str,
|
371
|
+
) -> str:
|
372
|
+
"""
|
373
|
+
Resolve a comment in a Google Doc.
|
374
|
+
|
375
|
+
Args:
|
376
|
+
document_id: The ID of the Google Document
|
377
|
+
comment_id: The ID of the comment to resolve
|
378
|
+
|
379
|
+
Returns:
|
380
|
+
str: Confirmation message.
|
381
|
+
"""
|
382
|
+
logger.info(f"[resolve_comment] Resolving comment {comment_id} in document {document_id}")
|
383
|
+
|
384
|
+
body = {"resolved": True}
|
385
|
+
|
386
|
+
await asyncio.to_thread(
|
387
|
+
service.comments().update(
|
388
|
+
fileId=document_id,
|
389
|
+
commentId=comment_id,
|
390
|
+
body=body
|
391
|
+
).execute
|
392
|
+
)
|
393
|
+
|
394
|
+
return f"Comment {comment_id} has been resolved successfully."
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: workspace-mcp
|
3
|
-
Version: 1.0.
|
3
|
+
Version: 1.0.3
|
4
4
|
Summary: Comprehensive, highly performant Google Workspace Streamable HTTP & SSE MCP Server for Calendar, Gmail, Docs, Sheets, Slides & Drive
|
5
5
|
Author-email: Taylor Wilsdon <taylor@taylorwilsdon.com>
|
6
6
|
License: MIT
|
@@ -76,6 +76,20 @@ Dynamic: license-file
|
|
76
76
|
|
77
77
|
---
|
78
78
|
|
79
|
+
## AI-Enhanced Documentation
|
80
|
+
|
81
|
+
> **This README was crafted with AI assistance, and here's why that matters**
|
82
|
+
>
|
83
|
+
> When people dismiss documentation as "AI-generated," they're missing the bigger picture
|
84
|
+
|
85
|
+
As a solo developer building open source tools that may only ever serve my own needs, comprehensive documentation often wouldn't happen without AI help. When done right—using agents like **Roo** or **Claude Code** that understand the entire codebase, AI doesn't just regurgitate generic content - it extracts real implementation details and creates accurate, specific documentation.
|
86
|
+
|
87
|
+
**The alternative? No docs at all.**
|
88
|
+
|
89
|
+
I hope the community can appreciate these tools for what they enable: solo developers maintaining professional documentation standards while focusing on building great software.
|
90
|
+
|
91
|
+
---
|
92
|
+
*This documentation was enhanced by AI with full codebase context. The result? You're reading docs that otherwise might not exist.*
|
79
93
|
|
80
94
|
## 🌐 Overview
|
81
95
|
|
@@ -102,9 +116,13 @@ A production-ready MCP server that integrates all major Google Workspace service
|
|
102
116
|
|
103
117
|
### Simplest Start (uvx - Recommended)
|
104
118
|
|
105
|
-
Run instantly without installation
|
119
|
+
> Run instantly without manual installation - you must configure OAuth credentials when using uvx. You can use either environment variables (recommended for production) or set the `GOOGLE_CLIENT_SECRET_PATH` (or legacy `GOOGLE_CLIENT_SECRETS`) environment variable to point to your `client_secret.json` file.
|
106
120
|
|
107
121
|
```bash
|
122
|
+
# Set OAuth credentials via environment variables (recommended)
|
123
|
+
export GOOGLE_OAUTH_CLIENT_ID="your-client-id.apps.googleusercontent.com"
|
124
|
+
export GOOGLE_OAUTH_CLIENT_SECRET="your-client-secret"
|
125
|
+
|
108
126
|
# Start the server with all Google Workspace tools
|
109
127
|
uvx workspace-mcp
|
110
128
|
|
@@ -138,9 +156,31 @@ uv run main.py
|
|
138
156
|
1. **Google Cloud Setup**:
|
139
157
|
- Create OAuth 2.0 credentials (web application) in [Google Cloud Console](https://console.cloud.google.com/)
|
140
158
|
- Enable APIs: Calendar, Drive, Gmail, Docs, Sheets, Slides, Forms, Chat
|
141
|
-
- Download credentials as `client_secret.json` in project root
|
142
|
-
- To use a different location for `client_secret.json`, you can set the `GOOGLE_CLIENT_SECRETS` environment variable with that path
|
143
159
|
- Add redirect URI: `http://localhost:8000/oauth2callback`
|
160
|
+
- Configure credentials using one of these methods:
|
161
|
+
|
162
|
+
**Option A: Environment Variables (Recommended for Production)**
|
163
|
+
```bash
|
164
|
+
export GOOGLE_OAUTH_CLIENT_ID="your-client-id.apps.googleusercontent.com"
|
165
|
+
export GOOGLE_OAUTH_CLIENT_SECRET="your-client-secret"
|
166
|
+
export GOOGLE_OAUTH_REDIRECT_URI="http://localhost:8000/oauth2callback" # Optional
|
167
|
+
```
|
168
|
+
|
169
|
+
**Option B: File-based (Traditional)**
|
170
|
+
- Download credentials as `client_secret.json` in project root
|
171
|
+
- To use a different location, set `GOOGLE_CLIENT_SECRET_PATH` (or legacy `GOOGLE_CLIENT_SECRETS`) environment variable with the file path
|
172
|
+
|
173
|
+
**Credential Loading Priority**:
|
174
|
+
1. Environment variables (`GOOGLE_OAUTH_CLIENT_ID`, `GOOGLE_OAUTH_CLIENT_SECRET`)
|
175
|
+
2. File specified by `GOOGLE_CLIENT_SECRET_PATH` or `GOOGLE_CLIENT_SECRETS` environment variable
|
176
|
+
3. Default file (`client_secret.json` in project root)
|
177
|
+
|
178
|
+
**Why Environment Variables?**
|
179
|
+
- ✅ Containerized deployments (Docker, Kubernetes)
|
180
|
+
- ✅ Cloud platforms (Heroku, Railway, etc.)
|
181
|
+
- ✅ CI/CD pipelines
|
182
|
+
- ✅ No secrets in version control
|
183
|
+
- ✅ Easy credential rotation
|
144
184
|
|
145
185
|
2. **Environment**:
|
146
186
|
```bash
|
@@ -198,7 +238,11 @@ python install_claude.py
|
|
198
238
|
"mcpServers": {
|
199
239
|
"google_workspace": {
|
200
240
|
"command": "uvx",
|
201
|
-
"args": ["workspace-mcp"]
|
241
|
+
"args": ["workspace-mcp"],
|
242
|
+
"env": {
|
243
|
+
"GOOGLE_OAUTH_CLIENT_ID": "your-client-id.apps.googleusercontent.com",
|
244
|
+
"GOOGLE_OAUTH_CLIENT_SECRET": "your-client-secret"
|
245
|
+
}
|
202
246
|
}
|
203
247
|
}
|
204
248
|
}
|
@@ -211,7 +255,11 @@ python install_claude.py
|
|
211
255
|
"google_workspace": {
|
212
256
|
"command": "uv",
|
213
257
|
"args": ["run", "main.py"],
|
214
|
-
"cwd": "/path/to/google_workspace_mcp"
|
258
|
+
"cwd": "/path/to/google_workspace_mcp",
|
259
|
+
"env": {
|
260
|
+
"GOOGLE_OAUTH_CLIENT_ID": "your-client-id.apps.googleusercontent.com",
|
261
|
+
"GOOGLE_OAUTH_CLIENT_SECRET": "your-client-secret"
|
262
|
+
}
|
215
263
|
}
|
216
264
|
}
|
217
265
|
}
|
@@ -259,7 +307,8 @@ When calling a tool:
|
|
259
307
|
|------|-------------|
|
260
308
|
| `list_calendars` | List accessible calendars |
|
261
309
|
| `get_events` | Retrieve events with time range filtering |
|
262
|
-
| `
|
310
|
+
| `get_event` | Fetch detailed information of a single event by ID |
|
311
|
+
| `create_event` | Create events (all-day or timed) with optional Drive file attachments |
|
263
312
|
| `modify_event` | Update existing events |
|
264
313
|
| `delete_event` | Remove events |
|
265
314
|
|
@@ -270,7 +319,7 @@ When calling a tool:
|
|
270
319
|
| `search_drive_files` | Search files with query syntax |
|
271
320
|
| `get_drive_file_content` | Read file content (supports Office formats) |
|
272
321
|
| `list_drive_items` | List folder contents |
|
273
|
-
| `create_drive_file` | Create new files |
|
322
|
+
| `create_drive_file` | Create new files or fetch content from public URLs |
|
274
323
|
|
275
324
|
### 📧 Gmail ([`gmail_tools.py`](gmail/gmail_tools.py))
|
276
325
|
|
@@ -1,19 +1,20 @@
|
|
1
1
|
main.py,sha256=Mv5jfggqQ5XqzetKhccD2OmeWFnhidSbgzyKppCfywo,7078
|
2
2
|
auth/__init__.py,sha256=gPCU3GE-SLy91S3D3CbX-XfKBm6hteK_VSPKx7yjT5s,42
|
3
|
-
auth/google_auth.py,sha256=
|
4
|
-
auth/oauth_callback_server.py,sha256
|
3
|
+
auth/google_auth.py,sha256=2UBbQgGcUPdUFWDbzdFy60NJLQ3SI45GIASzuzO1Tew,30717
|
4
|
+
auth/oauth_callback_server.py,sha256=igrur3fkZSY0bawufrH4AN9fMNpobUdAUp1BG7AQC6w,9341
|
5
5
|
auth/oauth_responses.py,sha256=qbirSB4d7mBRKcJKqGLrJxRAPaLHqObf9t-VMAq6UKA,7020
|
6
6
|
auth/scopes.py,sha256=kMRdFN0wLyipFkp7IitTHs-M6zhZD-oieVd7fylueBc,3320
|
7
7
|
auth/service_decorator.py,sha256=h9bkG1O6U-p4_yT1KseBKJvueprKd4SVJe1Bj2VrdXA,15669
|
8
8
|
core/__init__.py,sha256=AHVKdPl6v4lUFm2R-KuGuAgEmCyfxseMeLGtntMcqCs,43
|
9
|
-
core/
|
9
|
+
core/context.py,sha256=zNgPXf9EO2EMs9sQkfKiywoy6sEOksVNgOrJMA_c30Y,768
|
10
|
+
core/server.py,sha256=fBPGMy9axIUOppsRFB31rlkaxEV32JRvaw2ZN_UZ9ms,9188
|
10
11
|
core/utils.py,sha256=2t5wbLtSLodxNKNAZb-jmR8Zg6mm-Rady-LpnXCP-1g,10297
|
11
12
|
gcalendar/__init__.py,sha256=D5fSdAwbeomoaj7XAdxSnIy-NVKNkpExs67175bOtfc,46
|
12
13
|
gcalendar/calendar_tools.py,sha256=SIiSJRxG3G9KsScow0pYwew600_PdtFqlOo-y2vXQRo,22144
|
13
14
|
gchat/__init__.py,sha256=XBjH4SbtULfZHgFCxk3moel5XqG599HCgZWl_veIncg,88
|
14
15
|
gchat/chat_tools.py,sha256=cIeXBBxWkFCdQNJ23BkX8IoDho6J8ZcfLsPjctUWyfA,7274
|
15
16
|
gdocs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
16
|
-
gdocs/docs_tools.py,sha256=
|
17
|
+
gdocs/docs_tools.py,sha256=AN9yG0c2AWCTd3bjc9guYBaOOF_PS_c_xKV6UMXclvU,13555
|
17
18
|
gdrive/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
18
19
|
gdrive/drive_tools.py,sha256=l-6IpHTstRMKIY2CU4DFTTNfEQ5rVbafgwo8BrbJ9Bk,15257
|
19
20
|
gforms/__init__.py,sha256=pL91XixrEp9YjpM-AYwONIEfeCP2OumkEG0Io5V4boE,37
|
@@ -24,9 +25,9 @@ gsheets/__init__.py,sha256=jFfhD52w_EOVw6N5guf_dIc9eP2khW_eS9UAPJg_K3k,446
|
|
24
25
|
gsheets/sheets_tools.py,sha256=ctUvaA-3I-iGwCCHOk9Bloh5P7XQDqxBnFAxFTqCTPc,11466
|
25
26
|
gslides/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
26
27
|
gslides/slides_tools.py,sha256=FyFbpUxfbaueyN4lbRk5WeoxK7NWbLDTBCiyDPtPFgM,9426
|
27
|
-
workspace_mcp-1.0.
|
28
|
-
workspace_mcp-1.0.
|
29
|
-
workspace_mcp-1.0.
|
30
|
-
workspace_mcp-1.0.
|
31
|
-
workspace_mcp-1.0.
|
32
|
-
workspace_mcp-1.0.
|
28
|
+
workspace_mcp-1.0.3.dist-info/licenses/LICENSE,sha256=bB8L7rIyRy5o-WHxGgvRuY8hUTzNu4h3DTkvyV8XFJo,1070
|
29
|
+
workspace_mcp-1.0.3.dist-info/METADATA,sha256=Ix57WY-9KB0uDjyFNMWYh42CcEpJEmDtx9Xe3N-bIgY,18318
|
30
|
+
workspace_mcp-1.0.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
31
|
+
workspace_mcp-1.0.3.dist-info/entry_points.txt,sha256=kPiEfOTuf-ptDM0Rf2OlyrFudGW7hCZGg4MCn2Foxs4,44
|
32
|
+
workspace_mcp-1.0.3.dist-info/top_level.txt,sha256=Y8mAkTitLNE2zZEJ-DbqR9R7Cs1V1MMf-UploVdOvlw,73
|
33
|
+
workspace_mcp-1.0.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|