工具:update_doc
使用批量更新请求更新文档。它接受 documents.batchUpdate 请求(以 JSON 格式)。
对应于 REST API 中的 documents.batchUpdate。
可能的更新列表如下:
replaceAllText:替换指定文本的所有实例。insertText:在指定位置插入文本。updateTextStyle:更新指定范围内的文字样式。createParagraphBullets:为段落创建项目符号。deleteParagraphBullets:从段落中删除项目符号。createNamedRange:创建命名范围。deleteNamedRange:删除指定范围。updateParagraphStyle:更新指定范围内的段落样式。deleteContentRange:从文档中删除内容。insertInlineImage:在指定位置插入内嵌图片。insertTable:在指定位置插入表格。insertTableRow:将空行插入表中。insertTableColumn:将空列插入表中。deleteTableRow:从表中删除一行。deleteTableColumn:从表中删除列。insertPageBreak:在指定位置插入分页符。deletePositionedObject:从文档中删除定位的对象。updateTableColumnProperties:更新表中的列的属性。updateTableCellStyle:更新表格单元格的样式。updateTableRowStyle:更新表格中的行样式。replaceImage:替换文档中的图片。updateDocumentStyle:更新文档的样式。insertInlineSheetsChart:在指定位置插入内嵌的 Google 表格图表。mergeTableCells:合并表格中的单元格。unmergeTableCells:取消合并表格中的单元格。refreshSheetsChart:刷新 Google 表格图表。createHeader:创建标题。createFooter:创建页脚。createFootnote:创建脚注。replaceNamedRangeContent:替换指定范围内的内容。updateEmbeddedObject:更新嵌入式对象的属性。updateSectionStyle:更新指定范围的版块样式。insertSectionBreak:在指定位置插入分节符。deleteHeader:从文档中删除标头。deleteFooter:从文档中删除页脚。pinTableHeaderRows:更新表格中固定标题行的数量。addDocumentTab:添加文档标签页。deleteTab:删除文档标签页。updateDocumentTabProperties:更新文档标签页的属性。insertPerson:插入人物提及。updateNamedStyle:更新已命名的样式。insertRichLink:插入富链接。insertDate:插入日期。insertComment:将 CommentThread 插入到文档中。addCommentReply:向 CommentThread 或 SuggestionThread 添加回复。updateCommentPost:更新 CommentThread 或 SuggestionThread 的现有帖子(主帖或回复)。deleteComment:删除 CommentThread。deleteCommentReply:从 CommentThread 或 SuggestionThread 中删除回复 Post。acceptSuggestion:接受建议。rejectSuggestion:拒绝建议。deleteSuggestion:删除建议。
以下示例演示了如何使用 curl 调用 update_doc MCP 工具。
| Curl 请求 |
|---|
curl --location 'https://docsmcp.googleapis.com/mcp' \ --header 'content-type: application/json' \ --header 'accept: application/json, text/event-stream' \ --data '{ "method": "tools/call", "params": { "name": "update_doc", "arguments": { // provide these details according to the tool MCP specification } }, "jsonrpc": "2.0", "id": 1 }' |
输入架构
UpdateDocRequest
| JSON 表示法 |
|---|
{ "documentId": string, "requests": [ { object } ] } |
| 字段 | |
|---|---|
documentId |
必需。要更新的文档的 ID。与云端硬盘工具中的 file_id 相同。 |
requests[] |
要应用于文档的更新列表。每个请求都应是一个有效的 documents.batchUpdate 请求对象,并使用以下网址中记录的架构:https://developers.google.com/workspace/docs/api/reference/rest/v1/documents/request。系统将按指定顺序应用请求。如果任何请求无效,则不会应用任何请求。 |
结构体
| JSON 表示法 |
|---|
{ "fields": { string: value, ... } } |
| 字段 | |
|---|---|
fields |
无序的动态类型值映射。 包含一系列 |
FieldsEntry
| JSON 表示法 |
|---|
{ "key": string, "value": value } |
| 字段 | |
|---|---|
key |
|
value |
|
值
| JSON 表示法 |
|---|
{ "nullValue": null, "numberValue": number, "stringValue": string, "boolValue": boolean, "structValue": { object }, "listValue": array } |
| 字段 | |
|---|---|
联合字段 kind。值的类型。kind 只能是下列其中一项: |
|
nullValue |
表示 JSON |
numberValue |
表示 JSON 数值。不得为 |
stringValue |
表示 JSON 字符串。 |
boolValue |
表示 JSON 布尔值(JSON 中的 |
structValue |
表示 JSON 对象。 |
listValue |
表示 JSON 数组。 |
ListValue
| JSON 表示法 |
|---|
{ "values": [ value ] } |
| 字段 | |
|---|---|
values[] |
动态类型值的重复字段。 |
NullValue
表示 JSON null。
NullValue 是一个标记,使用仅包含一个值的枚举来表示 Value 类型联合的 null 值。
如果类型为 NullValue 的字段的值不是 0,则视为无效。大多数 ProtoJSON 序列化程序都会发出一个 Value,并将 null_value 设置为 JSON null,无论整数值是多少,因此都会往返于 0 值。
| 枚举 | |
|---|---|
NULL_VALUE |
Null 值。 |
输出架构
UpdateDocResponse
| JSON 表示法 |
|---|
{ "replies": [ { object } ] } |
| 字段 | |
|---|---|
replies[] |
执行批量更新请求后得到的回复。包括错误、警告和原始 API 响应,以帮助模型进行调整。原始 API 响应使用以下文档中记录的架构:https://developers.google.com/workspace/docs/api/reference/rest/v1/documents/response |
结构体
| JSON 表示法 |
|---|
{ "fields": { string: value, ... } } |
| 字段 | |
|---|---|
fields |
无序的动态类型值映射。 包含一系列 |
FieldsEntry
| JSON 表示法 |
|---|
{ "key": string, "value": value } |
| 字段 | |
|---|---|
key |
|
value |
|
值
| JSON 表示法 |
|---|
{ "nullValue": null, "numberValue": number, "stringValue": string, "boolValue": boolean, "structValue": { object }, "listValue": array } |
| 字段 | |
|---|---|
联合字段 kind。值的类型。kind 只能是下列其中一项: |
|
nullValue |
表示 JSON |
numberValue |
表示 JSON 数值。不得为 |
stringValue |
表示 JSON 字符串。 |
boolValue |
表示 JSON 布尔值(JSON 中的 |
structValue |
表示 JSON 对象。 |
listValue |
表示 JSON 数组。 |
ListValue
| JSON 表示法 |
|---|
{ "values": [ value ] } |
| 字段 | |
|---|---|
values[] |
动态类型值的重复字段。 |
NullValue
表示 JSON null。
NullValue 是一个标记,使用仅包含一个值的枚举来表示 Value 类型联合的 null 值。
如果类型为 NullValue 的字段的值不是 0,则视为无效。大多数 ProtoJSON 序列化程序都会发出一个 Value,并将 null_value 设置为 JSON null,无论整数值是多少,因此都会往返于 0 值。
| 枚举 | |
|---|---|
NULL_VALUE |
Null 值。 |
工具注释
破坏性提示:❌ | 幂等性提示:❌ | 只读提示:❌ | 开放世界提示:✅