Skip to main content
Glama
deyikong

SendGrid MCP Server

by deyikong

Get Statistics Overview

get_stats_overview

Retrieve comprehensive email statistics overview across multiple dimensions including date ranges, grouping options, and subuser data for SendGrid email analytics.

Instructions

Get a comprehensive overview of email statistics across multiple dimensions

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
include_subusersNoInclude subuser statistics in the overview

Implementation Reference

  • The main handler function for get_stats_overview, which fetches statistics from multiple SendGrid endpoints (global, browsers, clients, geo, mailbox providers) in parallel and returns a combined overview.
    handler: async ({ start_date, end_date, aggregated_by, include_subusers }: { start_date: string; end_date?: string; aggregated_by?: string; include_subusers?: boolean }): Promise<ToolResult> => {
      const baseParams = `start_date=${start_date}${end_date ? `&end_date=${end_date}` : ''}${aggregated_by ? `&aggregated_by=${aggregated_by}` : ''}`;
      
      // Fetch multiple stats in parallel for comprehensive overview
      const [globalStats, browserStats, clientStats, geoStats, providerStats] = await Promise.all([
        makeRequest(`https://api.sendgrid.com/v3/stats?${baseParams}`),
        makeRequest(`https://api.sendgrid.com/v3/browsers/stats?${baseParams}`),
        makeRequest(`https://api.sendgrid.com/v3/clients/stats?${baseParams}`),
        makeRequest(`https://api.sendgrid.com/v3/geo/stats?${baseParams}`),
        makeRequest(`https://api.sendgrid.com/v3/mailbox_providers/stats?${baseParams}`)
      ]);
    
      const overview = {
        period: {
          start_date,
          end_date: end_date || new Date().toISOString().split('T')[0],
          aggregated_by: aggregated_by || 'day'
        },
        global_statistics: globalStats,
        browser_statistics: browserStats,
        client_statistics: clientStats, 
        geographic_statistics: geoStats,
        mailbox_provider_statistics: providerStats
      };
    
      return { content: [{ type: "text", text: JSON.stringify(overview, null, 2) }] };
    },
  • Zod input schema defining parameters: start_date (required), end_date (optional), aggregated_by (optional, defaults to 'day'), include_subusers (optional, defaults to false).
    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"),
      include_subusers: z.boolean().optional().default(false).describe("Include subuser statistics in the overview"),
    },
  • src/index.ts:20-23 (registration)
    MCP server registration loop that dynamically registers get_stats_overview (via allTools[name]) with its config and handler to the McpServer.
    // Register all tools
    for (const [name, tool] of Object.entries(allTools)) {
      server.registerTool(name, tool.config as any, tool.handler as any);
    }
  • Aggregation of all tools including statsTools (which contains get_stats_overview) into allTools, imported and used for registration in src/index.ts.
    export const allTools = {
      ...automationTools,
      ...campaignTools,
      ...contactTools,
      ...mailTools,
      ...miscTools,
      ...statsTools,
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. While 'Get' implies a read-only operation, the description doesn't address important behavioral aspects like whether this requires authentication, what the return format looks like, whether results are paginated, or if there are rate limits. For a statistical tool with zero annotation coverage, this leaves significant gaps in understanding how the tool behaves.

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 a single, efficient sentence that gets straight to the point without unnecessary words. It's appropriately sized for what it communicates, though it could potentially be more specific about what 'multiple dimensions' entails to improve clarity.

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 tool with no annotations and no output schema, the description is insufficient. It doesn't explain what statistics are included, what format the results take, or how this differs from other statistical tools in the system. The agent would need to guess about the output structure and when to use this versus alternatives.

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 description mentions 'across multiple dimensions' which hints at the aggregation capabilities, but doesn't specifically explain the parameters. With 100% schema description coverage, the schema already documents all 4 parameters thoroughly, so the description adds minimal value beyond what's in the structured schema. The baseline of 3 is appropriate when the 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 ('Get') and resource ('comprehensive overview of email statistics across multiple dimensions'), making the purpose understandable. However, it doesn't specifically differentiate this tool from sibling statistical tools like 'get_global_stats' or 'get_category_stats', which likely provide similar statistical data but with different scopes or dimensions.

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. With multiple sibling tools like 'get_global_stats', 'get_category_stats', and various 'get_stats_by_*' tools, there's no indication of what makes this 'overview' tool distinct or when it should be preferred over more specific statistical 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/deyikong/sendgrid-mcp'

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