Skip to main content
Glama
ZatesloFL

Google Workspace MCP Server

by ZatesloFL

create_document_comment

Enables users to add comments to Google Documents by specifying the user email, document ID, and comment content. Facilitates collaborative feedback and document review processes within Google Workspace.

Instructions

Create a new comment on a Google Document.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
comment_contentYes
document_idYes
user_google_emailYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Core handler logic that creates a comment using the Google Drive Comments API's comments.create method. This is the main execution logic for the tool.
    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}"
  • The decorated handler function specifically for documents (create_document_comment), which calls the core impl. This is the direct MCP tool handler.
    @require_google_service("drive", "drive_read")
    @handle_http_errors(read_func_name, service_type="drive")
    async def read_comments(service, user_google_email: str, document_id: str) -> str:
        """Read all comments from a Google Document."""
        return await _read_comments_impl(service, app_name, document_id)
  • Sets the function __name__ to 'create_document_comment' and registers it as an MCP tool using server.tool().
    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
    
    # Register tools with the server using the proper names
    server.tool()(read_comments)
    server.tool()(create_comment)
    server.tool()(reply_to_comment)
    server.tool()(resolve_comment)
  • Factory function that generates and registers the create_document_comment tool when called with app_name='document'.
    def create_comment_tools(app_name: str, file_id_param: str):
        """
        Factory function to create comment management tools for a specific Google Workspace app.
    
        Args:
            app_name: Name of the app (e.g., "document", "spreadsheet", "presentation")
            file_id_param: Parameter name for the file ID (e.g., "document_id", "spreadsheet_id", "presentation_id")
    
        Returns:
            Dict containing the four comment management functions with unique names
        """
    
        # Create unique function names based on the app type
        read_func_name = f"read_{app_name}_comments"
        create_func_name = f"create_{app_name}_comment"
        reply_func_name = f"reply_to_{app_name}_comment"
        resolve_func_name = f"resolve_{app_name}_comment"
    
        # Create functions without decorators first, then apply decorators with proper names
        if file_id_param == "document_id":
            @require_google_service("drive", "drive_read")
            @handle_http_errors(read_func_name, service_type="drive")
            async def read_comments(service, user_google_email: str, document_id: str) -> str:
                """Read all comments from a Google Document."""
                return await _read_comments_impl(service, app_name, document_id)
    
            @require_google_service("drive", "drive_file")
            @handle_http_errors(create_func_name, service_type="drive")
            async def create_comment(service, user_google_email: str, document_id: str, comment_content: str) -> str:
                """Create a new comment on a Google Document."""
                return await _create_comment_impl(service, app_name, document_id, comment_content)
    
            @require_google_service("drive", "drive_file")
            @handle_http_errors(reply_func_name, service_type="drive")
            async def reply_to_comment(service, user_google_email: str, document_id: str, comment_id: str, reply_content: str) -> str:
                """Reply to a specific comment in a Google Document."""
                return await _reply_to_comment_impl(service, app_name, document_id, comment_id, reply_content)
    
            @require_google_service("drive", "drive_file")
            @handle_http_errors(resolve_func_name, service_type="drive")
            async def resolve_comment(service, user_google_email: str, document_id: str, comment_id: str) -> str:
                """Resolve a comment in a Google Document."""
                return await _resolve_comment_impl(service, app_name, document_id, comment_id)
    
        elif file_id_param == "spreadsheet_id":
            @require_google_service("drive", "drive_read")
            @handle_http_errors(read_func_name, service_type="drive")
            async def read_comments(service, user_google_email: str, spreadsheet_id: str) -> str:
                """Read all comments from a Google Spreadsheet."""
                return await _read_comments_impl(service, app_name, spreadsheet_id)
    
            @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)
    
            @require_google_service("drive", "drive_file")
            @handle_http_errors(reply_func_name, service_type="drive")
            async def reply_to_comment(service, user_google_email: str, spreadsheet_id: str, comment_id: str, reply_content: str) -> str:
                """Reply to a specific comment in a Google Spreadsheet."""
                return await _reply_to_comment_impl(service, app_name, spreadsheet_id, comment_id, reply_content)
    
            @require_google_service("drive", "drive_file")
            @handle_http_errors(resolve_func_name, service_type="drive")
            async def resolve_comment(service, user_google_email: str, spreadsheet_id: str, comment_id: str) -> str:
                """Resolve a comment in a Google Spreadsheet."""
                return await _resolve_comment_impl(service, app_name, spreadsheet_id, comment_id)
    
        elif file_id_param == "presentation_id":
            @require_google_service("drive", "drive_read")
            @handle_http_errors(read_func_name, service_type="drive")
            async def read_comments(service, user_google_email: str, presentation_id: str) -> str:
                """Read all comments from a Google Presentation."""
                return await _read_comments_impl(service, app_name, presentation_id)
    
            @require_google_service("drive", "drive_file")
            @handle_http_errors(create_func_name, service_type="drive")
            async def create_comment(service, user_google_email: str, presentation_id: str, comment_content: str) -> str:
                """Create a new comment on a Google Presentation."""
                return await _create_comment_impl(service, app_name, presentation_id, comment_content)
    
            @require_google_service("drive", "drive_file")
            @handle_http_errors(reply_func_name, service_type="drive")
            async def reply_to_comment(service, user_google_email: str, presentation_id: str, comment_id: str, reply_content: str) -> str:
                """Reply to a specific comment in a Google Presentation."""
                return await _reply_to_comment_impl(service, app_name, presentation_id, comment_id, reply_content)
    
            @require_google_service("drive", "drive_file")
            @handle_http_errors(resolve_func_name, service_type="drive")
            async def resolve_comment(service, user_google_email: str, presentation_id: str, comment_id: str) -> str:
                """Resolve a comment in a Google Presentation."""
                return await _resolve_comment_impl(service, app_name, presentation_id, comment_id)
    
        # Set the proper function names and register with server
        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
    
        # Register tools with the server using the proper names
        server.tool()(read_comments)
        server.tool()(create_comment)
        server.tool()(reply_to_comment)
        server.tool()(resolve_comment)
    
        return {
            'read_comments': read_comments,
            'create_comment': create_comment,
            'reply_to_comment': reply_to_comment,
            'resolve_comment': resolve_comment
        }
  • Invokes the factory to create document-specific comment tools, including create_document_comment, and aliases it locally as create_doc_comment.
    _comment_tools = create_comment_tools("document", "document_id")
    
    # Extract and register the functions
    read_doc_comments = _comment_tools['read_comments']
    create_doc_comment = _comment_tools['create_comment']
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. While 'Create' implies a write/mutation operation, the description doesn't disclose important behavioral traits like required permissions, whether the comment is immediately visible, how it interacts with existing comments, rate limits, or what happens on failure. For a mutation tool with zero annotation coverage, this represents a significant gap in behavioral transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that gets straight to the point with zero wasted words. It's appropriately sized for a tool with a straightforward purpose and follows good front-loading principles by immediately stating the core functionality.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given that there's an output schema (which means the description doesn't need to explain return values) and the tool has moderate complexity (3 required parameters for a mutation operation), the description is minimally adequate but incomplete. The presence of an output schema helps, but the complete lack of parameter semantics and behavioral context for a mutation tool leaves significant gaps in understanding how to use this tool effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 0%, meaning none of the three parameters have descriptions in the schema. The tool description provides no information about what the parameters mean, their expected formats, or how they relate to each other. The description doesn't compensate for the complete lack of schema documentation, leaving all three required parameters (comment_content, document_id, user_google_email) semantically undefined.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Create a new comment') and target resource ('on a Google Document'), providing a specific verb+resource combination. However, it doesn't distinguish this tool from sibling tools like 'create_presentation_comment' or 'create_spreadsheet_comment' that perform similar operations on different Google Workspace resources.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance about when to use this tool versus alternatives. There are sibling tools for creating comments on presentations and spreadsheets, but the description doesn't mention these alternatives or provide context about when this specific document comment tool is appropriate versus other comment-related tools like 'reply_to_document_comment' or 'resolve_document_comment'.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/ZatesloFL/google_workspace_mcp'

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