Skip to main content
Glama
josedu90

MCP Google Workspace Server

docs_get_content

Extract and retrieve the content of a Google Doc by specifying its document ID. Designed for AI agents to interact with Google Workspace services efficiently.

Instructions

Get the contents of a Google Doc

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
document_idYesID of the document

Implementation Reference

  • The handler function that implements the core logic for the 'docs_get_content' tool. It validates the document_id input and calls the DocsService to retrieve the document content.
    async def _handle_docs_get_content(
        self, context: GoogleWorkspaceContext, arguments: dict
    ) -> Dict[str, Any]:
        """Handle docs get content requests."""
        document_id = arguments.get("document_id")
    
        if not document_id:
            raise ValueError("Document ID is required")
    
        logger.debug(f"Getting document content - ID: {document_id}")
        result = await context.docs.get_document_content(document_id=document_id)
        logger.debug("Document content retrieved successfully")
        return result
  • The input schema definition for the 'docs_get_content' tool, requiring a 'document_id' string parameter.
    types.Tool(
        name="docs_get_content",
        description="Get the contents of a Google Doc",
        inputSchema={
            "type": "object",
            "properties": {
                "document_id": {"type": "string", "description": "ID of the document"}
            },
            "required": ["document_id"],
        },
    ),
  • The registration logic that dynamically registers the 'docs_get_content' handler by looking for _handle_docs_get_content method.
    # Register tool handlers
    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}")
  • Supporting method in DocsService that performs the actual API call to retrieve Google Doc contents (likely the target of the handler's delegation, despite minor name discrepancy).
    async def get_document(self, document_id: str) -> Dict[str, Any]:
        """Get the contents of a Google Doc."""
        try:
            service = await self.get_service()
            document = await asyncio.to_thread(
                service.documents().get(documentId=document_id).execute
            )
            return {"success": True, "document": document}
        except HttpError as error:
            return {"success": False, **self.handle_error(error)}

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

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/josedu90/mcp-suiteg'

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