MCP Tools Reference: drivemcp.googleapis.com

工具:get_file_metadata

呼叫這項工具,即可尋找使用者雲端硬碟檔案的一般中繼資料。

如果找不到檔案,請嘗試使用 search_files 等其他工具,尋找使用者要求的檔案。

下列範例示範如何使用 curl 叫用 get_file_metadata 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": "get_file_metadata",
    "arguments": {
      // provide these details according to the tool's MCP specification
    }
  },
  "jsonrpc": "2.0",
  "id": 1
}'
                

輸入內容的結構定義

要求取得檔案。

GetFileRequest

JSON 表示法
{
  "fileId": string,

  "excludeContentSnippets": boolean
}
欄位
fileId

string

必填。要擷取的檔案 ID。

聯集欄位 _exclude_content_snippets

_exclude_content_snippets 只能是下列其中一項:

excludeContentSnippets

boolean

設為 True 時,回覆中不會包含內容摘要。

輸出內容的結構定義

檔案資源。

檔案

JSON 表示法
{
  "id": string,
  "title": string,
  "parentId": string,

  "mimeType": string

  "fileSize": string

  "description": string

  "fileExtension": string

  "contentSnippet": string

  "viewUrl": string

  "sharedWithMeTime": string

  "createdTime": string

  "modifiedTime": string

  "viewedByMeTime": string

  "owner": string

  "canAddChildren": boolean
}
欄位
id

string

擷取檔案的 ID。

title

string

檔案標題。

parentId

string

檔案父項的 ID (選用)。

聯集欄位 _mime_type

_mime_type 只能是下列其中一項:

mimeType

string

檔案的 MIME 類型。

聯集欄位 _file_size

_file_size 只能是下列其中一項:

fileSize

string (int64 format)

檔案大小 (以位元組為單位)。

聯集欄位 _description

_description 只能是下列其中一項:

description

string

檔案說明。

聯集欄位 _file_extension

_file_extension 只能是下列其中一項:

fileExtension

string

檔案的原始副檔名,只有儲存在雲端硬碟中的檔案才會填入這個值。

聯集欄位 _content_snippet

_content_snippet 只能是下列其中一項:

contentSnippet

string

系統根據檔案內容生成的摘要。

聯集欄位 _view_url

_view_url 只能是下列其中一項:

viewUrl

string

查看檔案的網址。

聯集欄位 _shared_with_me_time

_shared_with_me_time 只能是下列其中一項:

sharedWithMeTime

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"

聯集欄位 _created_time

_created_time 只能是下列其中一項:

createdTime

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"

聯集欄位 _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"

聯集欄位 _viewed_by_me_time

_viewed_by_me_time 只能是下列其中一項:

viewedByMeTime

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"

聯集欄位 _owner

_owner 只能是下列其中一項:

owner

string

檔案擁有者的電子郵件地址。

聯集欄位 _can_add_children

_can_add_children 只能是下列其中一項:

canAddChildren

boolean

要求者是否可將孩子新增至這個資料夾。如果不是資料夾類型,這項屬性一律為 false。

時間戳記

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 之間 (含)。

工具註解

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

授權範圍

需要下列其中一種 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