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
| Name | Required | Description | Default |
|---|---|---|---|
| start_date | Yes | Start date in YYYY-MM-DD format | |
| end_date | No | End date in YYYY-MM-DD format (defaults to today) | |
| aggregated_by | No | How to group the statistics | day |
| mailbox_providers | No | Comma-separated list of mailbox providers to filter by |
Implementation Reference
- src/tools/stats.ts:127-135 (handler)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) }] }; },
- src/tools/stats.ts:117-126 (schema)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"), }, },
- src/tools/index.ts:6-17 (registration)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); }