update_google_document
Modify Google Docs by inserting or updating content at specified positions using a document ID. Streamline document editing with precise control over content changes.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | 追加または更新するコンテンツ | |
| documentId | Yes | 更新するGoogle DocsドキュメントのID | |
| endPosition | No | 更新を終了する位置(オプション) | |
| startPosition | No | 更新を開始する位置(オプション) |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"content": {
"description": "追加または更新するコンテンツ",
"type": "string"
},
"documentId": {
"description": "更新するGoogle DocsドキュメントのID",
"type": "string"
},
"endPosition": {
"description": "更新を終了する位置(オプション)",
"type": "number"
},
"startPosition": {
"description": "更新を開始する位置(オプション)",
"type": "number"
}
},
"required": [
"documentId",
"content"
],
"type": "object"
}
Implementation Reference
- src/mcp/tools/updateDocument.ts:37-70 (handler)The handler function that performs the actual Google Document update using the Google Docs service.protected async executeInternal(args: { documentId: string; content: string; startPosition?: number; endPosition?: number; }): Promise<McpToolResponse> { // 引数検証 this.validateArgs(args, ["documentId", "content"]); const { documentId, content, startPosition, endPosition } = args; this.logger.info( `ドキュメント更新開始: ${documentId}, 位置: ${startPosition}-${endPosition}`, ); try { // Google Docsサービスを取得 const docsService = await this.serviceContainer.getGoogleDocsService(); // ドキュメントを更新 await docsService.updateDocumentContent( documentId, content, startPosition, endPosition, ); this.logger.info(`ドキュメント更新完了: ${documentId}`); return this.createSuccessResponse("ドキュメントが更新されました"); } catch (error) { this.logger.error(`ドキュメント更新エラー: ${documentId}`, error); throw error; // BaseMcpToolでエラーハンドリング } }
- Defines the Zod schema for input validation of the tool parameters: documentId, content, optional startPosition and endPosition.get schema() { return { documentId: z.string().describe("更新するGoogle DocsドキュメントのID"), content: z.string().describe("追加または更新するコンテンツ"), startPosition: z .number() .optional() .describe("更新を開始する位置(オプション)"), endPosition: z .number() .optional() .describe("更新を終了する位置(オプション)"), }; }
- src/mcp/registry.ts:55-55 (registration)Registers an instance of UpdateDocumentTool in the tool registry during default tools setup.this.registerTool(new UpdateDocumentTool(this.serviceContainer));