Skip to main content
Glama
deyikong

SendGrid MCP Server

by deyikong

Get Email Statistics by Country and State/Province

get_stats_by_country

Retrieve email statistics grouped by geographic location to analyze campaign performance across countries and regions.

Instructions

Retrieve email statistics grouped by geographic location

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
countryNoISO 3166-1 alpha-2 country code to filter by
stateNoState or province to filter by

Implementation Reference

  • The handler function constructs the SendGrid API URL for /v3/geo/stats with parameters for date range, aggregation, country, and state filters, calls makeRequest, and returns the JSON-formatted stats.
      handler: async ({ start_date, end_date, aggregated_by, country, state }: { start_date: string; end_date?: string; aggregated_by?: string; country?: string; state?: string }): Promise<ToolResult> => {
        let url = `https://api.sendgrid.com/v3/geo/stats?start_date=${start_date}`;
        if (end_date) url += `&end_date=${end_date}`;
        if (aggregated_by) url += `&aggregated_by=${aggregated_by}`;
        if (country) url += `&country=${encodeURIComponent(country)}`;
        if (state) url += `&state=${encodeURIComponent(state)}`;
        
        const result = await makeRequest(url);
        return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
      },
    },
  • Zod-based input schema validating the tool parameters: required start_date (YYYY-MM-DD), optional end_date, aggregated_by (day/week/month default day), country (ISO code), and state/province.
    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"),
      country: z.string().optional().describe("ISO 3166-1 alpha-2 country code to filter by"),
      state: z.string().optional().describe("State or province to filter by"),
    },
  • src/index.ts:21-23 (registration)
    MCP server registration loop that iterates over allTools (including get_stats_by_country) and calls server.registerTool for each, passing name, config, and handler.
    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?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool retrieves statistics but doesn't describe what data is returned (e.g., metrics like opens, clicks), whether it's read-only (implied but not confirmed), rate limits, authentication needs, or error handling. For a data retrieval tool with zero annotation coverage, this is a significant gap in transparency.

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 with zero waste. It's front-loaded with the core purpose and appropriately sized for a straightforward retrieval tool. Every word earns its place without redundancy.

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's moderate complexity (5 parameters, no output schema, no annotations), the description is minimally adequate. It states the purpose but lacks details on return values, behavioral traits, or usage context. With no output schema, the description should ideally hint at what statistics are retrieved, but it doesn't. This leaves gaps for an agent to understand full context.

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 all parameters well-documented in the schema (e.g., date formats, enum values, defaults). The description adds no additional parameter semantics beyond implying geographic grouping, which is already clear from the tool name and schema. This meets the baseline of 3 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 ('Retrieve') and resource ('email statistics grouped by geographic location'), which matches the tool name and title. It distinguishes this tool from siblings like 'get_global_stats' or 'get_stats_by_browser' by specifying geographic grouping. However, it doesn't explicitly mention 'country and state/province' as in the title, leaving some ambiguity about the exact grouping levels.

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 sibling tools like 'get_global_stats' (for overall stats) or 'get_stats_by_browser' (for browser-based grouping), nor does it specify prerequisites or exclusions. Usage is implied by the name and description 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/deyikong/sendgrid-mcp'

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