Skip to main content
Glama
adexltd
by adexltd

docs_create

Generate a new Google Doc with a specified title and optional initial content using the MCP Google Suite server for secure Google Workspace integration.

Instructions

Create a new Google Doc

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentNoInitial content
titleYesTitle of the document

Implementation Reference

  • MCP tool handler for docs_create: extracts arguments, validates title, delegates to DocsService.create_document, and returns the result.
    async def _handle_docs_create( self, context: GoogleWorkspaceContext, arguments: dict ) -> Dict[str, Any]: """Handle docs create requests.""" title = arguments.get("title") content = arguments.get("content") if not title: raise ValueError("Document title is required") logger.debug(f"Creating document - Title: {title}, Content length: {len(content or '')}") result = await context.docs.create_document(title=title, content=content) logger.debug(f"Document created - ID: {result.get('documentId')}") return result
  • Input schema definition for the docs_create tool, specifying title (required) and optional content.
    types.Tool( name="docs_create", description="Create a new Google Doc", inputSchema={ "type": "object", "properties": { "title": {"type": "string", "description": "Title of the document"}, "content": {"type": "string", "description": "Initial content"}, }, "required": ["title"], }, ),
  • Dynamic registration of tool handlers into _tool_registry based on available tools list.
    for tool in self._get_tools_list(): handler_name = f"_handle_{tool.name}" if hasattr(self, handler_name): handler = getattr(self, handler_name) self._tool_registry[tool.name] = handler logger.debug(f"Registered handler for {tool.name}")
  • Core implementation in DocsService: creates Google Doc via API, optionally inserts initial content by calling update_document_content.
    async def create_document(self, title: str, content: Optional[str] = None) -> Dict[str, Any]: """Create a new Google Doc with optional initial content.""" try: service = await self.get_service() doc = await asyncio.to_thread(service.documents().create(body={"title": title}).execute) if content: await self.update_document_content(doc["documentId"], content) return {"success": True, "document": doc} except HttpError as error: return {"success": False, **self.handle_error(error)}

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/adexltd/mcp-google-suite'

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