MCP Tools Reference: drivemcp.googleapis.com

工具:read_file_content

呼叫這項工具可擷取雲端硬碟檔案的自然語言表示法,以及選擇性擷取檔案的註解。

如果檔案過大,檔案內容可能不完整。文字表示法會隨時間改變,因此請勿假設這項工具傳回的文字格式。如果支援,內容中就會包含註解標記。

支援的 MIME 類型:

  • application/vnd.google-apps.document
  • application/vnd.google-apps.presentation
  • application/vnd.google-apps.spreadsheet
  • application/pdf
  • application/msword
  • application/vnd.openxmlformats-officedocument.wordprocessingml.document
  • application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
  • application/vnd.openxmlformats-officedocument.presentationml.presentation
  • application/vnd.oasis.opendocument.spreadsheet
  • application/vnd.oasis.opendocument.presentation
  • application/x-vnd.oasis.opendocument.text
  • image/png
  • image/jpeg
  • image/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

string

必填。要擷取的檔案 ID。

includeComments

boolean

是否要在回覆中加入留言。註解會內嵌在檔案的文字內容中,並對應至註解串。

輸出內容的結構定義

讀取檔案內容的回應。

ReadFileContentResponse

JSON 表示法
{
  "contentAnchoredComments": [
    {
      object (CommentThread)
    }
  ],
  "unanchoredComments": [
    {
      object (CommentThread)
    }
  ],

  "fileContent": string

  "textFormattingNotSupported": boolean
  // End of list of possible types for union field
  // _text_formatting_not_supported.

  "commentsNotSupported": boolean
}
欄位
contentAnchoredComments[]

object (CommentThread)

傳回的 file_content 中參照的註解串。

unanchoredComments[]

object (CommentThread)

無法錨定至發還檔案中特定內容的註解討論串。

聯集欄位 _file_content

_file_content 只能是下列其中一項:

fileContent

string

以文字格式傳回雲端硬碟檔案內容。如果系統不支援檔案的文字格式設定,這個欄位可能會空白。如果要求中的 include_comments 為 true,則可包含註解參照。

聯集欄位 _text_formatting_not_supported

_text_formatting_not_supported 只能是下列其中一項:

textFormattingNotSupported

boolean

這個檔案是否支援文字格式設定。如果為 true,file_content 會是空白。

聯集欄位 _comments_not_supported

_comments_not_supported 只能是下列其中一項:

commentsNotSupported

boolean

這個檔案是否支援回覆留言。只有在要求中 include_comments 為 true,且系統不支援註解時,才會顯示這項資訊。

CommentThread

JSON 表示法
{
  "replies": [
    {
      object (Post)
    }
  ],

  "commentId": string

  "status": enum (Status)

  "headPost": {
    object (Post)
  }
}
欄位
replies[]

object (Post)

留言串中第一則留言的回覆。

聯集欄位 _comment_id

_comment_id 只能是下列其中一項:

commentId

string

留言討論串的 ID。這與初始留言的 ID 相同。

聯集欄位 _status

_status 只能是下列其中一項:

status

enum (Status)

註解討論串的狀態。

聯集欄位 _head_post

_head_post 只能是下列其中一項:

headPost

object (Post)

留言討論串中的第一則貼文。

貼文

JSON 表示法
{

  "postId": string

  "content": string

  "authorName": string

  "modifiedTime": string
}
欄位

聯集欄位 _post_id

_post_id 只能是下列其中一項:

postId

string

貼文的 ID。

聯集欄位 _content

_content 只能是下列其中一項:

content

string

貼文內容。

聯集欄位 _author_name

_author_name 只能是下列其中一項:

authorName

string

貼文作者的名稱。

聯集欄位 _modified_time

_modified_time 只能是下列其中一項:

modifiedTime

string (Timestamp format)

貼文上次修改的時間。

使用 RFC 3339,產生的輸出內容一律會經過 Z 正規化,並使用 0、3、6 或 9 個小數位數,也接受「Z」以外的偏移量。範例:"2014-10-02T15:01:23Z""2014-10-02T15:01:23.045123456Z""2014-10-02T15:01:23+05:30"

時間戳記

JSON 表示法
{
  "seconds": string,
  "nanos": integer
}
欄位
seconds

string (int64 format)

代表自 Unix 紀元 1970-01-01T00:00:00Z 起算的世界標準時間秒數。必須介於 -62135596800 和 253402300799 之間 (含),對應至 0001-01-01T00:00:00Z 至 9999-12-31T23:59:59Z。

nanos

integer

以奈秒為單位的非負秒數小數。這個欄位是時間長度的奈秒部分,並非秒數的替代值。如果第二個值為負數,且包含分數,奈秒值仍須為非負數,且時間會往前計算。必須介於 0 至 999,999,999 之間 (含)。

狀態

定義註解討論串的狀態。

列舉
STATUS_UNSPECIFIED
OPEN
RESOLVED

工具註解

破壞性提示:❌ | 等冪提示:✅ | 唯讀提示:✅ | 開放世界提示:❌

授權範圍

需要下列其中一種 OAuth 範圍:

  • https://www.googleapis.com/auth/drive
  • https://www.googleapis.com/auth/drive.appdata
  • https://www.googleapis.com/auth/drive.file
  • https://www.googleapis.com/auth/drive.meet.readonly
  • https://www.googleapis.com/auth/drive.metadata
  • https://www.googleapis.com/auth/drive.metadata.readonly
  • https://www.googleapis.com/auth/drive.photos.readonly
  • https://www.googleapis.com/auth/drive.readonly