Skip to main content
Glama

gmail_get_packages

Extract package delivery and shipping notifications from Gmail, including tracking information from major carriers like Amazon, UPS, FedEx, and USPS.

Instructions

Get package delivery and shipping notification emails. Finds tracking info from Amazon, UPS, FedEx, USPS, and other carriers. Always includes read emails since you want to track all pending deliveries.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
days_backNoHow many days back to search for package emails. Default is 14 days.

Implementation Reference

  • Handler implementation for 'gmail_get_packages' tool. Constructs a comprehensive Gmail search query for package/shipping notifications from major carriers (Amazon, UPS, FedEx, USPS, DHL) and generic terms. Includes emails from the past N days (default 14), formats results with delivery status icons, and always includes read emails.
    elif name == "gmail_get_packages":
        days_back = arguments.get("days_back", 14)
        
        # Build query for package/shipping emails from common carriers and retailers
        package_queries = [
            # Amazon
            'from:shipment-tracking@amazon.com',
            'from:ship-confirm@amazon.com',
            'from:order-update@amazon.com',
            'subject:"shipped" from:amazon',
            'subject:"out for delivery" from:amazon',
            'subject:"arriving" from:amazon',
            'subject:"delivered" from:amazon',
            # UPS
            'from:ups.com subject:delivery',
            'from:ups.com subject:shipped',
            'from:ups.com subject:tracking',
            # FedEx
            'from:fedex.com subject:delivery',
            'from:fedex.com subject:shipped',
            'from:fedex.com subject:tracking',
            # USPS
            'from:usps.com subject:delivery',
            'from:usps.com subject:shipped',
            'from:usps.com subject:tracking',
            'from:informeddelivery@usps.com',
            # DHL
            'from:dhl.com subject:delivery',
            'from:dhl.com subject:shipment',
            # Generic shipping terms
            'subject:"your order has shipped"',
            'subject:"your package"',
            'subject:"shipment notification"',
            'subject:"tracking number"',
            'subject:"out for delivery"',
            'subject:"expected delivery"',
        ]
        
        # Add date filter
        from datetime import datetime, timedelta
        date_after = (datetime.now() - timedelta(days=days_back)).strftime("%Y/%m/%d")
        
        # Combine queries - always include read emails for package tracking
        combined_query = f"({' OR '.join(package_queries)}) after:{date_after}"
        
        # Search for package emails
        emails = await client.search_emails(combined_query, max_results=50)
        
        if not emails:
            return [TextContent(
                type="text", 
                text=f"No package/shipping emails found in the last {days_back} days."
            )]
        
        # Format results
        lines = [f"📦 **Package Tracking Emails** (last {days_back} days)\n"]
        lines.append(f"Found {len(emails)} shipping/delivery email(s):\n")
        
        for email in emails:
            status = "📩" if not email.is_read else "📧"
            # Try to identify delivery status from subject
            subject_lower = email.subject.lower()
            if "delivered" in subject_lower:
                icon = "✅"
            elif "out for delivery" in subject_lower:
                icon = "🚚"
            elif "arriving" in subject_lower or "expected" in subject_lower:
                icon = "📅"
            elif "shipped" in subject_lower:
                icon = "📤"
            else:
                icon = "📦"
            
            lines.append(f"{status} {icon} **{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[:120]}...")
            lines.append("")
        
        return [TextContent(type="text", text="\n".join(lines))]
  • Registration of the 'gmail_get_packages' tool in the GMAIL_TOOLS list, including name, description, and JSON schema for the optional 'days_back' parameter.
        name="gmail_get_packages",
        description="Get package delivery and shipping notification emails. Finds tracking info from Amazon, UPS, FedEx, USPS, and other carriers. Always includes read emails since you want to track all pending deliveries.",
        inputSchema={
            "type": "object",
            "properties": {
                "days_back": {
                    "type": "integer",
                    "description": "How many days back to search for package emails. Default is 14 days."
                }
            },
            "required": []
        },
    ),
  • Input schema definition for the 'gmail_get_packages' tool, specifying the optional integer parameter 'days_back'.
    inputSchema={
        "type": "object",
        "properties": {
            "days_back": {
                "type": "integer",
                "description": "How many days back to search for package emails. Default is 14 days."
            }
        },
        "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 usefully adds that the tool 'Always includes read emails since you want to track all pending deliveries,' which clarifies scope beyond what the parameter schema indicates. However, it doesn't mention other important behaviors like rate limits, authentication needs, or what happens if no emails are found, leaving gaps for a mutation-free tool.

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: the first states the core purpose, and the second adds crucial behavioral context about including read emails. Every sentence earns its place with no wasted words, making it easy to parse and front-loaded with key information.

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

Completeness4/5

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

For a simple read-only tool with one well-documented parameter and no output schema, the description is mostly complete. It clearly explains what the tool does and includes important behavioral context (including read emails). The main gap is lack of output format details, which would be helpful since there's no output schema, but this is partially mitigated by the tool's straightforward purpose.

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?

The input schema has 100% description coverage for its single parameter (days_back), so the schema already fully documents it. The description doesn't add any parameter-specific information beyond what's in the schema, such as format details or examples. This meets the baseline of 3 when schema coverage is high.

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 verbs ('Get package delivery and shipping notification emails') and resources ('emails from Amazon, UPS, FedEx, USPS, and other carriers'). It distinguishes itself from siblings like gmail_search or gmail_get_email by focusing exclusively on package-related emails with tracking info, not general email retrieval.

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 for when to use this tool: to find package tracking emails from specific carriers. It implies an alternative to general search tools by specifying this specialized focus. However, it doesn't explicitly state when NOT to use it or name specific sibling alternatives, which prevents a perfect score.

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