get_stats_by_browser
Retrieve email statistics grouped by browser type to analyze engagement patterns across different web browsers for SendGrid email campaigns.
Instructions
Retrieve email statistics grouped by browser type
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 |
| browsers | No | Comma-separated list of browsers to filter by |
Implementation Reference
- src/tools/stats.ts:37-46 (handler)The async handler function that builds the SendGrid API URL for /browsers/stats endpoint and returns the JSON response.handler: async ({ start_date, end_date, aggregated_by, browsers }: { start_date: string; end_date?: string; aggregated_by?: string; browsers?: string }): Promise<ToolResult> => { let url = `https://api.sendgrid.com/v3/browsers/stats?start_date=${start_date}`; if (end_date) url += `&end_date=${end_date}`; if (aggregated_by) url += `&aggregated_by=${aggregated_by}`; if (browsers) url += `&browsers=${encodeURIComponent(browsers)}`; const result = await makeRequest(url); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; }, },
- src/tools/stats.ts:27-36 (schema)Tool configuration including title, description, and Zod inputSchema for parameter validation.config: { title: "Get Email Statistics by Browser", description: "Retrieve email statistics grouped by browser type", 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"), browsers: z.string().optional().describe("Comma-separated list of browsers to filter by"), }, },
- src/tools/index.ts:9-17 (registration)Spreads statsTools (containing 'get_stats_by_browser') into allTools, which is imported and registered in MCP server.export const allTools = { ...automationTools, ...campaignTools, ...contactTools, ...mailTools, ...miscTools, ...statsTools, ...templateTools, };
- src/index.ts:21-23 (registration)Registers all tools from allTools object with the MCP server, including get_stats_by_browser.for (const [name, tool] of Object.entries(allTools)) { server.registerTool(name, tool.config as any, tool.handler as any); }