universal-mcp 0.1.8rc1__py3-none-any.whl → 0.1.8rc2__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.
- universal_mcp/applications/application.py +6 -5
- universal_mcp/applications/calendly/README.md +78 -0
- universal_mcp/applications/calendly/app.py +954 -0
- universal_mcp/applications/e2b/app.py +18 -12
- universal_mcp/applications/firecrawl/app.py +28 -1
- universal_mcp/applications/github/app.py +150 -107
- universal_mcp/applications/google_calendar/app.py +72 -137
- universal_mcp/applications/google_docs/app.py +35 -15
- universal_mcp/applications/google_drive/app.py +84 -55
- universal_mcp/applications/google_mail/app.py +143 -53
- universal_mcp/applications/google_sheet/app.py +61 -38
- universal_mcp/applications/markitdown/app.py +12 -11
- universal_mcp/applications/notion/app.py +199 -89
- universal_mcp/applications/perplexity/app.py +17 -15
- universal_mcp/applications/reddit/app.py +110 -101
- universal_mcp/applications/resend/app.py +14 -7
- universal_mcp/applications/serpapi/app.py +13 -6
- universal_mcp/applications/tavily/app.py +13 -10
- universal_mcp/applications/wrike/README.md +71 -0
- universal_mcp/applications/wrike/__init__.py +0 -0
- universal_mcp/applications/wrike/app.py +1044 -0
- universal_mcp/applications/youtube/README.md +82 -0
- universal_mcp/applications/youtube/__init__.py +0 -0
- universal_mcp/applications/youtube/app.py +986 -0
- universal_mcp/applications/zenquotes/app.py +13 -3
- universal_mcp/exceptions.py +8 -2
- universal_mcp/integrations/__init__.py +15 -1
- universal_mcp/integrations/integration.py +132 -27
- universal_mcp/servers/__init__.py +6 -15
- universal_mcp/servers/server.py +209 -153
- universal_mcp/stores/__init__.py +7 -2
- universal_mcp/stores/store.py +103 -42
- universal_mcp/tools/__init__.py +3 -0
- universal_mcp/tools/adapters.py +40 -0
- universal_mcp/tools/func_metadata.py +214 -0
- universal_mcp/tools/tools.py +285 -0
- universal_mcp/utils/docgen.py +277 -123
- universal_mcp/utils/docstring_parser.py +156 -0
- universal_mcp/utils/openapi.py +149 -40
- {universal_mcp-0.1.8rc1.dist-info → universal_mcp-0.1.8rc2.dist-info}/METADATA +7 -3
- universal_mcp-0.1.8rc2.dist-info/RECORD +71 -0
- universal_mcp-0.1.8rc1.dist-info/RECORD +0 -58
- /universal_mcp/{utils/bridge.py → applications/calendly/__init__.py} +0 -0
- {universal_mcp-0.1.8rc1.dist-info → universal_mcp-0.1.8rc2.dist-info}/WHEEL +0 -0
- {universal_mcp-0.1.8rc1.dist-info → universal_mcp-0.1.8rc2.dist-info}/entry_points.txt +0 -0
@@ -36,41 +36,51 @@ class GoogleDriveApp(APIApplication):
|
|
36
36
|
|
37
37
|
def get_drive_info(self) -> dict[str, Any]:
|
38
38
|
"""
|
39
|
-
|
39
|
+
Retrieves detailed information about the user's Google Drive storage and account.
|
40
40
|
|
41
41
|
Returns:
|
42
|
-
A dictionary containing information
|
43
|
-
|
42
|
+
A dictionary containing Drive information including storage quota (usage, limit) and user details (name, email, etc.).
|
43
|
+
|
44
|
+
Raises:
|
45
|
+
HTTPError: If the API request fails or returns an error status code
|
46
|
+
ConnectionError: If there are network connectivity issues
|
47
|
+
AuthenticationError: If the authentication credentials are invalid or expired
|
48
|
+
|
49
|
+
Tags:
|
50
|
+
get, info, storage, drive, quota, user, api, important
|
44
51
|
"""
|
45
52
|
url = f"{self.base_url}/about"
|
46
53
|
params = {"fields": "storageQuota,user"}
|
47
|
-
|
48
54
|
response = self._get(url, params=params)
|
49
55
|
return response.json()
|
50
56
|
|
51
57
|
def list_files(self, page_size: int = 10, query: str = None, order_by: str = None) -> dict[str, Any]:
|
52
58
|
"""
|
53
|
-
|
59
|
+
Lists and retrieves files from Google Drive with optional filtering, pagination, and sorting.
|
54
60
|
|
55
61
|
Args:
|
56
|
-
page_size: Maximum number of files to return (default: 10)
|
57
|
-
query:
|
58
|
-
order_by:
|
62
|
+
page_size: Maximum number of files to return per page (default: 10)
|
63
|
+
query: Optional search query string using Google Drive query syntax (e.g., "mimeType='image/jpeg'")
|
64
|
+
order_by: Optional field name to sort results by, with optional direction (e.g., "modifiedTime desc")
|
59
65
|
|
60
66
|
Returns:
|
61
|
-
|
67
|
+
Dictionary containing a list of files and metadata, including 'files' array and optional 'nextPageToken' for pagination
|
68
|
+
|
69
|
+
Raises:
|
70
|
+
HTTPError: Raised when the API request fails or returns an error status code
|
71
|
+
RequestException: Raised when network connectivity issues occur during the API request
|
72
|
+
|
73
|
+
Tags:
|
74
|
+
list, files, search, google-drive, pagination, important
|
62
75
|
"""
|
63
76
|
url = f"{self.base_url}/files"
|
64
77
|
params = {
|
65
78
|
"pageSize": page_size,
|
66
79
|
}
|
67
|
-
|
68
80
|
if query:
|
69
81
|
params["q"] = query
|
70
|
-
|
71
82
|
if order_by:
|
72
83
|
params["orderBy"] = order_by
|
73
|
-
|
74
84
|
response = self._get(url, params=params)
|
75
85
|
response.raise_for_status()
|
76
86
|
return response.json()
|
@@ -78,13 +88,20 @@ class GoogleDriveApp(APIApplication):
|
|
78
88
|
|
79
89
|
def get_file(self, file_id: str) -> dict[str, Any]:
|
80
90
|
"""
|
81
|
-
|
91
|
+
Retrieves detailed metadata for a specific file using its ID.
|
82
92
|
|
83
93
|
Args:
|
84
|
-
file_id:
|
94
|
+
file_id: String identifier of the file whose metadata should be retrieved
|
85
95
|
|
86
96
|
Returns:
|
87
|
-
|
97
|
+
Dictionary containing the file's metadata including properties such as name, size, type, and other attributes
|
98
|
+
|
99
|
+
Raises:
|
100
|
+
HTTPError: When the API request fails due to invalid file_id or network issues
|
101
|
+
JSONDecodeError: When the API response cannot be parsed as JSON
|
102
|
+
|
103
|
+
Tags:
|
104
|
+
retrieve, file, metadata, get, api, important
|
88
105
|
"""
|
89
106
|
url = f"{self.base_url}/files/{file_id}"
|
90
107
|
response = self._get(url)
|
@@ -92,13 +109,19 @@ class GoogleDriveApp(APIApplication):
|
|
92
109
|
|
93
110
|
def delete_file(self, file_id: str) -> dict[str, Any]:
|
94
111
|
"""
|
95
|
-
|
112
|
+
Deletes a specified file from Google Drive and returns a status message.
|
96
113
|
|
97
114
|
Args:
|
98
|
-
file_id: The
|
115
|
+
file_id: The unique identifier string of the file to be deleted from Google Drive
|
99
116
|
|
100
117
|
Returns:
|
101
|
-
A
|
118
|
+
A dictionary containing either a success message {'message': 'File deleted successfully'} or an error message {'error': 'error description'}
|
119
|
+
|
120
|
+
Raises:
|
121
|
+
Exception: When the DELETE request fails due to network issues, invalid file_id, insufficient permissions, or other API errors
|
122
|
+
|
123
|
+
Tags:
|
124
|
+
delete, file-management, google-drive, api, important
|
102
125
|
"""
|
103
126
|
url = f"{self.base_url}/files/{file_id}"
|
104
127
|
try:
|
@@ -115,54 +138,61 @@ class GoogleDriveApp(APIApplication):
|
|
115
138
|
mime_type: str = "text/plain"
|
116
139
|
) -> dict[str, Any]:
|
117
140
|
"""
|
118
|
-
|
141
|
+
Creates a new file in Google Drive with specified text content and returns the file's metadata.
|
119
142
|
|
120
143
|
Args:
|
121
144
|
file_name: Name of the file to create on Google Drive
|
122
145
|
text_content: Plain text content to be written to the file
|
123
|
-
parent_id: ID of the parent folder
|
124
|
-
mime_type: MIME type of the file (
|
146
|
+
parent_id: Optional ID of the parent folder where the file will be created
|
147
|
+
mime_type: MIME type of the file (defaults to 'text/plain')
|
125
148
|
|
126
149
|
Returns:
|
127
|
-
|
150
|
+
Dictionary containing metadata of the created file including ID, name, and other Google Drive file properties
|
151
|
+
|
152
|
+
Raises:
|
153
|
+
HTTPStatusError: Raised when the API request fails during file creation or content upload
|
154
|
+
UnicodeEncodeError: Raised when the text_content cannot be encoded in UTF-8
|
155
|
+
|
156
|
+
Tags:
|
157
|
+
create, file, upload, drive, text, important, storage, document
|
128
158
|
"""
|
129
159
|
metadata = {
|
130
160
|
"name": file_name,
|
131
161
|
"mimeType": mime_type
|
132
162
|
}
|
133
|
-
|
134
163
|
if parent_id:
|
135
164
|
metadata["parents"] = [parent_id]
|
136
|
-
|
137
165
|
create_url = f"{self.base_url}/files"
|
138
166
|
create_response = self._post(create_url, data=metadata)
|
139
167
|
file_data = create_response.json()
|
140
168
|
file_id = file_data.get("id")
|
141
|
-
|
142
|
-
# Step 2: Update the file with text content
|
143
169
|
upload_url = f"https://www.googleapis.com/upload/drive/v3/files/{file_id}?uploadType=media"
|
144
170
|
upload_headers = self._get_headers()
|
145
171
|
upload_headers["Content-Type"] = f"{mime_type}; charset=utf-8"
|
146
|
-
|
147
172
|
upload_response = httpx.patch(
|
148
173
|
upload_url,
|
149
174
|
headers=upload_headers,
|
150
175
|
content=text_content.encode("utf-8")
|
151
176
|
)
|
152
177
|
upload_response.raise_for_status()
|
153
|
-
|
154
178
|
response_data = upload_response.json()
|
155
179
|
return response_data
|
156
180
|
|
157
181
|
def find_folder_id_by_name(self, folder_name: str) -> str | None:
|
158
182
|
"""
|
159
|
-
|
183
|
+
Searches for and retrieves a Google Drive folder's ID using its name.
|
160
184
|
|
161
185
|
Args:
|
162
|
-
folder_name: The name of the folder to
|
163
|
-
|
186
|
+
folder_name: The name of the folder to search for in Google Drive
|
187
|
+
|
164
188
|
Returns:
|
165
|
-
The folder ID if found, None
|
189
|
+
str | None: The folder's ID if a matching folder is found, None if no folder is found or if an error occurs
|
190
|
+
|
191
|
+
Raises:
|
192
|
+
Exception: Caught internally and logged when API requests fail or response parsing errors occur
|
193
|
+
|
194
|
+
Tags:
|
195
|
+
search, find, google-drive, folder, query, api, utility
|
166
196
|
"""
|
167
197
|
query = f"mimeType='application/vnd.google-apps.folder' and name='{folder_name}' and trashed=false"
|
168
198
|
try:
|
@@ -178,23 +208,26 @@ class GoogleDriveApp(APIApplication):
|
|
178
208
|
|
179
209
|
def create_folder(self, folder_name: str, parent_id: str = None) -> dict[str, Any]:
|
180
210
|
"""
|
181
|
-
|
211
|
+
Creates a new folder in Google Drive with optional parent folder specification
|
182
212
|
|
183
213
|
Args:
|
184
214
|
folder_name: Name of the folder to create
|
185
|
-
parent_id: ID of the parent folder
|
186
|
-
|
187
|
-
|
215
|
+
parent_id: ID or name of the parent folder. Can be either a folder ID string or a folder name that will be automatically looked up
|
216
|
+
|
188
217
|
Returns:
|
189
|
-
|
218
|
+
Dictionary containing the created folder's metadata including its ID, name, and other Drive-specific information
|
219
|
+
|
220
|
+
Raises:
|
221
|
+
ValueError: Raised when a parent folder name is provided but cannot be found in Google Drive
|
222
|
+
|
223
|
+
Tags:
|
224
|
+
create, folder, drive, storage, important, management
|
190
225
|
"""
|
191
226
|
import re
|
192
|
-
|
193
227
|
metadata = {
|
194
228
|
"name": folder_name,
|
195
229
|
"mimeType": "application/vnd.google-apps.folder"
|
196
230
|
}
|
197
|
-
|
198
231
|
if parent_id:
|
199
232
|
if not re.match(r"^[a-zA-Z0-9_-]{28,33}$", parent_id):
|
200
233
|
found_id = self.find_folder_id_by_name(parent_id)
|
@@ -204,10 +237,8 @@ class GoogleDriveApp(APIApplication):
|
|
204
237
|
raise ValueError(f"Could not find parent folder with name: {parent_id}")
|
205
238
|
else:
|
206
239
|
metadata["parents"] = [parent_id]
|
207
|
-
|
208
240
|
url = f"{self.base_url}/files"
|
209
241
|
params = {"supportsAllDrives": "true"}
|
210
|
-
|
211
242
|
response = self._post(url, data=metadata, params=params)
|
212
243
|
return response.json()
|
213
244
|
|
@@ -219,36 +250,35 @@ class GoogleDriveApp(APIApplication):
|
|
219
250
|
mime_type: str = None
|
220
251
|
) -> dict[str, Any]:
|
221
252
|
"""
|
222
|
-
|
223
|
-
|
224
|
-
This method is suitable for files under 5MB in size. It automatically
|
225
|
-
reads the file from the provided path.
|
253
|
+
Uploads a file to Google Drive by creating a file metadata entry and uploading the binary content.
|
226
254
|
|
227
255
|
Args:
|
228
256
|
file_name: Name to give the file on Google Drive
|
229
257
|
file_path: Path to the local file to upload
|
230
|
-
parent_id: ID of the parent folder to create the file in
|
231
|
-
mime_type: MIME type of the file
|
232
|
-
Examples: 'image/jpeg', 'image/png', 'application/pdf', 'text/csv'
|
258
|
+
parent_id: Optional ID of the parent folder to create the file in
|
259
|
+
mime_type: MIME type of the file (e.g., 'image/jpeg', 'image/png', 'application/pdf')
|
233
260
|
|
234
261
|
Returns:
|
235
|
-
|
236
|
-
"""
|
262
|
+
Dictionary containing the uploaded file's metadata from Google Drive
|
237
263
|
|
238
|
-
|
264
|
+
Raises:
|
265
|
+
FileNotFoundError: When the specified file_path does not exist or is not accessible
|
266
|
+
HTTPError: When the API request fails or returns an error status code
|
267
|
+
IOError: When there are issues reading the file content
|
268
|
+
|
269
|
+
Tags:
|
270
|
+
upload, file-handling, google-drive, api, important, binary, storage
|
271
|
+
"""
|
239
272
|
metadata = {
|
240
273
|
"name": file_name,
|
241
274
|
"mimeType": mime_type
|
242
275
|
}
|
243
|
-
|
244
276
|
if parent_id:
|
245
277
|
metadata["parents"] = [parent_id]
|
246
|
-
|
247
278
|
create_url = f"{self.base_url}/files"
|
248
279
|
create_response = self._post(create_url, data=metadata)
|
249
280
|
file_data = create_response.json()
|
250
281
|
file_id = file_data.get("id")
|
251
|
-
|
252
282
|
with open(file_path, 'rb') as file_content:
|
253
283
|
binary_content = file_content.read()
|
254
284
|
|
@@ -262,7 +292,6 @@ class GoogleDriveApp(APIApplication):
|
|
262
292
|
content=binary_content
|
263
293
|
)
|
264
294
|
upload_response.raise_for_status()
|
265
|
-
|
266
295
|
response_data = upload_response.json()
|
267
296
|
return response_data
|
268
297
|
|
@@ -30,15 +30,24 @@ class GoogleMailApp(APIApplication):
|
|
30
30
|
}
|
31
31
|
|
32
32
|
def send_email(self, to: str, subject: str, body: str) -> str:
|
33
|
-
"""
|
34
|
-
|
33
|
+
"""
|
34
|
+
Sends an email using the Gmail API and returns a confirmation or error message.
|
35
|
+
|
35
36
|
Args:
|
36
37
|
to: The email address of the recipient
|
37
|
-
subject: The subject of the email
|
38
|
-
body: The
|
39
|
-
|
38
|
+
subject: The subject line of the email
|
39
|
+
body: The main content of the email message
|
40
|
+
|
40
41
|
Returns:
|
41
|
-
A confirmation message
|
42
|
+
A string containing either a success confirmation message or an error description
|
43
|
+
|
44
|
+
Raises:
|
45
|
+
NotAuthorizedError: When Gmail API authentication is not valid or has expired
|
46
|
+
KeyError: When required configuration keys are missing
|
47
|
+
Exception: For any other unexpected errors during the email sending process
|
48
|
+
|
49
|
+
Tags:
|
50
|
+
send, email, api, communication, important
|
42
51
|
"""
|
43
52
|
try:
|
44
53
|
url = f"{self.base_api_url}/messages/send"
|
@@ -89,15 +98,24 @@ class GoogleMailApp(APIApplication):
|
|
89
98
|
raise
|
90
99
|
|
91
100
|
def create_draft(self, to: str, subject: str, body: str) -> str:
|
92
|
-
"""
|
93
|
-
|
101
|
+
"""
|
102
|
+
Creates a draft email message in Gmail using the Gmail API and returns a confirmation status.
|
103
|
+
|
94
104
|
Args:
|
95
105
|
to: The email address of the recipient
|
96
|
-
subject: The subject of the email
|
97
|
-
body: The
|
98
|
-
|
106
|
+
subject: The subject line of the draft email
|
107
|
+
body: The main content/message of the draft email
|
108
|
+
|
99
109
|
Returns:
|
100
|
-
A
|
110
|
+
A string containing either a success message with the draft ID or an error message describing the failure
|
111
|
+
|
112
|
+
Raises:
|
113
|
+
NotAuthorizedError: When the user's Gmail API authorization is invalid or expired
|
114
|
+
KeyError: When required configuration keys are missing
|
115
|
+
Exception: For general API errors, network issues, or other unexpected problems
|
116
|
+
|
117
|
+
Tags:
|
118
|
+
create, email, draft, gmail, api, important
|
101
119
|
"""
|
102
120
|
try:
|
103
121
|
url = f"{self.base_api_url}/drafts"
|
@@ -129,13 +147,22 @@ class GoogleMailApp(APIApplication):
|
|
129
147
|
return f"Error creating draft: {type(e).__name__} - {str(e)}"
|
130
148
|
|
131
149
|
def send_draft(self, draft_id: str) -> str:
|
132
|
-
"""
|
133
|
-
|
150
|
+
"""
|
151
|
+
Sends an existing draft email using the Gmail API and returns a confirmation message.
|
152
|
+
|
134
153
|
Args:
|
135
|
-
draft_id: The
|
136
|
-
|
154
|
+
draft_id: The unique identifier of the Gmail draft to be sent
|
155
|
+
|
137
156
|
Returns:
|
138
|
-
A
|
157
|
+
A string containing either a success message with the sent message ID or an error message detailing the failure reason
|
158
|
+
|
159
|
+
Raises:
|
160
|
+
NotAuthorizedError: When the user's Gmail API authorization is invalid or expired
|
161
|
+
KeyError: When required configuration keys are missing from the API response
|
162
|
+
Exception: For other unexpected errors during the API request or response handling
|
163
|
+
|
164
|
+
Tags:
|
165
|
+
send, email, api, communication, important, draft
|
139
166
|
"""
|
140
167
|
try:
|
141
168
|
url = f"{self.base_api_url}/drafts/send"
|
@@ -165,14 +192,23 @@ class GoogleMailApp(APIApplication):
|
|
165
192
|
return f"Error sending draft: {type(e).__name__} - {str(e)}"
|
166
193
|
|
167
194
|
def get_draft(self, draft_id: str, format: str = "full") -> str:
|
168
|
-
"""
|
169
|
-
|
195
|
+
"""
|
196
|
+
Retrieves and formats a specific draft email from Gmail by its ID
|
197
|
+
|
170
198
|
Args:
|
171
|
-
draft_id:
|
172
|
-
format:
|
173
|
-
|
199
|
+
draft_id: String identifier of the draft email to retrieve
|
200
|
+
format: Output format of the draft (options: minimal, full, raw, metadata). Defaults to 'full'
|
201
|
+
|
174
202
|
Returns:
|
175
|
-
|
203
|
+
A formatted string containing the draft email details (ID, recipient, subject) or an error message if retrieval fails
|
204
|
+
|
205
|
+
Raises:
|
206
|
+
NotAuthorizedError: When the user's Gmail authorization is invalid or expired
|
207
|
+
KeyError: When required configuration keys or response data fields are missing
|
208
|
+
Exception: For any other unexpected errors during draft retrieval
|
209
|
+
|
210
|
+
Tags:
|
211
|
+
retrieve, email, gmail, draft, api, format, important
|
176
212
|
"""
|
177
213
|
try:
|
178
214
|
url = f"{self.base_api_url}/drafts/{draft_id}"
|
@@ -223,15 +259,24 @@ class GoogleMailApp(APIApplication):
|
|
223
259
|
def list_drafts(
|
224
260
|
self, max_results: int = 20, q: str = None, include_spam_trash: bool = False
|
225
261
|
) -> str:
|
226
|
-
"""
|
227
|
-
|
262
|
+
"""
|
263
|
+
Retrieves and formats a list of email drafts from the user's Gmail mailbox with optional filtering and pagination.
|
264
|
+
|
228
265
|
Args:
|
229
266
|
max_results: Maximum number of drafts to return (max 500, default 20)
|
230
|
-
q: Search query to filter drafts
|
231
|
-
include_spam_trash:
|
232
|
-
|
267
|
+
q: Search query string to filter drafts using Gmail search syntax (default None)
|
268
|
+
include_spam_trash: Boolean flag to include drafts from spam and trash folders (default False)
|
269
|
+
|
233
270
|
Returns:
|
234
|
-
A formatted list of
|
271
|
+
A formatted string containing the list of draft IDs and count information, or an error message if the request fails
|
272
|
+
|
273
|
+
Raises:
|
274
|
+
NotAuthorizedError: When the Gmail API authentication is missing or invalid
|
275
|
+
KeyError: When required configuration keys are missing
|
276
|
+
Exception: For general errors during API communication or data processing
|
277
|
+
|
278
|
+
Tags:
|
279
|
+
list, email, drafts, gmail, api, search, query, pagination, important
|
235
280
|
"""
|
236
281
|
try:
|
237
282
|
url = f"{self.base_api_url}/drafts"
|
@@ -286,13 +331,22 @@ class GoogleMailApp(APIApplication):
|
|
286
331
|
return f"Error listing drafts: {type(e).__name__} - {str(e)}"
|
287
332
|
|
288
333
|
def get_message(self, message_id: str) -> str:
|
289
|
-
"""
|
290
|
-
|
334
|
+
"""
|
335
|
+
Retrieves and formats a specific email message from Gmail API by its ID, including sender, recipient, date, subject, and message preview.
|
336
|
+
|
291
337
|
Args:
|
292
|
-
message_id: The
|
293
|
-
|
338
|
+
message_id: The unique identifier of the Gmail message to retrieve
|
339
|
+
|
294
340
|
Returns:
|
295
|
-
|
341
|
+
A formatted string containing the message details (ID, From, To, Date, Subject, Preview) or an error message if the retrieval fails
|
342
|
+
|
343
|
+
Raises:
|
344
|
+
NotAuthorizedError: When the request lacks proper Gmail API authorization
|
345
|
+
KeyError: When required configuration keys or message fields are missing
|
346
|
+
Exception: For general API communication errors or unexpected issues
|
347
|
+
|
348
|
+
Tags:
|
349
|
+
retrieve, email, format, api, gmail, message, important
|
296
350
|
"""
|
297
351
|
try:
|
298
352
|
url = f"{self.base_api_url}/messages/{message_id}"
|
@@ -350,15 +404,24 @@ class GoogleMailApp(APIApplication):
|
|
350
404
|
def list_messages(
|
351
405
|
self, max_results: int = 20, q: str = None, include_spam_trash: bool = False
|
352
406
|
) -> str:
|
353
|
-
"""
|
354
|
-
|
407
|
+
"""
|
408
|
+
Retrieves and formats a list of messages from the user's Gmail mailbox with optional filtering and pagination support.
|
409
|
+
|
355
410
|
Args:
|
356
411
|
max_results: Maximum number of messages to return (max 500, default 20)
|
357
|
-
q: Search query to filter messages
|
358
|
-
include_spam_trash:
|
359
|
-
|
412
|
+
q: Search query string to filter messages using Gmail search syntax
|
413
|
+
include_spam_trash: Boolean flag to include messages from spam and trash folders (default False)
|
414
|
+
|
360
415
|
Returns:
|
361
|
-
A formatted list of
|
416
|
+
A formatted string containing the list of message IDs and thread IDs, or an error message if the operation fails
|
417
|
+
|
418
|
+
Raises:
|
419
|
+
NotAuthorizedError: When the Gmail API authentication is invalid or missing
|
420
|
+
KeyError: When required configuration keys are missing
|
421
|
+
Exception: For general API errors, network issues, or other unexpected problems
|
422
|
+
|
423
|
+
Tags:
|
424
|
+
list, messages, gmail, search, query, pagination, important
|
362
425
|
"""
|
363
426
|
try:
|
364
427
|
url = f"{self.base_api_url}/messages"
|
@@ -417,10 +480,21 @@ class GoogleMailApp(APIApplication):
|
|
417
480
|
return f"Error listing messages: {type(e).__name__} - {str(e)}"
|
418
481
|
|
419
482
|
def list_labels(self) -> str:
|
420
|
-
"""
|
421
|
-
|
483
|
+
"""
|
484
|
+
Retrieves and formats a list of all labels (both system and user-created) from the user's Gmail account, organizing them by type and sorting them alphabetically.
|
485
|
+
|
486
|
+
Args:
|
487
|
+
None: This method takes no arguments
|
488
|
+
|
422
489
|
Returns:
|
423
|
-
A formatted list of labels or an error message
|
490
|
+
A formatted string containing a list of Gmail labels categorized by type (system and user), with their IDs, or an error message if the operation fails.
|
491
|
+
|
492
|
+
Raises:
|
493
|
+
NotAuthorizedError: Raised when the user's Gmail authorization is invalid or missing
|
494
|
+
Exception: Raised when any other unexpected error occurs during the API request or data processing
|
495
|
+
|
496
|
+
Tags:
|
497
|
+
list, gmail, labels, fetch, organize, important, management
|
424
498
|
"""
|
425
499
|
try:
|
426
500
|
url = f"{self.base_api_url}/labels"
|
@@ -486,13 +560,21 @@ class GoogleMailApp(APIApplication):
|
|
486
560
|
return f"Error listing labels: {type(e).__name__} - {str(e)}"
|
487
561
|
|
488
562
|
def create_label(self, name: str) -> str:
|
489
|
-
"""
|
490
|
-
|
563
|
+
"""
|
564
|
+
Creates a new Gmail label with specified visibility settings and returns creation status details.
|
565
|
+
|
491
566
|
Args:
|
492
567
|
name: The display name of the label to create
|
493
|
-
|
568
|
+
|
494
569
|
Returns:
|
495
|
-
A
|
570
|
+
A formatted string containing the creation status, including the new label's name and ID if successful, or an error message if the creation fails
|
571
|
+
|
572
|
+
Raises:
|
573
|
+
NotAuthorizedError: Raised when the request lacks proper Gmail API authorization
|
574
|
+
Exception: Raised for any other unexpected errors during label creation
|
575
|
+
|
576
|
+
Tags:
|
577
|
+
create, label, gmail, management, important
|
496
578
|
"""
|
497
579
|
try:
|
498
580
|
url = f"{self.base_api_url}/labels"
|
@@ -531,13 +613,21 @@ class GoogleMailApp(APIApplication):
|
|
531
613
|
return f"Error creating label: {type(e).__name__} - {str(e)}"
|
532
614
|
|
533
615
|
def get_profile(self) -> str:
|
534
|
-
"""
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
616
|
+
"""
|
617
|
+
Retrieves and formats the user's Gmail profile information including email address, message count, thread count, and history ID.
|
618
|
+
|
619
|
+
Args:
|
620
|
+
None: This method takes no arguments besides self
|
621
|
+
|
539
622
|
Returns:
|
540
|
-
A formatted string containing the user's profile information or an error message
|
623
|
+
A formatted string containing the user's Gmail profile information or an error message if the request fails
|
624
|
+
|
625
|
+
Raises:
|
626
|
+
NotAuthorizedError: Raised when the user's credentials are invalid or authorization is required
|
627
|
+
Exception: Raised for any other unexpected errors during the API request or data processing
|
628
|
+
|
629
|
+
Tags:
|
630
|
+
fetch, profile, gmail, user-info, api-request, important
|
541
631
|
"""
|
542
632
|
try:
|
543
633
|
url = f"{self.base_api_url}/profile"
|