Skip to main content
Glama

gmail_get_priorities

Retrieve important emails from configured senders and subjects like Navy orders, school alerts, or family messages while filtering out routine notifications.

Instructions

Get priority emails based on the 'known_priorities' category in categories.yaml. Searches for emails matching configured senders (Navy, schools, family) and subjects (orders, deployments, scouts, financial alerts). Automatically excludes routine items like autopay confirmations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
days_backNoHow many days back to search for priority emails. Default is 7 days.
include_readNoWhether to include already-read emails. Default is false (unread only).

Implementation Reference

  • Main handler implementation for the gmail_get_priorities tool. Builds a complex Gmail search query using matchers from the 'known_priorities' category in config (senders, subjects, labels), applies date filter, excludes routine notifications, optionally unread only, searches, and formats results with previews.
    elif name == "gmail_get_priorities":
        days_back = arguments.get("days_back", 7)
        include_read = arguments.get("include_read", False)
        
        # Get the known_priorities category from config
        categories_config = get_categories_config()
        priority_cat = categories_config.categories.get("known_priorities")
        
        if not priority_cat:
            return [TextContent(
                type="text",
                text="Error: 'known_priorities' category not found in categories.yaml"
            )]
        
        # Build query from category matchers
        query_parts = []
        
        # Add sender patterns
        for sender in priority_cat.matcher.senders:
            query_parts.append(f"from:{sender}")
        
        # Add subject patterns  
        for subject in priority_cat.matcher.subjects:
            # Wrap multi-word subjects in quotes
            if " " in subject:
                query_parts.append(f'subject:"{subject}"')
            else:
                query_parts.append(f"subject:{subject}")
        
        # Add label patterns
        for label in priority_cat.matcher.labels:
            if label.lower() == "starred":
                query_parts.append("is:starred")
            elif label.lower() == "important":
                query_parts.append("is:important")
            else:
                query_parts.append(f"label:{label}")
        
        if not query_parts:
            return [TextContent(
                type="text",
                text="Error: 'known_priorities' category has no matchers defined"
            )]
        
        # Add date filter
        from datetime import datetime, timedelta
        date_after = (datetime.now() - timedelta(days=days_back)).strftime("%Y/%m/%d")
        
        # Combine queries with OR
        combined_query = f"({' OR '.join(query_parts)}) after:{date_after}"
        
        # Exclude routine/junk
        combined_query += " -subject:(autopay) -subject:(scheduled payment) -subject:(payment received) -subject:(statement ready) -category:promotions"
        
        if not include_read:
            combined_query += " is:unread"
        
        # Search for priority emails
        emails = await client.search_emails(combined_query, max_results=50)
        
        if not emails:
            return [TextContent(
                type="text", 
                text=f"No priority emails found in the last {days_back} days."
            )]
        
        # Format results
        lines = [f"📌 **Priority Emails** (last {days_back} days)\n"]
        lines.append(f"Found {len(emails)} priority item(s):\n")
        
        for email in emails:
            status = "📩" if not email.is_read else "📧"
            starred = "⭐ " if email.is_starred else ""
            lines.append(f"{status} {starred}**{email.subject}**")
            lines.append(f"   From: {email.sender.name or email.sender.email}")
            lines.append(f"   Date: {email.date.strftime('%Y-%m-%d %H:%M')}")
            lines.append(f"   ID: `{email.id}`")
            if email.snippet:
                lines.append(f"   Preview: {email.snippet[:100]}...")
            lines.append("")
        
        return [TextContent(type="text", text="\n".join(lines))]
  • Tool registration and schema definition for gmail_get_priorities, included in GMAIL_TOOLS list returned by list_tools() handler.
        name="gmail_get_priorities",
        description="Get priority emails based on the 'known_priorities' category in categories.yaml. Searches for emails matching configured senders (Navy, schools, family) and subjects (orders, deployments, scouts, financial alerts). Automatically excludes routine items like autopay confirmations.",
        inputSchema={
            "type": "object",
            "properties": {
                "days_back": {
                    "type": "integer",
                    "description": "How many days back to search for priority emails. Default is 7 days."
                },
                "include_read": {
                    "type": "boolean",
                    "description": "Whether to include already-read emails. Default is false (unread only)."
                }
            },
            "required": []
        },
    ),
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It describes what the tool does (searches for priority emails with specific criteria) and mentions automatic exclusion of routine items, which is useful behavioral context. However, it doesn't disclose important behavioral aspects like whether this requires specific permissions, rate limits, or what the response format looks like.

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

Conciseness5/5

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

The description is efficiently structured in two sentences that each earn their place. The first sentence states the core purpose and configuration source, while the second provides important behavioral details about search criteria and exclusions. No wasted words or redundant information.

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?

For a tool with 2 parameters, 100% schema coverage, but no annotations and no output schema, the description provides adequate context about what the tool does and its search criteria. However, it doesn't describe the return format or structure of results, which would be important for an email retrieval tool. The description is complete enough for basic understanding but lacks output details.

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%, so the schema already fully documents both parameters (days_back and include_read). The description doesn't add any parameter-specific information beyond what's in the schema. The baseline score of 3 is appropriate when the schema does all the parameter documentation work.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/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 with specific verb ('Get priority emails') and resource ('based on the known_priorities category in categories.yaml'), and distinguishes it from siblings by specifying it searches for emails matching configured senders and subjects while automatically excluding routine items. This is more specific than generic search tools like gmail_search.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context about when to use this tool - for finding priority emails based on configured categories, senders, and subjects. It distinguishes from generic search by mentioning the automatic exclusion of routine items. However, it doesn't explicitly state when NOT to use it or name specific alternatives among the sibling tools.

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