MCP Tools Reference: drivemcp.googleapis.com

工具:read_file_content

调用此工具可获取 Drive 文件的自然语言表示形式,并可选择获取其评论。

对于非常大的文件,文件内容可能不完整。文本表示形式会随时间变化,因此请勿对该工具返回的文本的特定格式做出假设。如果支持,评论标记将包含在内容中。

支持的 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

以文本格式返回的 Drive 文件内容。如果文件不支持文本格式,则可能为空。如果请求中的 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 与初始评论的 ID 相同。

联合字段 _status

_status 只能是下列其中一项:

status

enum (Status)

评论串的状态。

联合字段 _head_post

_head_post 只能是下列其中一项:

headPost

object (Post)

评论串中的第一条帖子。

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 规范化(即转换为 UTC 零时区格式并在末尾附加 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)

表示世界协调时间 (UTC) 的秒数(从 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