Tool: read_file_content
Call this tool to fetch a natural language representation of a Drive file, and optionally, its comments.
The file content may be incomplete for very large files. The text representation will change over time, so don't make assumptions about the particular format of the text returned by this tool. If supported, comment tags will be included in the content.
Supported Mime Types:
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
If the file is not found, try using other tools like search_files to find the file the user is requesting using keywords.
The following sample demonstrate how to use curl to invoke the read_file_content MCP tool.
| Curl Request |
|---|
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 }' |
Input Schema
Request to read file content with support for fetching comments.
ReadFileContentRequest
| JSON representation |
|---|
{ "fileId": string, "includeComments": boolean } |
| Fields | |
|---|---|
fileId |
Required. The ID of the file to retrieve. |
includeComments |
Whether to include comments in the response. Comments will be inlined in the text content of the file with a mapping to the comment threads. |
Output Schema
Response to read file content.
ReadFileContentResponse
| JSON representation |
|---|
{ "contentAnchoredComments": [ { object ( |
| Fields | |
|---|---|
contentAnchoredComments[] |
Comment threads referenced in the returned file_content. |
unanchoredComments[] |
Comment threads that could not be anchored to specific content in the returned file. |
Union field
|
|
fileContent |
Drive file content returned in text format. May be empty if the file is not supported for text formatting. Can include comment references if include_comments is true in the request. |
Union field
|
|
textFormattingNotSupported |
Whether text formatting is supported for this file. If true, file_content will be empty. |
Union field
|
|
commentsNotSupported |
Whether returning comments is supported for this file. Only present if include_comments is true in the request and comments are not supported. |
CommentThread
| JSON representation |
|---|
{ "replies": [ { object ( |
| Fields | |
|---|---|
replies[] |
The replies to the first post in the comment thread. |
Union field
|
|
commentId |
The id of the comment thread. This is the same id as the initial comment. |
Union field
|
|
status |
The status of the comment thread. |
Union field
|
|
headPost |
The first post in the comment thread. |
Post
| JSON representation |
|---|
{ "postId": string "content": string "authorName": string "modifiedTime": string } |
| Fields | |
|---|---|
Union field
|
|
postId |
The id of the post. |
Union field
|
|
content |
The content of the post. |
Union field
|
|
authorName |
The name of the author of the post. |
Union field
|
|
modifiedTime |
The time that the post was last modified. Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: |
Timestamp
| JSON representation |
|---|
{ "seconds": string, "nanos": integer } |
| Fields | |
|---|---|
seconds |
Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must be between -62135596800 and 253402300799 inclusive (which corresponds to 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z). |
nanos |
Non-negative fractions of a second at nanosecond resolution. This field is the nanosecond portion of the duration, not an alternative to seconds. Negative second values with fractions must still have non-negative nanos values that count forward in time. Must be between 0 and 999,999,999 inclusive. |
Status
Defines the status of a comment thread.
| Enums | |
|---|---|
STATUS_UNSPECIFIED |
|
OPEN |
|
RESOLVED |
|
Tool Annotations
Destructive Hint: ❌ | Idempotent Hint: ✅ | Read Only Hint: ✅ | Open World Hint: ❌
Authorization Scopes
Requires one of the following OAuth scopes:
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