工具:read_file_content
呼叫這項工具可擷取雲端硬碟檔案的自然語言表示法,以及選擇性擷取檔案的註解。
如果檔案過大,檔案內容可能不完整。文字表示法會隨時間改變,因此請勿假設這項工具傳回的文字格式。如果支援,內容中就會包含註解標記。
支援的 MIME 類型:
application/vnd.google-apps.documentapplication/vnd.google-apps.presentationapplication/vnd.google-apps.spreadsheetapplication/pdfapplication/mswordapplication/vnd.openxmlformats-officedocument.wordprocessingml.documentapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheetapplication/vnd.openxmlformats-officedocument.presentationml.presentationapplication/vnd.oasis.opendocument.spreadsheetapplication/vnd.oasis.opendocument.presentationapplication/x-vnd.oasis.opendocument.textimage/pngimage/jpegimage/jpg
如果找不到檔案,請嘗試使用其他工具 (例如 search_files),根據關鍵字尋找使用者要求的檔案。
下列範例示範如何使用 curl 叫用 read_file_content MCP 工具。
| Curl 要求 |
|---|
curl --location 'https://drivemcp.googleapis.com/mcp/v1' \ --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \ --header 'content-type: application/json' \ --header 'accept: application/json, text/event-stream' \ --data '{ "method": "tools/call", "params": { "name": "read_file_content", "arguments": { // provide these details according to the tool's MCP specification } }, "jsonrpc": "2.0", "id": 1 }' |
輸入內容的結構定義
要求讀取檔案內容,並支援擷取註解。
ReadFileContentRequest
| JSON 表示法 |
|---|
{ "fileId": string, "includeComments": boolean } |
| 欄位 | |
|---|---|
fileId |
必填。要擷取的檔案 ID。 |
includeComments |
是否要在回覆中加入留言。註解會內嵌在檔案的文字內容中,並對應至註解串。 |
輸出內容的結構定義
讀取檔案內容的回應。
ReadFileContentResponse
| JSON 表示法 |
|---|
{ "contentAnchoredComments": [ { object ( |
| 欄位 | |
|---|---|
contentAnchoredComments[] |
傳回的 file_content 中參照的註解串。 |
unanchoredComments[] |
無法錨定至發還檔案中特定內容的註解討論串。 |
聯集欄位
|
|
fileContent |
以文字格式傳回雲端硬碟檔案內容。如果系統不支援檔案的文字格式設定,這個欄位可能會空白。如果要求中的 include_comments 為 true,則可包含註解參照。 |
聯集欄位
|
|
textFormattingNotSupported |
這個檔案是否支援文字格式設定。如果為 true,file_content 會是空白。 |
聯集欄位
|
|
commentsNotSupported |
這個檔案是否支援回覆留言。只有在要求中 include_comments 為 true,且系統不支援註解時,才會顯示這項資訊。 |
CommentThread
| JSON 表示法 |
|---|
{ "replies": [ { object ( |
| 欄位 | |
|---|---|
replies[] |
留言串中第一則留言的回覆。 |
聯集欄位
|
|
commentId |
留言討論串的 ID。這與初始留言的 ID 相同。 |
聯集欄位
|
|
status |
註解討論串的狀態。 |
聯集欄位
|
|
headPost |
留言討論串中的第一則貼文。 |
貼文
| JSON 表示法 |
|---|
{ "postId": string "content": string "authorName": string "modifiedTime": string } |
| 欄位 | |
|---|---|
聯集欄位
|
|
postId |
貼文的 ID。 |
聯集欄位
|
|
content |
貼文內容。 |
聯集欄位
|
|
authorName |
貼文作者的名稱。 |
聯集欄位
|
|
modifiedTime |
貼文上次修改的時間。 使用 RFC 3339,產生的輸出內容一律會經過 Z 正規化,並使用 0、3、6 或 9 個小數位數,也接受「Z」以外的偏移量。範例: |
時間戳記
| JSON 表示法 |
|---|
{ "seconds": string, "nanos": integer } |
| 欄位 | |
|---|---|
seconds |
代表自 Unix 紀元 1970-01-01T00:00:00Z 起算的世界標準時間秒數。必須介於 -62135596800 和 253402300799 之間 (含),對應至 0001-01-01T00:00:00Z 至 9999-12-31T23:59:59Z。 |
nanos |
以奈秒為單位的非負秒數小數。這個欄位是時間長度的奈秒部分,並非秒數的替代值。如果第二個值為負數,且包含分數,奈秒值仍須為非負數,且時間會往前計算。必須介於 0 至 999,999,999 之間 (含)。 |
狀態
定義註解討論串的狀態。
| 列舉 | |
|---|---|
STATUS_UNSPECIFIED |
|
OPEN |
|
RESOLVED |
|
工具註解
破壞性提示:❌ | 等冪提示:✅ | 唯讀提示:✅ | 開放世界提示:❌
授權範圍
需要下列其中一種 OAuth 範圍:
https://www.googleapis.com/auth/drivehttps://www.googleapis.com/auth/drive.appdatahttps://www.googleapis.com/auth/drive.filehttps://www.googleapis.com/auth/drive.meet.readonlyhttps://www.googleapis.com/auth/drive.metadatahttps://www.googleapis.com/auth/drive.metadata.readonlyhttps://www.googleapis.com/auth/drive.photos.readonlyhttps://www.googleapis.com/auth/drive.readonly