create_spreadsheet_comment
Add comments to Google Spreadsheets by specifying user email, spreadsheet ID, and comment content. Simplify collaboration and feedback tracking within Google Workspace.
Instructions
Create a new comment on a Google Spreadsheet.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| comment_content | Yes | ||
| spreadsheet_id | Yes | ||
| user_google_email | Yes |
Implementation Reference
- core/comments.py:70-74 (handler)The handler function for the 'create_spreadsheet_comment' tool. It is dynamically defined for spreadsheets, decorated with authentication and error handling, and delegates to the implementation helper.@require_google_service("drive", "drive_file") @handle_http_errors(create_func_name, service_type="drive") async def create_comment(service, user_google_email: str, spreadsheet_id: str, comment_content: str) -> str: """Create a new comment on a Google Spreadsheet.""" return await _create_comment_impl(service, app_name, spreadsheet_id, comment_content)
- core/comments.py:183-202 (helper)The core implementation that uses the Google Drive API to create a comment on the specified spreadsheet, returning a formatted success message.async def _create_comment_impl(service, app_name: str, file_id: str, comment_content: str) -> str: """Implementation for creating a comment on any Google Workspace file.""" logger.info(f"[create_{app_name}_comment] Creating comment in {app_name} {file_id}") body = {"content": comment_content} comment = await asyncio.to_thread( service.comments().create( fileId=file_id, body=body, fields="id,content,author,createdTime,modifiedTime" ).execute ) comment_id = comment.get('id', '') author = comment.get('author', {}).get('displayName', 'Unknown') created = comment.get('createdTime', '') return f"Comment created successfully!\\nComment ID: {comment_id}\\nAuthor: {author}\\nCreated: {created}\\nContent: {comment_content}"
- core/comments.py:120-123 (registration)Registers the dynamically created comment tools, including 'create_spreadsheet_comment', with the MCP server.server.tool()(read_comments) server.tool()(create_comment) server.tool()(reply_to_comment) server.tool()(resolve_comment)
- gsheets/sheets_tools.py:358-366 (registration)Triggers the creation and registration of spreadsheet-specific comment tools by calling the factory function.# Create comment management tools for sheets _comment_tools = create_comment_tools("spreadsheet", "spreadsheet_id") # Extract and register the functions read_sheet_comments = _comment_tools['read_comments'] create_sheet_comment = _comment_tools['create_comment'] reply_to_sheet_comment = _comment_tools['reply_to_comment'] resolve_sheet_comment = _comment_tools['resolve_comment']
- core/comments.py:114-117 (helper)Sets the function names dynamically, e.g., 'create_comment' to 'create_spreadsheet_comment'.read_comments.__name__ = read_func_name create_comment.__name__ = create_func_name reply_to_comment.__name__ = reply_func_name resolve_comment.__name__ = resolve_func_name