Skip to main content
Glama
taylorwilsdon

Google Workspace MCP Server - Control Gmail, Calendar, Docs, Sheets, Slides, Chat, Forms & Drive

create_doc

Generate and customize Google Docs by specifying a title and optional content using the Google Workspace MCP Server, returning a document ID and link for immediate 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
serviceYes
titleYes
user_google_emailYes

Implementation Reference

  • The core handler function for the 'create_doc' tool. It creates a new Google Document using the Google Docs API, optionally inserts initial content at index 1, generates a shareable link, and returns a confirmation message with the document ID.
    async def create_doc( service: Any, 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()
  • Decorators for error handling specific to 'create_doc' tool and required auth scopes for Docs API write access.
    @handle_http_errors("create_doc", service_type="docs") @require_google_service("docs", "docs_write")

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/taylorwilsdon/google_workspace_mcp'

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