Skip to main content
Glama

gmail_category_summary

Summarize unread emails in a specific Gmail category to quickly identify important messages and manage your inbox efficiently.

Instructions

Get a summary of unread emails in one specific category. Returns email count and list of emails matching that category.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryYesCategory to summarize. Must be one of: navy, kids, financial, action_required.

Implementation Reference

  • Core handler implementing the tool logic: fetches unread emails matching the specified category using search query built from category matchers, computes counts, and constructs CategorySummary object.
    async def get_category_summary(self, category_key: str) -> Optional[CategorySummary]:
        """Get summary for a specific category."""
        if category_key not in self.categories.categories:
            return None
    
        category = self.categories.categories[category_key]
        max_results = self.categories.summary_settings.get("max_per_category", 10)
    
        # Search for emails in this category
        search = SearchQuery(
            category=category_key,
            is_unread=True,
            max_results=50,
        )
    
        emails = await self.list_emails(search)
    
        return CategorySummary(
            category_key=category_key,
            category_name=category.name,
            priority=category.priority,
            total_count=len(emails),
            unread_count=sum(1 for e in emails if not e.is_read),
            emails=emails[:max_results],
        )
  • Registers the gmail_category_summary tool with the MCP server, including name, description, and input schema defining the required 'category' parameter.
    Tool(
        name="gmail_category_summary",
        description="Get a summary of unread emails in a specific category",
        inputSchema={
            "type": "object",
            "properties": {
                "category": {
                    "type": "string",
                    "description": "Category to summarize",
                    "enum": ["navy", "kids", "financial", "action_required"],
                },
            },
            "required": ["category"],
        },
    ),
  • Tool dispatch handler in MCP call_tool: validates input, calls GmailClient.get_category_summary, handles errors, formats output as TextContent.
    elif name == "gmail_category_summary":
        category = arguments.get("category")
        if not category:
            return [TextContent(type="text", text="Error: category is required")]
        summary = await client.get_category_summary(category)
        if summary is None:
            return [TextContent(type="text", text=f"Unknown category: {category}")]
        return [
            TextContent(
                type="text",
                text=_format_category_summary(summary),
            )
        ]
  • Helper function to format the CategorySummary object into a human-readable markdown string for the tool response.
    def _format_category_summary(summary) -> str:
        """Format category summary for display."""
        lines = [
            f"# {summary.category_name}",
            f"**Total:** {summary.total_count} | **Unread:** {summary.unread_count}",
            "",
        ]
    
        for email in summary.emails:
            status = "📬" if not email.is_read else "📭"
            lines.append(f"{status} **{email.subject}**")
            lines.append(f"   From: {email.sender.email} | {email.date.strftime('%Y-%m-%d %H:%M')}")
            lines.append(f"   {email.snippet[:100]}...")
            lines.append(f"   ID: `{email.id}`")
            lines.append("")
    
        return "\n".join(lines)
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions the tool returns 'email count and list of emails matching that category,' which adds some context about output behavior. However, it lacks critical details: it doesn't specify if this is a read-only operation (implied by 'Get' but not explicit), whether it requires authentication or permissions, any rate limits, or how the list is formatted (e.g., pagination, fields included). For a tool with no annotations, this is insufficient.

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 appropriately sized with two sentences that are front-loaded: the first states the purpose, and the second specifies the return values. There's no wasted text, and it efficiently conveys core information. However, it could be slightly more structured by explicitly separating purpose from behavior, but it's still concise and clear.

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

Completeness3/5

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

Given the tool has one parameter with full schema coverage and no output schema, the description is moderately complete. It covers the basic purpose and return values, but lacks depth: it doesn't explain the category semantics, authentication needs, or error handling. For a simple read operation, this is adequate but has clear gaps, especially in behavioral context due to missing annotations.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with the schema fully documenting the single parameter 'category' and its allowed values. The description adds no additional meaning beyond what the schema provides—it doesn't explain the semantics of categories (e.g., what 'navy' or 'action_required' mean) or provide usage examples. With high schema coverage, the baseline is 3, as the description doesn't compensate but doesn't detract either.

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 tool's purpose: 'Get a summary of unread emails in one specific category.' It specifies the verb ('Get a summary') and resource ('unread emails in one specific category'), and distinguishes it from siblings like 'gmail_list_unread' by focusing on categorization. However, it doesn't explicitly differentiate from 'gmail_get_categories' (which might list categories) or 'gmail_daily_summary' (which might summarize by time), so it's not fully sibling-aware.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to choose this over 'gmail_list_unread' (which lists all unread emails) or 'gmail_get_categories' (which might provide category information). There's no context about prerequisites, such as needing unread emails in the specified category, or exclusions. Usage is implied by the purpose but not explicitly stated.

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

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/murphy360/mcp_gmail'

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