Skip to main content
Glama
deyikong

SendGrid MCP Server

by deyikong

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); }

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