Skip to main content
Glama
penysho

Google Docs MCP Server

by penysho

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

TableJSON Schema
NameRequiredDescriptionDefault
contentYes追加または更新するコンテンツ
documentIdYes更新するGoogle DocsドキュメントのID
endPositionNo更新を終了する位置(オプション)
startPositionNo更新を開始する位置(オプション)

Implementation Reference

  • 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("更新を終了する位置(オプション)"),
    	};
    }
  • Registers an instance of UpdateDocumentTool in the tool registry during default tools setup.
    this.registerTool(new UpdateDocumentTool(this.serviceContainer));
Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/penysho/docs-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server