Skip to main content
Glama
ZatesloFL

Google Workspace MCP Server

by ZatesloFL

create_doc

Generate a new Google Doc with a specified title and optional initial content. Returns a confirmation message including the document ID and link for easy access.

Instructions

Creates a new Google Doc and optionally inserts initial content.

Returns: str: Confirmation message with document ID and link.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentNo
titleYes
user_google_emailYes

Implementation Reference

  • The primary handler function for the 'create_doc' MCP tool. It creates a new Google Document using the Docs API with the given title and optional initial content, then returns the document ID and edit link.
    @server.tool()
    @handle_http_errors("create_doc", service_type="docs")
    @require_google_service("docs", "docs_write")
    async def create_doc(
        service,
        user_google_email: str,
        title: str,
        content: str = '',
    ) -> str:
        """
        Creates a new Google Doc and optionally inserts initial content.
    
        Returns:
            str: Confirmation message with document ID and link.
        """
        logger.info(f"[create_doc] Invoked. Email: '{user_google_email}', Title='{title}'")
    
        doc = await asyncio.to_thread(service.documents().create(body={'title': title}).execute)
        doc_id = doc.get('documentId')
        if content:
            requests = [{'insertText': {'location': {'index': 1}, 'text': content}}]
            await asyncio.to_thread(service.documents().batchUpdate(documentId=doc_id, body={'requests': requests}).execute)
        link = f"https://docs.google.com/document/d/{doc_id}/edit"
        msg = f"Created Google Doc '{title}' (ID: {doc_id}) for {user_google_email}. Link: {link}"
        logger.info(f"Successfully created Google Doc '{title}' (ID: {doc_id}) for {user_google_email}. Link: {link}")
        return msg
  • The @server.tool() decorator registers the create_doc function as an MCP tool.
    @server.tool()
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