datarobot-genai 0.2.22__py3-none-any.whl → 0.2.23__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.
- datarobot_genai/drmcp/tools/clients/confluence.py +93 -1
- datarobot_genai/drmcp/tools/clients/gdrive.py +255 -0
- datarobot_genai/drmcp/tools/confluence/tools.py +67 -0
- datarobot_genai/drmcp/tools/gdrive/tools.py +66 -0
- {datarobot_genai-0.2.22.dist-info → datarobot_genai-0.2.23.dist-info}/METADATA +1 -1
- {datarobot_genai-0.2.22.dist-info → datarobot_genai-0.2.23.dist-info}/RECORD +10 -10
- {datarobot_genai-0.2.22.dist-info → datarobot_genai-0.2.23.dist-info}/WHEEL +0 -0
- {datarobot_genai-0.2.22.dist-info → datarobot_genai-0.2.23.dist-info}/entry_points.txt +0 -0
- {datarobot_genai-0.2.22.dist-info → datarobot_genai-0.2.23.dist-info}/licenses/AUTHORS +0 -0
- {datarobot_genai-0.2.22.dist-info → datarobot_genai-0.2.23.dist-info}/licenses/LICENSE +0 -0
|
@@ -50,6 +50,7 @@ class ConfluencePage(BaseModel):
|
|
|
50
50
|
space_id: str = Field(..., description="Space ID where the page resides")
|
|
51
51
|
space_key: str | None = Field(None, description="Space key (if available)")
|
|
52
52
|
body: str = Field(..., description="Page content in storage format (HTML-like)")
|
|
53
|
+
version: int = Field(..., description="Current version number of the page")
|
|
53
54
|
|
|
54
55
|
def as_flat_dict(self) -> dict[str, Any]:
|
|
55
56
|
"""Return a flat dictionary representation of the page."""
|
|
@@ -59,6 +60,7 @@ class ConfluencePage(BaseModel):
|
|
|
59
60
|
"space_id": self.space_id,
|
|
60
61
|
"space_key": self.space_key,
|
|
61
62
|
"body": self.body,
|
|
63
|
+
"version": self.version,
|
|
62
64
|
}
|
|
63
65
|
|
|
64
66
|
|
|
@@ -111,7 +113,7 @@ class ConfluenceClient:
|
|
|
111
113
|
At the moment of creating this client, official Confluence SDK is not supporting async.
|
|
112
114
|
"""
|
|
113
115
|
|
|
114
|
-
EXPAND_FIELDS = "body.storage,space"
|
|
116
|
+
EXPAND_FIELDS = "body.storage,space,version"
|
|
115
117
|
|
|
116
118
|
def __init__(self, access_token: str) -> None:
|
|
117
119
|
"""
|
|
@@ -164,6 +166,8 @@ class ConfluenceClient:
|
|
|
164
166
|
space = data.get("space", {})
|
|
165
167
|
space_key = space.get("key") if isinstance(space, dict) else None
|
|
166
168
|
space_id = space.get("id", "") if isinstance(space, dict) else data.get("spaceId", "")
|
|
169
|
+
version_data = data.get("version", {})
|
|
170
|
+
version_number = version_data.get("number", 1) if isinstance(version_data, dict) else 1
|
|
167
171
|
|
|
168
172
|
return ConfluencePage(
|
|
169
173
|
page_id=str(data.get("id", "")),
|
|
@@ -171,6 +175,7 @@ class ConfluenceClient:
|
|
|
171
175
|
space_id=str(space_id),
|
|
172
176
|
space_key=space_key,
|
|
173
177
|
body=body_content,
|
|
178
|
+
version=version_number,
|
|
174
179
|
)
|
|
175
180
|
|
|
176
181
|
async def get_page_by_id(self, page_id: str) -> ConfluencePage:
|
|
@@ -339,6 +344,93 @@ class ConfluenceClient:
|
|
|
339
344
|
|
|
340
345
|
return self._parse_response(response.json())
|
|
341
346
|
|
|
347
|
+
async def update_page(
|
|
348
|
+
self,
|
|
349
|
+
page_id: str,
|
|
350
|
+
new_body_content: str,
|
|
351
|
+
version_number: int,
|
|
352
|
+
) -> ConfluencePage:
|
|
353
|
+
"""
|
|
354
|
+
Update the content of an existing Confluence page.
|
|
355
|
+
|
|
356
|
+
Args:
|
|
357
|
+
page_id: The ID of the page to update
|
|
358
|
+
new_body_content: The new content in Confluence Storage Format (XML) or raw text
|
|
359
|
+
version_number: The current version number of the page (for optimistic locking).
|
|
360
|
+
The update will increment this by 1.
|
|
361
|
+
|
|
362
|
+
Returns
|
|
363
|
+
-------
|
|
364
|
+
ConfluencePage with the updated page data including the new version number
|
|
365
|
+
|
|
366
|
+
Raises
|
|
367
|
+
------
|
|
368
|
+
ConfluenceError: If page not found (404), version conflict (409),
|
|
369
|
+
permission denied (403), invalid content (400),
|
|
370
|
+
or rate limited (429)
|
|
371
|
+
httpx.HTTPStatusError: If the API request fails with unexpected status
|
|
372
|
+
"""
|
|
373
|
+
cloud_id = await self._get_cloud_id()
|
|
374
|
+
url = f"{ATLASSIAN_API_BASE}/ex/confluence/{cloud_id}/wiki/rest/api/content/{page_id}"
|
|
375
|
+
|
|
376
|
+
try:
|
|
377
|
+
current_page = await self.get_page_by_id(page_id)
|
|
378
|
+
title_to_use = current_page.title
|
|
379
|
+
except ConfluenceError as e:
|
|
380
|
+
if e.status_code == 404:
|
|
381
|
+
raise ConfluenceError(
|
|
382
|
+
f"Page with ID '{page_id}' not found: cannot fetch existing title",
|
|
383
|
+
status_code=404,
|
|
384
|
+
)
|
|
385
|
+
raise
|
|
386
|
+
|
|
387
|
+
payload: dict[str, Any] = {
|
|
388
|
+
"type": "page",
|
|
389
|
+
"title": title_to_use,
|
|
390
|
+
"body": {
|
|
391
|
+
"storage": {
|
|
392
|
+
"value": new_body_content,
|
|
393
|
+
"representation": "storage",
|
|
394
|
+
}
|
|
395
|
+
},
|
|
396
|
+
"version": {
|
|
397
|
+
"number": version_number + 1,
|
|
398
|
+
},
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
response = await self._client.put(url, json=payload)
|
|
402
|
+
|
|
403
|
+
if response.status_code == HTTPStatus.NOT_FOUND:
|
|
404
|
+
error_msg = self._extract_error_message(response)
|
|
405
|
+
raise ConfluenceError(
|
|
406
|
+
f"Page with ID '{page_id}' not found: {error_msg}",
|
|
407
|
+
status_code=404,
|
|
408
|
+
)
|
|
409
|
+
|
|
410
|
+
if response.status_code == HTTPStatus.CONFLICT:
|
|
411
|
+
error_msg = self._extract_error_message(response)
|
|
412
|
+
raise ConfluenceError(
|
|
413
|
+
f"Version conflict: the page has been modified since version {version_number}. "
|
|
414
|
+
f"Please fetch the latest version and retry. Details: {error_msg}",
|
|
415
|
+
status_code=409,
|
|
416
|
+
)
|
|
417
|
+
|
|
418
|
+
if response.status_code == HTTPStatus.FORBIDDEN:
|
|
419
|
+
raise ConfluenceError(
|
|
420
|
+
f"Permission denied: you don't have access to update page '{page_id}'",
|
|
421
|
+
status_code=403,
|
|
422
|
+
)
|
|
423
|
+
|
|
424
|
+
if response.status_code == HTTPStatus.BAD_REQUEST:
|
|
425
|
+
error_msg = self._extract_error_message(response)
|
|
426
|
+
raise ConfluenceError(f"Invalid request: {error_msg}", status_code=400)
|
|
427
|
+
|
|
428
|
+
if response.status_code == HTTPStatus.TOO_MANY_REQUESTS:
|
|
429
|
+
raise ConfluenceError("Rate limit exceeded. Please try again later.", status_code=429)
|
|
430
|
+
|
|
431
|
+
response.raise_for_status()
|
|
432
|
+
return self._parse_response(response.json())
|
|
433
|
+
|
|
342
434
|
def _parse_comment_response(self, data: dict, page_id: str) -> ConfluenceComment:
|
|
343
435
|
"""Parse API response into ConfluenceComment."""
|
|
344
436
|
body_content = ""
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
"""Google Drive API Client and utilities for OAuth."""
|
|
16
16
|
|
|
17
|
+
import io
|
|
17
18
|
import logging
|
|
18
19
|
from typing import Annotated
|
|
19
20
|
from typing import Any
|
|
@@ -24,6 +25,7 @@ from fastmcp.exceptions import ToolError
|
|
|
24
25
|
from pydantic import BaseModel
|
|
25
26
|
from pydantic import ConfigDict
|
|
26
27
|
from pydantic import Field
|
|
28
|
+
from pypdf import PdfReader
|
|
27
29
|
|
|
28
30
|
from datarobot_genai.drmcp.core.auth import get_access_token
|
|
29
31
|
|
|
@@ -37,6 +39,23 @@ DEFAULT_ORDER = "modifiedTime desc"
|
|
|
37
39
|
MAX_PAGE_SIZE = 100
|
|
38
40
|
LIMIT = 500
|
|
39
41
|
|
|
42
|
+
GOOGLE_WORKSPACE_EXPORT_MIMES: dict[str, str] = {
|
|
43
|
+
"application/vnd.google-apps.document": "text/markdown",
|
|
44
|
+
"application/vnd.google-apps.spreadsheet": "text/csv",
|
|
45
|
+
"application/vnd.google-apps.presentation": "text/plain",
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
BINARY_MIME_PREFIXES = (
|
|
49
|
+
"image/",
|
|
50
|
+
"audio/",
|
|
51
|
+
"video/",
|
|
52
|
+
"application/zip",
|
|
53
|
+
"application/octet-stream",
|
|
54
|
+
"application/vnd.google-apps.drawing",
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
PDF_MIME_TYPE = "application/pdf"
|
|
58
|
+
|
|
40
59
|
|
|
41
60
|
async def get_gdrive_access_token() -> str | ToolError:
|
|
42
61
|
"""
|
|
@@ -116,6 +135,35 @@ class PaginatedResult(BaseModel):
|
|
|
116
135
|
next_page_token: str | None = None
|
|
117
136
|
|
|
118
137
|
|
|
138
|
+
class GoogleDriveFileContent(BaseModel):
|
|
139
|
+
"""Content retrieved from a Google Drive file."""
|
|
140
|
+
|
|
141
|
+
id: str
|
|
142
|
+
name: str
|
|
143
|
+
mime_type: str
|
|
144
|
+
content: str
|
|
145
|
+
original_mime_type: str
|
|
146
|
+
was_exported: bool = False
|
|
147
|
+
size: int | None = None
|
|
148
|
+
web_view_link: str | None = None
|
|
149
|
+
|
|
150
|
+
def as_flat_dict(self) -> dict[str, Any]:
|
|
151
|
+
"""Return a flat dictionary representation of the file content."""
|
|
152
|
+
result: dict[str, Any] = {
|
|
153
|
+
"id": self.id,
|
|
154
|
+
"name": self.name,
|
|
155
|
+
"mimeType": self.mime_type,
|
|
156
|
+
"content": self.content,
|
|
157
|
+
"originalMimeType": self.original_mime_type,
|
|
158
|
+
"wasExported": self.was_exported,
|
|
159
|
+
}
|
|
160
|
+
if self.size is not None:
|
|
161
|
+
result["size"] = self.size
|
|
162
|
+
if self.web_view_link is not None:
|
|
163
|
+
result["webViewLink"] = self.web_view_link
|
|
164
|
+
return result
|
|
165
|
+
|
|
166
|
+
|
|
119
167
|
class GoogleDriveClient:
|
|
120
168
|
"""Client for interacting with Google Drive API."""
|
|
121
169
|
|
|
@@ -344,6 +392,213 @@ class GoogleDriveClient:
|
|
|
344
392
|
logger.debug(f"Auto-formatted query '{query}' to '{formatted_query}'")
|
|
345
393
|
return formatted_query
|
|
346
394
|
|
|
395
|
+
@staticmethod
|
|
396
|
+
def _is_binary_mime_type(mime_type: str) -> bool:
|
|
397
|
+
"""Check if MIME type indicates binary content that's not useful for LLM consumption.
|
|
398
|
+
|
|
399
|
+
Args:
|
|
400
|
+
mime_type: The MIME type to check.
|
|
401
|
+
|
|
402
|
+
Returns
|
|
403
|
+
-------
|
|
404
|
+
True if the MIME type is considered binary, False otherwise.
|
|
405
|
+
"""
|
|
406
|
+
return any(mime_type.startswith(prefix) for prefix in BINARY_MIME_PREFIXES)
|
|
407
|
+
|
|
408
|
+
async def get_file_metadata(self, file_id: str) -> GoogleDriveFile:
|
|
409
|
+
"""Get file metadata from Google Drive.
|
|
410
|
+
|
|
411
|
+
Args:
|
|
412
|
+
file_id: The ID of the file to get metadata for.
|
|
413
|
+
|
|
414
|
+
Returns
|
|
415
|
+
-------
|
|
416
|
+
GoogleDriveFile with file metadata.
|
|
417
|
+
|
|
418
|
+
Raises
|
|
419
|
+
------
|
|
420
|
+
GoogleDriveError: If the file is not found or access is denied.
|
|
421
|
+
"""
|
|
422
|
+
params = {"fields": SUPPORTED_FIELDS_STR}
|
|
423
|
+
response = await self._client.get(f"/{file_id}", params=params)
|
|
424
|
+
|
|
425
|
+
if response.status_code == 404:
|
|
426
|
+
raise GoogleDriveError(f"File with ID '{file_id}' not found.")
|
|
427
|
+
if response.status_code == 403:
|
|
428
|
+
raise GoogleDriveError(f"Permission denied: you don't have access to file '{file_id}'.")
|
|
429
|
+
if response.status_code == 429:
|
|
430
|
+
raise GoogleDriveError("Rate limit exceeded. Please try again later.")
|
|
431
|
+
|
|
432
|
+
response.raise_for_status()
|
|
433
|
+
return GoogleDriveFile.from_api_response(response.json())
|
|
434
|
+
|
|
435
|
+
async def _export_workspace_file(self, file_id: str, export_mime_type: str) -> str:
|
|
436
|
+
"""Export a Google Workspace file to the specified format.
|
|
437
|
+
|
|
438
|
+
Args:
|
|
439
|
+
file_id: The ID of the Google Workspace file.
|
|
440
|
+
export_mime_type: The MIME type to export to (e.g., 'text/markdown').
|
|
441
|
+
|
|
442
|
+
Returns
|
|
443
|
+
-------
|
|
444
|
+
The exported content as a string.
|
|
445
|
+
|
|
446
|
+
Raises
|
|
447
|
+
------
|
|
448
|
+
GoogleDriveError: If export fails.
|
|
449
|
+
"""
|
|
450
|
+
response = await self._client.get(
|
|
451
|
+
f"/{file_id}/export",
|
|
452
|
+
params={"mimeType": export_mime_type},
|
|
453
|
+
)
|
|
454
|
+
|
|
455
|
+
if response.status_code == 404:
|
|
456
|
+
raise GoogleDriveError(f"File with ID '{file_id}' not found.")
|
|
457
|
+
if response.status_code == 403:
|
|
458
|
+
raise GoogleDriveError(
|
|
459
|
+
f"Permission denied: you don't have access to export file '{file_id}'."
|
|
460
|
+
)
|
|
461
|
+
if response.status_code == 400:
|
|
462
|
+
raise GoogleDriveError(
|
|
463
|
+
f"Cannot export file '{file_id}' to format '{export_mime_type}'. "
|
|
464
|
+
"The file may not support this export format."
|
|
465
|
+
)
|
|
466
|
+
if response.status_code == 429:
|
|
467
|
+
raise GoogleDriveError("Rate limit exceeded. Please try again later.")
|
|
468
|
+
|
|
469
|
+
response.raise_for_status()
|
|
470
|
+
return response.text
|
|
471
|
+
|
|
472
|
+
async def _download_file(self, file_id: str) -> str:
|
|
473
|
+
"""Download a regular file's content from Google Drive as text."""
|
|
474
|
+
content = await self._download_file_bytes(file_id)
|
|
475
|
+
return content.decode("utf-8")
|
|
476
|
+
|
|
477
|
+
async def _download_file_bytes(self, file_id: str) -> bytes:
|
|
478
|
+
"""Download a file's content as bytes from Google Drive.
|
|
479
|
+
|
|
480
|
+
Args:
|
|
481
|
+
file_id: The ID of the file to download.
|
|
482
|
+
|
|
483
|
+
Returns
|
|
484
|
+
-------
|
|
485
|
+
The file content as bytes.
|
|
486
|
+
|
|
487
|
+
Raises
|
|
488
|
+
------
|
|
489
|
+
GoogleDriveError: If download fails.
|
|
490
|
+
"""
|
|
491
|
+
response = await self._client.get(
|
|
492
|
+
f"/{file_id}",
|
|
493
|
+
params={"alt": "media"},
|
|
494
|
+
)
|
|
495
|
+
|
|
496
|
+
if response.status_code == 404:
|
|
497
|
+
raise GoogleDriveError(f"File with ID '{file_id}' not found.")
|
|
498
|
+
if response.status_code == 403:
|
|
499
|
+
raise GoogleDriveError(
|
|
500
|
+
f"Permission denied: you don't have access to download file '{file_id}'."
|
|
501
|
+
)
|
|
502
|
+
if response.status_code == 429:
|
|
503
|
+
raise GoogleDriveError("Rate limit exceeded. Please try again later.")
|
|
504
|
+
|
|
505
|
+
response.raise_for_status()
|
|
506
|
+
return response.content
|
|
507
|
+
|
|
508
|
+
def _extract_text_from_pdf(self, pdf_bytes: bytes) -> str:
|
|
509
|
+
"""Extract text from PDF bytes using pypdf.
|
|
510
|
+
|
|
511
|
+
Args:
|
|
512
|
+
pdf_bytes: The PDF file content as bytes.
|
|
513
|
+
|
|
514
|
+
Returns
|
|
515
|
+
-------
|
|
516
|
+
Extracted text from the PDF.
|
|
517
|
+
|
|
518
|
+
Raises
|
|
519
|
+
------
|
|
520
|
+
GoogleDriveError: If PDF text extraction fails.
|
|
521
|
+
"""
|
|
522
|
+
try:
|
|
523
|
+
reader = PdfReader(io.BytesIO(pdf_bytes))
|
|
524
|
+
text_parts = []
|
|
525
|
+
for page in reader.pages:
|
|
526
|
+
page_text = page.extract_text()
|
|
527
|
+
if page_text:
|
|
528
|
+
text_parts.append(page_text)
|
|
529
|
+
return "\n\n".join(text_parts)
|
|
530
|
+
except Exception as e:
|
|
531
|
+
raise GoogleDriveError(f"Failed to extract text from PDF: {e}")
|
|
532
|
+
|
|
533
|
+
async def read_file_content(
|
|
534
|
+
self, file_id: str, target_format: str | None = None
|
|
535
|
+
) -> GoogleDriveFileContent:
|
|
536
|
+
"""Read the content of a file from Google Drive.
|
|
537
|
+
|
|
538
|
+
Google Workspace files (Docs, Sheets, Slides) are automatically exported to
|
|
539
|
+
LLM-readable formats:
|
|
540
|
+
- Google Docs -> Markdown (text/markdown)
|
|
541
|
+
- Google Sheets -> CSV (text/csv)
|
|
542
|
+
- Google Slides -> Plain text (text/plain)
|
|
543
|
+
- PDF files -> Extracted text (text/plain)
|
|
544
|
+
|
|
545
|
+
Regular text files are downloaded directly.
|
|
546
|
+
Binary files (images, videos, etc.) will raise an error.
|
|
547
|
+
|
|
548
|
+
Args:
|
|
549
|
+
file_id: The ID of the file to read.
|
|
550
|
+
target_format: Optional MIME type to export Google Workspace files to.
|
|
551
|
+
If not specified, uses sensible defaults. Has no effect on non-Workspace files.
|
|
552
|
+
|
|
553
|
+
Returns
|
|
554
|
+
-------
|
|
555
|
+
GoogleDriveFileContent with the file content and metadata.
|
|
556
|
+
|
|
557
|
+
Raises
|
|
558
|
+
------
|
|
559
|
+
GoogleDriveError: If the file cannot be read (not found, permission denied,
|
|
560
|
+
binary file, etc.).
|
|
561
|
+
"""
|
|
562
|
+
file_metadata = await self.get_file_metadata(file_id)
|
|
563
|
+
original_mime_type = file_metadata.mime_type
|
|
564
|
+
|
|
565
|
+
if self._is_binary_mime_type(original_mime_type):
|
|
566
|
+
raise GoogleDriveError(
|
|
567
|
+
f"Binary files are not supported for reading. "
|
|
568
|
+
f"File '{file_metadata.name}' has MIME type '{original_mime_type}'."
|
|
569
|
+
)
|
|
570
|
+
|
|
571
|
+
if original_mime_type == GOOGLE_DRIVE_FOLDER_MIME:
|
|
572
|
+
raise GoogleDriveError(
|
|
573
|
+
f"Cannot read content of a folder. '{file_metadata.name}' is a folder, not a file."
|
|
574
|
+
)
|
|
575
|
+
|
|
576
|
+
was_exported = False
|
|
577
|
+
if original_mime_type in GOOGLE_WORKSPACE_EXPORT_MIMES:
|
|
578
|
+
export_mime = target_format or GOOGLE_WORKSPACE_EXPORT_MIMES[original_mime_type]
|
|
579
|
+
content = await self._export_workspace_file(file_id, export_mime)
|
|
580
|
+
result_mime_type = export_mime
|
|
581
|
+
was_exported = True
|
|
582
|
+
elif original_mime_type == PDF_MIME_TYPE:
|
|
583
|
+
pdf_bytes = await self._download_file_bytes(file_id)
|
|
584
|
+
content = self._extract_text_from_pdf(pdf_bytes)
|
|
585
|
+
result_mime_type = "text/plain"
|
|
586
|
+
was_exported = True
|
|
587
|
+
else:
|
|
588
|
+
content = await self._download_file(file_id)
|
|
589
|
+
result_mime_type = original_mime_type
|
|
590
|
+
|
|
591
|
+
return GoogleDriveFileContent(
|
|
592
|
+
id=file_metadata.id,
|
|
593
|
+
name=file_metadata.name,
|
|
594
|
+
mime_type=result_mime_type,
|
|
595
|
+
content=content,
|
|
596
|
+
original_mime_type=original_mime_type,
|
|
597
|
+
was_exported=was_exported,
|
|
598
|
+
size=file_metadata.size,
|
|
599
|
+
web_view_link=file_metadata.web_view_link,
|
|
600
|
+
)
|
|
601
|
+
|
|
347
602
|
async def __aenter__(self) -> "GoogleDriveClient":
|
|
348
603
|
"""Async context manager entry."""
|
|
349
604
|
return self
|
|
@@ -252,3 +252,70 @@ async def confluence_search(
|
|
|
252
252
|
content=f"Successfully executed CQL query and retrieved {n} result(s).",
|
|
253
253
|
structured_content={"data": data, "count": n},
|
|
254
254
|
)
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
@dr_mcp_tool(tags={"confluence", "write", "update", "page"})
|
|
258
|
+
async def confluence_update_page(
|
|
259
|
+
*,
|
|
260
|
+
page_id: Annotated[str, "The ID of the Confluence page to update."],
|
|
261
|
+
new_body_content: Annotated[
|
|
262
|
+
str,
|
|
263
|
+
"The full updated content of the page in Confluence Storage Format (XML) or raw text.",
|
|
264
|
+
],
|
|
265
|
+
version_number: Annotated[
|
|
266
|
+
int,
|
|
267
|
+
"The current version number of the page, required to prevent update conflicts. "
|
|
268
|
+
"Get this from the confluence_get_page tool.",
|
|
269
|
+
],
|
|
270
|
+
) -> ToolResult:
|
|
271
|
+
"""Update the content of an existing Confluence page.
|
|
272
|
+
|
|
273
|
+
Requires the current version number to ensure atomic updates.
|
|
274
|
+
Use this tool to update the body content of an existing Confluence page.
|
|
275
|
+
The version_number is required for optimistic locking - it prevents overwriting
|
|
276
|
+
changes made by others since you last fetched the page.
|
|
277
|
+
|
|
278
|
+
Usage:
|
|
279
|
+
page_id="856391684", new_body_content="<p>New content</p>", version_number=5
|
|
280
|
+
|
|
281
|
+
Important: Always fetch the page first using confluence_get_page to get the
|
|
282
|
+
current version number before updating.
|
|
283
|
+
"""
|
|
284
|
+
if not page_id:
|
|
285
|
+
raise ToolError("Argument validation error: 'page_id' cannot be empty.")
|
|
286
|
+
|
|
287
|
+
if not new_body_content:
|
|
288
|
+
raise ToolError("Argument validation error: 'new_body_content' cannot be empty.")
|
|
289
|
+
|
|
290
|
+
if version_number < 1:
|
|
291
|
+
raise ToolError(
|
|
292
|
+
"Argument validation error: 'version_number' must be a positive integer (>= 1)."
|
|
293
|
+
)
|
|
294
|
+
|
|
295
|
+
access_token = await get_atlassian_access_token()
|
|
296
|
+
if isinstance(access_token, ToolError):
|
|
297
|
+
raise access_token
|
|
298
|
+
|
|
299
|
+
try:
|
|
300
|
+
async with ConfluenceClient(access_token) as client:
|
|
301
|
+
page_response = await client.update_page(
|
|
302
|
+
page_id=page_id,
|
|
303
|
+
new_body_content=new_body_content,
|
|
304
|
+
version_number=version_number,
|
|
305
|
+
)
|
|
306
|
+
except ConfluenceError as e:
|
|
307
|
+
logger.error(f"Confluence error updating page: {e}")
|
|
308
|
+
raise ToolError(str(e))
|
|
309
|
+
except Exception as e:
|
|
310
|
+
logger.error(f"Unexpected error updating Confluence page: {e}")
|
|
311
|
+
raise ToolError(
|
|
312
|
+
f"An unexpected error occurred while updating Confluence page '{page_id}': {str(e)}"
|
|
313
|
+
)
|
|
314
|
+
|
|
315
|
+
return ToolResult(
|
|
316
|
+
content=f"Page ID {page_id} updated successfully to version {page_response.version}.",
|
|
317
|
+
structured_content={
|
|
318
|
+
"updated_page_id": page_response.page_id,
|
|
319
|
+
"new_version": page_response.version,
|
|
320
|
+
},
|
|
321
|
+
)
|
|
@@ -109,3 +109,69 @@ async def gdrive_find_contents(
|
|
|
109
109
|
"nextPageToken": data.next_page_token,
|
|
110
110
|
},
|
|
111
111
|
)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
@dr_mcp_tool(tags={"google", "gdrive", "read", "content", "file", "download"})
|
|
115
|
+
async def gdrive_read_content(
|
|
116
|
+
*,
|
|
117
|
+
file_id: Annotated[str, "The ID of the file to read."],
|
|
118
|
+
target_format: Annotated[
|
|
119
|
+
str | None,
|
|
120
|
+
"The preferred output format for Google Workspace files "
|
|
121
|
+
"(e.g., 'text/markdown' for Docs, 'text/csv' for Sheets). "
|
|
122
|
+
"If not specified, uses sensible defaults. Has no effect on regular files.",
|
|
123
|
+
] = None,
|
|
124
|
+
) -> ToolResult | ToolError:
|
|
125
|
+
"""
|
|
126
|
+
Retrieve the content of a specific file by its ID. Google Workspace files are
|
|
127
|
+
automatically exported to LLM-readable formats (Push-Down).
|
|
128
|
+
|
|
129
|
+
Usage:
|
|
130
|
+
- Basic: gdrive_read_content(file_id="1ABC123def456")
|
|
131
|
+
- Custom format: gdrive_read_content(file_id="1ABC...", target_format="text/plain")
|
|
132
|
+
- First use gdrive_find_contents to discover file IDs
|
|
133
|
+
|
|
134
|
+
Supported conversions (defaults):
|
|
135
|
+
- Google Docs -> Markdown (text/markdown)
|
|
136
|
+
- Google Sheets -> CSV (text/csv)
|
|
137
|
+
- Google Slides -> Plain text (text/plain)
|
|
138
|
+
- PDF files -> Extracted text (text/plain)
|
|
139
|
+
- Other text files -> Downloaded as-is
|
|
140
|
+
|
|
141
|
+
Note: Binary files (images, videos, etc.) are not supported and will return an error.
|
|
142
|
+
Large Google Workspace files (>10MB) may fail to export due to API limits.
|
|
143
|
+
|
|
144
|
+
Refer to Google Drive export formats documentation:
|
|
145
|
+
https://developers.google.com/workspace/drive/api/guides/ref-export-formats
|
|
146
|
+
"""
|
|
147
|
+
if not file_id or not file_id.strip():
|
|
148
|
+
raise ToolError("Argument validation error: 'file_id' cannot be empty.")
|
|
149
|
+
|
|
150
|
+
access_token = await get_gdrive_access_token()
|
|
151
|
+
if isinstance(access_token, ToolError):
|
|
152
|
+
raise access_token
|
|
153
|
+
|
|
154
|
+
try:
|
|
155
|
+
async with GoogleDriveClient(access_token) as client:
|
|
156
|
+
file_content = await client.read_file_content(file_id, target_format)
|
|
157
|
+
except GoogleDriveError as e:
|
|
158
|
+
logger.error(f"Google Drive error reading file content: {e}")
|
|
159
|
+
raise ToolError(str(e))
|
|
160
|
+
except Exception as e:
|
|
161
|
+
logger.error(f"Unexpected error reading Google Drive file content: {e}")
|
|
162
|
+
raise ToolError(
|
|
163
|
+
f"An unexpected error occurred while reading Google Drive file content: {str(e)}"
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
# Provide helpful context about the conversion
|
|
167
|
+
export_info = ""
|
|
168
|
+
if file_content.was_exported:
|
|
169
|
+
export_info = f" (exported from {file_content.original_mime_type})"
|
|
170
|
+
|
|
171
|
+
return ToolResult(
|
|
172
|
+
content=(
|
|
173
|
+
f"Successfully retrieved content of '{file_content.name}' "
|
|
174
|
+
f"({file_content.mime_type}){export_info}."
|
|
175
|
+
),
|
|
176
|
+
structured_content=file_content.as_flat_dict(),
|
|
177
|
+
)
|
|
@@ -78,14 +78,14 @@ datarobot_genai/drmcp/test_utils/utils.py,sha256=esGKFv8aO31-Qg3owayeWp32BYe1CdY
|
|
|
78
78
|
datarobot_genai/drmcp/tools/__init__.py,sha256=0kq9vMkF7EBsS6lkEdiLibmUrghTQqosHbZ5k-V9a5g,578
|
|
79
79
|
datarobot_genai/drmcp/tools/clients/__init__.py,sha256=0kq9vMkF7EBsS6lkEdiLibmUrghTQqosHbZ5k-V9a5g,578
|
|
80
80
|
datarobot_genai/drmcp/tools/clients/atlassian.py,sha256=__M_uz7FrcbKCYRzeMn24DCEYD6OmFx_LuywHCxgXsA,6472
|
|
81
|
-
datarobot_genai/drmcp/tools/clients/confluence.py,sha256=
|
|
82
|
-
datarobot_genai/drmcp/tools/clients/gdrive.py,sha256=
|
|
81
|
+
datarobot_genai/drmcp/tools/clients/confluence.py,sha256=h_G0By_kDnJeWDT_d-IREsaZ5-0xB5GoLXOqblYP5MA,20706
|
|
82
|
+
datarobot_genai/drmcp/tools/clients/gdrive.py,sha256=e28XwX0C8E3nql85-_NbUEMB-4s0lsQ2f5spj9BgsgM,21455
|
|
83
83
|
datarobot_genai/drmcp/tools/clients/jira.py,sha256=Rm91JAyrNIqxu66-9rU1YqoRXVnWbEy-Ahvy6f6HlVg,9823
|
|
84
84
|
datarobot_genai/drmcp/tools/clients/s3.py,sha256=GmwzvurFdNfvxOooA8g5S4osRysHYU0S9ypg_177Glg,953
|
|
85
85
|
datarobot_genai/drmcp/tools/confluence/__init__.py,sha256=0kq9vMkF7EBsS6lkEdiLibmUrghTQqosHbZ5k-V9a5g,578
|
|
86
|
-
datarobot_genai/drmcp/tools/confluence/tools.py,sha256=
|
|
86
|
+
datarobot_genai/drmcp/tools/confluence/tools.py,sha256=_-ws65WLK8KZP_mKkf4yJ7ZunR8qdyoiMwHQX47MSMw,12362
|
|
87
87
|
datarobot_genai/drmcp/tools/gdrive/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
88
|
-
datarobot_genai/drmcp/tools/gdrive/tools.py,sha256=
|
|
88
|
+
datarobot_genai/drmcp/tools/gdrive/tools.py,sha256=EvoEr3AEI-xRldwCTZHiQfBRHQfLtgHuojTx8mXhlU4,7074
|
|
89
89
|
datarobot_genai/drmcp/tools/jira/__init__.py,sha256=0kq9vMkF7EBsS6lkEdiLibmUrghTQqosHbZ5k-V9a5g,578
|
|
90
90
|
datarobot_genai/drmcp/tools/jira/tools.py,sha256=dfkqTU2HH-7n44hX80ODFacKq0p0LOchFcZtIIKFNMM,9687
|
|
91
91
|
datarobot_genai/drmcp/tools/predictive/__init__.py,sha256=WuOHlNNEpEmcF7gVnhckruJRKU2qtmJLE3E7zoCGLDo,1030
|
|
@@ -111,9 +111,9 @@ datarobot_genai/nat/datarobot_llm_clients.py,sha256=Yu208Ed_p_4P3HdpuM7fYnKcXtim
|
|
|
111
111
|
datarobot_genai/nat/datarobot_llm_providers.py,sha256=aDoQcTeGI-odqydPXEX9OGGNFbzAtpqzTvHHEkmJuEQ,4963
|
|
112
112
|
datarobot_genai/nat/datarobot_mcp_client.py,sha256=35FzilxNp4VqwBYI0NsOc91-xZm1C-AzWqrOdDy962A,9612
|
|
113
113
|
datarobot_genai/nat/helpers.py,sha256=Q7E3ADZdtFfS8E6OQPyw2wgA6laQ58N3bhLj5CBWwJs,3265
|
|
114
|
-
datarobot_genai-0.2.
|
|
115
|
-
datarobot_genai-0.2.
|
|
116
|
-
datarobot_genai-0.2.
|
|
117
|
-
datarobot_genai-0.2.
|
|
118
|
-
datarobot_genai-0.2.
|
|
119
|
-
datarobot_genai-0.2.
|
|
114
|
+
datarobot_genai-0.2.23.dist-info/METADATA,sha256=5BfpvvJLwdoecSF1_TQsKLrgdzjfc2_vY9gvACOqGFo,6301
|
|
115
|
+
datarobot_genai-0.2.23.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
116
|
+
datarobot_genai-0.2.23.dist-info/entry_points.txt,sha256=jEW3WxDZ8XIK9-ISmTyt5DbmBb047rFlzQuhY09rGrM,284
|
|
117
|
+
datarobot_genai-0.2.23.dist-info/licenses/AUTHORS,sha256=isJGUXdjq1U7XZ_B_9AH8Qf0u4eX0XyQifJZ_Sxm4sA,80
|
|
118
|
+
datarobot_genai-0.2.23.dist-info/licenses/LICENSE,sha256=U2_VkLIktQoa60Nf6Tbt7E4RMlfhFSjWjcJJfVC-YCE,11341
|
|
119
|
+
datarobot_genai-0.2.23.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|