Skip to main content
Glama
Garoth

SendGrid MCP Server

by Garoth

get_stats

Retrieve SendGrid email analytics for specified date ranges to monitor campaign performance and engagement metrics.

Instructions

Get SendGrid email statistics

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
start_dateYesStart date in YYYY-MM-DD format
end_dateNoEnd date in YYYY-MM-DD format (optional)
aggregated_byNoHow to aggregate the statistics (optional)

Implementation Reference

  • The core handler function within SendGridService that fetches email statistics from the SendGrid API using the /v3/stats endpoint.
    async getStats(params: {
      start_date: string;
      end_date?: string;
      aggregated_by?: 'day' | 'week' | 'month';
    }): Promise<SendGridStats> {
      const [response] = await this.client.request({
        method: 'GET',
        url: '/v3/stats',
        qs: params
      });
      return response.body as SendGridStats;
    }
  • Tool definition registration including name, description, and input schema validation.
    {
      name: 'get_stats',
      description: 'Get SendGrid email statistics',
      inputSchema: {
        type: 'object',
        properties: {
          start_date: {
            type: 'string',
            description: 'Start date in YYYY-MM-DD format'
          },
          end_date: {
            type: 'string',
            description: 'End date in YYYY-MM-DD format (optional)'
          },
          aggregated_by: {
            type: 'string',
            enum: ['day', 'week', 'month'],
            description: 'How to aggregate the statistics (optional)'
          }
        },
        required: ['start_date']
      }
    },
  • MCP tool call dispatcher that invokes the service handler and serializes the stats response as JSON text.
    case 'get_stats':
      const stats = await service.getStats(args);
      return { content: [{ type: 'text', text: JSON.stringify(stats, null, 2) }] };
  • TypeScript interface for the output type SendGridStats, defining the structure of the API response.
    export interface SendGridStats extends Array<{
      date: string;
      stats: Array<{
        metrics: {
          opens: number;
          clicks: number;
          bounces: number;
          spam_reports: number;
          unique_opens: number;
          unique_clicks: number;
          blocks: number;
          delivered: number;
          bounce_drops?: number;
          deferred?: number;
          invalid_emails?: number;
          processed?: number;
          requests?: number;
          spam_report_drops?: number;
          unsubscribe_drops?: number;
          unsubscribes?: number;
        };
      }>;
    }> {}

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/Garoth/sendgrid-mcp'

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