Skip to main content
Glama
taylorwilsdon

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

get_messages

Retrieve and format messages from a Google Chat space using service details, user email, and space ID to access organized communication data.

Instructions

Retrieves messages from a Google Chat space.

Returns:
    str: Formatted messages from the specified space.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
order_byNocreateTime desc
page_sizeNo
serviceYes
space_idYes
user_google_emailYes

Implementation Reference

  • The core handler function that retrieves messages from a specified Google Chat space. It fetches space information, lists recent messages using the Google Chat API, formats them with sender, time, content, and message ID, and returns a formatted string.
    async def get_messages(
        service,
        user_google_email: str,
        space_id: str,
        page_size: int = 50,
        order_by: str = "createTime desc"
    ) -> str:
        """
        Retrieves messages from a Google Chat space.
    
        Returns:
            str: Formatted messages from the specified space.
        """
        logger.info(f"[get_messages] Space ID: '{space_id}' for user '{user_google_email}'")
    
        # Get space info first
        space_info = await asyncio.to_thread(
            service.spaces().get(name=space_id).execute
        )
        space_name = space_info.get('displayName', 'Unknown Space')
    
        # Get messages
        response = await asyncio.to_thread(
            service.spaces().messages().list(
                parent=space_id,
                pageSize=page_size,
                orderBy=order_by
            ).execute
        )
    
        messages = response.get('messages', [])
        if not messages:
            return f"No messages found in space '{space_name}' (ID: {space_id})."
    
        output = [f"Messages from '{space_name}' (ID: {space_id}):\n"]
        for msg in messages:
            sender = msg.get('sender', {}).get('displayName', 'Unknown Sender')
            create_time = msg.get('createTime', 'Unknown Time')
            text_content = msg.get('text', 'No text content')
            msg_name = msg.get('name', '')
    
            output.append(f"[{create_time}] {sender}:")
            output.append(f"  {text_content}")
            output.append(f"  (Message ID: {msg_name})\n")
    
        return "\n".join(output)
  • Registers the 'get_messages' tool with the MCP server using the @server.tool() decorator.
    @server.tool()
  • Decorator stack that registers the tool, requires Google Chat read permissions, and handles HTTP errors specifically for 'get_messages'.
    @server.tool()
    @require_google_service("chat", "chat_read")
    @handle_http_errors("get_messages", service_type="chat")
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the action and return type. It misses critical behavioral details like pagination handling (implied by 'page_size' parameter), rate limits, authentication requirements, or error conditions, making it insufficient for a mutation-like read operation.

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

Conciseness4/5

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

The description is brief and front-loaded with the core action, but the 'Returns' section is redundant as it restates the obvious without adding value. It could be more efficient by omitting unnecessary details or integrating them better.

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

Completeness2/5

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

For a tool with 5 parameters, 0% schema coverage, no annotations, and no output schema, the description is inadequate. It fails to explain parameter meanings, behavioral traits, or output format beyond a vague 'Formatted messages', leaving significant gaps for agent understanding.

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?

Schema description coverage is 0%, so the description must compensate but adds no parameter details. It doesn't explain what 'service', 'user_google_email', or 'space_id' mean, nor does it clarify the 'order_by' default or 'page_size' implications, leaving parameters largely undocumented.

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 verb ('Retrieves') and resource ('messages from a Google Chat space'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'search_messages' or 'list_spaces', which could provide similar functionality, so it doesn't reach the highest score.

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?

No guidance is provided on when to use this tool versus alternatives like 'search_messages' or 'list_spaces'. The description lacks context on prerequisites, such as authentication needs or space access, leaving the agent without usage direction.

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

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

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