Skip to main content
Glama
deyikong

SendGrid MCP Server

by deyikong

get_subuser_stats

Retrieve email performance statistics for SendGrid subusers within specified date ranges to analyze engagement metrics and campaign effectiveness.

Instructions

Retrieve email statistics for specific subusers

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
subusersYesComma-separated list of subuser names to retrieve stats for
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

Implementation Reference

  • The handler function that fetches email statistics for specified subusers from the SendGrid API.
    handler: async ({ subusers, start_date, end_date, aggregated_by }: { subusers: string; start_date: string; end_date?: string; aggregated_by?: string }): Promise<ToolResult> => { let url = `https://api.sendgrid.com/v3/subusers/stats?subusers=${encodeURIComponent(subusers)}&start_date=${start_date}`; if (end_date) url += `&end_date=${end_date}`; if (aggregated_by) url += `&aggregated_by=${aggregated_by}`; const result = await makeRequest(url); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; },
  • Zod schema for validating the input parameters of the get_subuser_stats tool.
    inputSchema: { subusers: z.string().describe("Comma-separated list of subuser names to retrieve stats for"), 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"), },
  • The complete tool definition for get_subuser_stats, including config, schema, and handler, within the exported statsTools object.
    get_subuser_stats: { config: { title: "Get Email Statistics by Subuser", description: "Retrieve email statistics for specific subusers", inputSchema: { subusers: z.string().describe("Comma-separated list of subuser names to retrieve stats for"), 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"), }, }, handler: async ({ subusers, start_date, end_date, aggregated_by }: { subusers: string; start_date: string; end_date?: string; aggregated_by?: string }): Promise<ToolResult> => { let url = `https://api.sendgrid.com/v3/subusers/stats?subusers=${encodeURIComponent(subusers)}&start_date=${start_date}`; if (end_date) url += `&end_date=${end_date}`; if (aggregated_by) url += `&aggregated_by=${aggregated_by}`; const result = await makeRequest(url); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; },
  • Registration of statsTools (which includes get_subuser_stats) into the aggregate allTools export.
    import { statsTools } from "./stats.js"; import { templateTools } from "./templates.js"; export const allTools = { ...automationTools, ...campaignTools, ...contactTools, ...mailTools, ...miscTools, ...statsTools, ...templateTools, };

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