Skip to main content
Glama
deyikong

SendGrid MCP Server

by deyikong

Get Email Statistics by Mailbox Provider

get_stats_by_mailbox_provider

Retrieve email statistics grouped by mailbox provider to analyze deliverability and performance across services like Gmail, Outlook, and Yahoo.

Instructions

Retrieve email statistics grouped by mailbox provider (Gmail, Outlook, Yahoo, etc.)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
start_dateYesStart date in YYYY-MM-DD format
end_dateNoEnd date in YYYY-MM-DD format (defaults to today)
aggregated_byNoHow to group the statisticsday
mailbox_providersNoComma-separated list of mailbox providers to filter by

Implementation Reference

  • The handler function that implements the tool logic by constructing a SendGrid API URL for /v3/mailbox_providers/stats and fetching the statistics data using makeRequest.
    handler: async ({ start_date, end_date, aggregated_by, mailbox_providers }: { start_date: string; end_date?: string; aggregated_by?: string; mailbox_providers?: string }): Promise<ToolResult> => {
      let url = `https://api.sendgrid.com/v3/mailbox_providers/stats?start_date=${start_date}`;
      if (end_date) url += `&end_date=${end_date}`;
      if (aggregated_by) url += `&aggregated_by=${aggregated_by}`;
      if (mailbox_providers) url += `&mailbox_providers=${encodeURIComponent(mailbox_providers)}`;
      
      const result = await makeRequest(url);
      return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
    },
  • Tool configuration including title, description, and Zod input schema defining required start_date and optional end_date, aggregated_by, mailbox_providers parameters.
    config: {
      title: "Get Email Statistics by Mailbox Provider",
      description: "Retrieve email statistics grouped by mailbox provider (Gmail, Outlook, Yahoo, etc.)",
      inputSchema: {
        start_date: z.string().describe("Start date in YYYY-MM-DD format"),
        end_date: z.string().optional().describe("End date in YYYY-MM-DD format (defaults to today)"),
        aggregated_by: z.enum(["day", "week", "month"]).optional().default("day").describe("How to group the statistics"),
        mailbox_providers: z.string().optional().describe("Comma-separated list of mailbox providers to filter by"),
      },
    },
  • Imports statsTools (containing get_stats_by_mailbox_provider) and spreads it into the aggregated allTools export used for MCP tool registration.
    import { statsTools } from "./stats.js";
    import { templateTools } from "./templates.js";
    
    export const allTools = {
      ...automationTools,
      ...campaignTools,
      ...contactTools,
      ...mailTools,
      ...miscTools,
      ...statsTools,
      ...templateTools,
    };
  • src/index.ts:21-23 (registration)
    Loops over allTools to register each tool, including get_stats_by_mailbox_provider, with the MCP server via registerTool.
    for (const [name, tool] of Object.entries(allTools)) {
      server.registerTool(name, tool.config as any, tool.handler as any);
    }
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 what the tool does, not how it behaves. It doesn't disclose whether this is a read-only operation, if it requires authentication, rate limits, error conditions, or what the output format looks like. For a statistical retrieval tool with zero annotation coverage, this is inadequate.

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 a single, efficient sentence that states the core purpose with zero waste. It's appropriately sized for this tool and front-loads the essential information without unnecessary elaboration.

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 statistical retrieval tool with 4 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what statistics are returned, format of results, pagination, error handling, or authentication requirements. The agent lacks crucial context to use this tool effectively beyond basic parameter passing.

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 all parameters are documented in the schema. The description adds no additional parameter semantics beyond what's in the schema - it doesn't explain what 'email statistics' includes, how grouping works, or provide examples for mailbox_providers. Baseline 3 is appropriate when schema does the heavy lifting.

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 'retrieve' and resource 'email statistics grouped by mailbox provider', with examples like Gmail, Outlook, Yahoo. It distinguishes from siblings like get_stats_by_browser or get_stats_by_country by specifying the grouping dimension. However, it doesn't explicitly differentiate from all statistical siblings beyond the grouping criteria.

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 like get_global_stats or get_stats_overview. It doesn't mention prerequisites, constraints, or typical use cases. The agent must infer usage from the title and sibling names alone.

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/deyikong/sendgrid-mcp'

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