Skip to content

Commit 4dcace8

Browse files
authored
Docs: Update Google Drive (#602)
Update google drive
1 parent faa3c74 commit 4dcace8

23 files changed

+1088
-85
lines changed

app/en/mcp-servers/productivity/google-drive/page.mdx

Lines changed: 271 additions & 24 deletions
Large diffs are not rendered by default.
Lines changed: 71 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,80 @@
1-
# GoogleDrive Reference
1+
# Google Drive Reference
22

3-
Below is a reference of enumerations used by some tools in the GoogleDrive MCP Server:
3+
Below is a reference of enumerations used by some tools in the Google Drive MCP Server:
44

55
## OrderBy
66

7-
- **CREATED_TIME**: `createdTime`
8-
- **CREATED_TIME_DESC**: `createdTime desc`
9-
- **FOLDER**: `folder`
10-
- **FOLDER_DESC**: `folder desc`
11-
- **MODIFIED_BY_ME_TIME**: `modifiedByMeTime`
12-
- **MODIFIED_BY_ME_TIME_DESC**: `modifiedByMeTime desc`
13-
- **MODIFIED_TIME**: `modifiedTime`
14-
- **MODIFIED_TIME_DESC**: `modifiedTime desc`
15-
- **NAME**: `name`
16-
- **NAME_DESC**: `name desc`
17-
- **NAME_NATURAL**: `name_natural`
18-
- **NAME_NATURAL_DESC**: `name_natural desc`
19-
- **QUOTA_BYTES_USED**: `quotaBytesUsed`
20-
- **QUOTA_BYTES_USED_DESC**: `quotaBytesUsed desc`
21-
- **RECENCY**: `recency`
22-
- **RECENCY_DESC**: `recency desc`
23-
- **SHARED_WITH_ME_TIME**: `sharedWithMeTime`
24-
- **SHARED_WITH_ME_TIME_DESC**: `sharedWithMeTime desc`
25-
- **STARRED**: `starred`
26-
- **STARRED_DESC**: `starred desc`
27-
- **VIEWED_BY_ME_TIME**: `viewedByMeTime`
28-
- **VIEWED_BY_ME_TIME_DESC**: `viewedByMeTime desc`
7+
Sort order options for listing and searching files.
8+
9+
- **CREATED_TIME**: `createdTime` - When the file was created (ascending)
10+
- **CREATED_TIME_DESC**: `createdTime desc` - When the file was created (descending)
11+
- **FOLDER**: `folder` - The folder ID, sorted using alphabetical ordering (ascending)
12+
- **FOLDER_DESC**: `folder desc` - The folder ID, sorted using alphabetical ordering (descending)
13+
- **MODIFIED_BY_ME_TIME**: `modifiedByMeTime` - The last time the file was modified by the user (ascending)
14+
- **MODIFIED_BY_ME_TIME_DESC**: `modifiedByMeTime desc` - The last time the file was modified by the user (descending)
15+
- **MODIFIED_TIME**: `modifiedTime` - The last time the file was modified by anyone (ascending)
16+
- **MODIFIED_TIME_DESC**: `modifiedTime desc` - The last time the file was modified by anyone (descending)
17+
- **NAME**: `name` - The name of the file, sorted alphabetically (ascending)
18+
- **NAME_DESC**: `name desc` - The name of the file, sorted alphabetically (descending)
19+
- **NAME_NATURAL**: `name_natural` - The name of the file, sorted using natural sort ordering (ascending)
20+
- **NAME_NATURAL_DESC**: `name_natural desc` - The name of the file, sorted using natural sort ordering (descending)
21+
- **QUOTA_BYTES_USED**: `quotaBytesUsed` - The number of storage quota bytes used by the file (ascending)
22+
- **QUOTA_BYTES_USED_DESC**: `quotaBytesUsed desc` - The number of storage quota bytes used by the file (descending)
23+
- **RECENCY**: `recency` - The most recent timestamp from the file's date-time fields (ascending)
24+
- **RECENCY_DESC**: `recency desc` - The most recent timestamp from the file's date-time fields (descending)
25+
- **SHARED_WITH_ME_TIME**: `sharedWithMeTime` - When the file was shared with the user (ascending)
26+
- **SHARED_WITH_ME_TIME_DESC**: `sharedWithMeTime desc` - When the file was shared with the user (descending)
27+
- **STARRED**: `starred` - Whether the user has starred the file (ascending)
28+
- **STARRED_DESC**: `starred desc` - Whether the user has starred the file (descending)
29+
- **VIEWED_BY_ME_TIME**: `viewedByMeTime` - The last time the file was viewed by the user (ascending)
30+
- **VIEWED_BY_ME_TIME_DESC**: `viewedByMeTime desc` - The last time the file was viewed by the user (descending)
2931

3032
## GoogleDriveFileType
3133

32-
- **SPREADSHEET**: `spreadsheet`
33-
- **SLIDES**: `slides`
34-
- **DOCUMENT**: `document`
35-
- **DRAWING**: `drawing`
36-
- **FORM**: `form`
37-
- **FOLDER**: `folder`
38-
- **IMAGE**: `image`
39-
- **VIDEO**: `video`
40-
- **AUDIO**: `audio`
41-
- **SCRIPT**: `script`
42-
- **SITES**: `sites`
43-
- **PDF**: `pdf`
34+
File type filters for searching files.
35+
36+
- **SPREADSHEET**: `spreadsheet` - Google Sheets
37+
- **SLIDES**: `slides` - Google Slides presentations
38+
- **DOCUMENT**: `document` - Google Docs
39+
- **DRAWING**: `drawing` - Google Drawings
40+
- **FORM**: `form` - Google Forms
41+
- **FOLDER**: `folder` - Folders
42+
- **IMAGE**: `image` - Image files (JPEG, PNG, GIF, WebP)
43+
- **VIDEO**: `video` - Video files (MP4, MPEG, QuickTime, WebM)
44+
- **AUDIO**: `audio` - Audio files (MP3, M4A, WAV)
45+
- **SCRIPT**: `script` - Google Apps Script
46+
- **SITES**: `sites` - Google Sites
47+
- **PDF**: `pdf` - PDF documents
48+
49+
## PermissionRole
50+
51+
Permission roles for sharing Google Drive files and folders.
52+
53+
- **READER**: `reader` - Can view and download
54+
- **COMMENTER**: `commenter` - Can view, download, and comment
55+
- **WRITER**: `writer` - Can view, download, comment, and edit
56+
- **OWNER**: `owner` - Full control (transfer ownership)
57+
58+
## UploadMimeType
59+
60+
Supported file types for uploading to Google Drive. This tool can only upload regular files - it cannot create Google Workspace files (Google Docs, Sheets, Slides).
61+
62+
### Text-based files
63+
64+
- **PLAIN_TEXT**: `text/plain` - .txt files
65+
- **CSV**: `text/csv` - .csv spreadsheet data
66+
- **JSON**: `application/json` - .json data files
67+
- **HTML**: `text/html` - .html web pages
68+
- **MARKDOWN**: `text/markdown` - .md documentation
69+
70+
### Documents
71+
72+
- **PDF**: `application/pdf` - .pdf documents
4473

74+
### Images
4575

76+
- **PNG**: `image/png` - .png images
77+
- **JPEG**: `image/jpeg` - .jpg/.jpeg images
78+
- **GIF**: `image/gif` - .gif images
79+
- **WEBP**: `image/webp` - .webp images
80+
- **SVG**: `image/svg+xml` - .svg vector graphics
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { Arcade } from "@arcadeai/arcadejs";
2+
3+
const client = new Arcade(); // Automatically finds the `ARCADE_API_KEY` env variable
4+
5+
const USER_ID = "{arcade_user_id}";
6+
const TOOL_NAME = "GoogleDrive.CreateFolder";
7+
8+
// Start the authorization process
9+
const authResponse = await client.tools.authorize({tool_name: TOOL_NAME, user_id: USER_ID});
10+
11+
if (authResponse.status !== "completed") {
12+
console.log(`Click this link to authorize: ${authResponse.url}`);
13+
}
14+
15+
// Wait for the authorization to complete
16+
await client.auth.waitForCompletion(authResponse);
17+
18+
const toolInput = {
19+
"folder_name": "My New Folder",
20+
"parent_folder_path_or_id": "Projects/2024"
21+
};
22+
23+
const response = await client.tools.execute({
24+
tool_name: TOOL_NAME,
25+
input: toolInput,
26+
user_id: USER_ID,
27+
});
28+
29+
console.log(JSON.stringify(response.output.value, null, 2));
30+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import json
2+
from arcadepy import Arcade
3+
4+
client = Arcade() # Automatically finds the `ARCADE_API_KEY` env variable
5+
6+
USER_ID = "{arcade_user_id}"
7+
TOOL_NAME = "GoogleDrive.CreateFolder"
8+
9+
auth_response = client.tools.authorize(tool_name=TOOL_NAME, user_id=USER_ID)
10+
11+
if auth_response.status != "completed":
12+
print(f"Click this link to authorize: {auth_response.url}")
13+
14+
# Wait for the authorization to complete
15+
client.auth.wait_for_completion(auth_response)
16+
17+
tool_input = {
18+
"folder_name": "My New Folder",
19+
"parent_folder_path_or_id": "Projects/2024"
20+
}
21+
22+
response = client.tools.execute(
23+
tool_name=TOOL_NAME,
24+
input=tool_input,
25+
user_id=USER_ID,
26+
)
27+
print(json.dumps(response.output.value, indent=2))
28+
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
import { Arcade } from "@arcadeai/arcadejs";
2+
import fs from "fs";
3+
import path from "path";
4+
import { fileURLToPath } from "url";
5+
6+
const client = new Arcade(); // Automatically finds the `ARCADE_API_KEY` env variable
7+
8+
const USER_ID = "{arcade_user_id}";
9+
const FILE_ID = "Projects/report.pdf";
10+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
11+
12+
// Authorize for download tools
13+
const authResponse = await client.tools.authorize({
14+
tool_name: "GoogleDrive.DownloadFile",
15+
user_id: USER_ID,
16+
});
17+
18+
if (authResponse.status !== "completed") {
19+
console.log(`Click this link to authorize: ${authResponse.url}`);
20+
}
21+
22+
// Wait for the authorization to complete
23+
await client.auth.waitForCompletion(authResponse);
24+
25+
// Step 1: Call download_file to get file info and possibly content
26+
console.log(`Downloading file: ${FILE_ID}`);
27+
const response = await client.tools.execute({
28+
tool_name: "GoogleDrive.DownloadFile",
29+
input: { file_path_or_id: FILE_ID },
30+
user_id: USER_ID,
31+
});
32+
33+
// Check for errors in the response
34+
if (response.output.error) {
35+
console.error(`Error: ${response.output.error}`);
36+
process.exit(1);
37+
}
38+
39+
const result = response.output.value;
40+
if (!result) {
41+
console.error(`Unexpected response: ${JSON.stringify(response)}`);
42+
process.exit(1);
43+
}
44+
45+
console.log(`File name: ${result.name}`);
46+
console.log(`MIME type: ${result.mimeType}`);
47+
console.log(`Size: ${result.size || "unknown"} bytes`);
48+
49+
// Get file extension from the original filename
50+
const originalName = result.name;
51+
const ext = path.extname(originalName) || ".bin";
52+
const outputPath = path.join(__dirname, `downloaded_file${ext}`);
53+
54+
let fileContent;
55+
56+
// Step 2: Check if chunked download is required
57+
if (result.requires_chunked_download) {
58+
console.log("\nFile requires chunked download. Downloading in chunks...");
59+
const chunkSize = result.recommended_chunk_size;
60+
61+
// Collect all chunks
62+
const chunks = [];
63+
let startByte = 0;
64+
65+
while (true) {
66+
console.log(`Downloading chunk starting at byte ${startByte}...`);
67+
const chunkResponse = await client.tools.execute({
68+
tool_name: "GoogleDrive.DownloadFileChunk",
69+
input: {
70+
file_path_or_id: FILE_ID,
71+
start_byte: startByte,
72+
chunk_size: chunkSize,
73+
},
74+
user_id: USER_ID,
75+
});
76+
77+
if (chunkResponse.output.error) {
78+
console.error(`Error downloading chunk: ${chunkResponse.output.error}`);
79+
process.exit(1);
80+
}
81+
82+
const chunkResult = chunkResponse.output.value;
83+
if (!chunkResult) {
84+
console.error(`Unexpected chunk response: ${JSON.stringify(chunkResponse)}`);
85+
process.exit(1);
86+
}
87+
88+
const chunkContent = Buffer.from(chunkResult.content, "base64");
89+
chunks.push(chunkContent);
90+
91+
console.log(`Progress: ${chunkResult.progress_percent}%`);
92+
93+
if (chunkResult.is_final_chunk) {
94+
break;
95+
}
96+
97+
startByte = chunkResult.next_start_byte;
98+
}
99+
100+
// Combine all chunks
101+
fileContent = Buffer.concat(chunks);
102+
} else {
103+
// Small file - content is included directly
104+
console.log("\nFile content received directly (small file).");
105+
fileContent = Buffer.from(result.content, "base64");
106+
}
107+
108+
// Save the file
109+
fs.writeFileSync(outputPath, fileContent);
110+
111+
console.log(`\nFile saved to: ${outputPath}`);
112+
console.log(`Total bytes written: ${fileContent.length}`);
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import base64
2+
import os
3+
4+
from arcadepy import Arcade
5+
6+
client = Arcade() # Automatically finds the `ARCADE_API_KEY` env variable
7+
8+
USER_ID = "{arcade_user_id}"
9+
FILE_ID = "Projects/report.pdf"
10+
OUTPUT_DIR = os.path.dirname(os.path.abspath(__file__))
11+
12+
# Authorize for download tools
13+
auth_response = client.tools.authorize(tool_name="GoogleDrive.DownloadFile", user_id=USER_ID)
14+
15+
if auth_response.status != "completed":
16+
print(f"Click this link to authorize: {auth_response.url}")
17+
18+
# Wait for the authorization to complete
19+
client.auth.wait_for_completion(auth_response)
20+
21+
# Step 1: Call download_file to get file info and possibly content
22+
print(f"Downloading file: {FILE_ID}")
23+
response = client.tools.execute(
24+
tool_name="GoogleDrive.DownloadFile",
25+
input={"file_path_or_id": FILE_ID},
26+
user_id=USER_ID,
27+
)
28+
29+
# Check for errors in the response
30+
if response.output.error:
31+
print(f"Error: {response.output.error}")
32+
exit(1)
33+
34+
result = response.output.value
35+
if result is None:
36+
print(f"Unexpected response: {response}")
37+
exit(1)
38+
39+
print(f"File name: {result['name']}")
40+
print(f"MIME type: {result['mimeType']}")
41+
print(f"Size: {result.get('size', 'unknown')} bytes")
42+
43+
# Get file extension from the original filename
44+
original_name = result["name"]
45+
_, ext = os.path.splitext(original_name)
46+
if not ext:
47+
ext = ".bin" # Default extension if none found
48+
49+
output_path = os.path.join(OUTPUT_DIR, f"downloaded_file{ext}")
50+
51+
# Step 2: Check if chunked download is required
52+
if result.get("requires_chunked_download"):
53+
print("\nFile requires chunked download. Downloading in chunks...")
54+
total_size = result["total_size_bytes"]
55+
chunk_size = result["recommended_chunk_size"]
56+
57+
# Collect all chunks
58+
chunks = []
59+
start_byte = 0
60+
61+
while True:
62+
print(f"Downloading chunk starting at byte {start_byte}...")
63+
chunk_response = client.tools.execute(
64+
tool_name="GoogleDrive.DownloadFileChunk",
65+
input={
66+
"file_path_or_id": FILE_ID,
67+
"start_byte": start_byte,
68+
"chunk_size": chunk_size,
69+
},
70+
user_id=USER_ID,
71+
)
72+
73+
if chunk_response.output.error:
74+
print(f"Error downloading chunk: {chunk_response.output.error}")
75+
exit(1)
76+
77+
chunk_result = chunk_response.output.value
78+
if chunk_result is None:
79+
print(f"Unexpected chunk response: {chunk_response}")
80+
exit(1)
81+
82+
chunk_content = base64.b64decode(chunk_result["content"])
83+
chunks.append(chunk_content)
84+
85+
print(f"Progress: {chunk_result['progress_percent']}%")
86+
87+
if chunk_result["is_final_chunk"]:
88+
break
89+
90+
start_byte = chunk_result["next_start_byte"]
91+
92+
# Combine all chunks and save
93+
file_content = b"".join(chunks)
94+
else:
95+
# Small file - content is included directly
96+
print("\nFile content received directly (small file).")
97+
file_content = base64.b64decode(result["content"])
98+
99+
# Save the file
100+
with open(output_path, "wb") as f:
101+
f.write(file_content)
102+
103+
print(f"\nFile saved to: {output_path}")
104+
print(f"Total bytes written: {len(file_content)}")

0 commit comments

Comments
 (0)