MailmodoCampainReportTool
Get campaign reports with open, click, and submission counts for a specified campaign ID within a date range.
Instructions
Tool to get the campaign reports for a particular campaign like open, click submission count etc
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| campaignId | Yes | ||
| fromDate | Yes | ||
| toDate | Yes |
Implementation Reference
- src/server.ts:78-97 (registration)Registration of the 'MailmodoCampainReportTool' tool on the MCP server with input schema (campaignId, fromDate, toDate) and handler invocation.
server.tool("MailmodoCampainReportTool", "Tool to get the campaign reports for a particular campaign like open, click submission count etc", { campaignId: z.string().uuid(), fromDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/, { message: 'fromDate must be in YYYY-MM-DD format', }), toDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/, { message: 'toDate must be in YYYY-MM-DD format', }), }, async ({ campaignId, fromDate, toDate }) => { const campaigns = await fetchCampaignReport(mmApiKey,campaignId,fromDate,toDate); return { content: [{ type: "text", text: campaigns.success? JSON.stringify(campaigns.data): "Something went wrong. Please check if correct campaign ID is being passed" }] } } ); - The fetchCampaignReport async function that executes the tool logic: makes a POST request to Mailmodo API to get campaign reports.
export async function fetchCampaignReport( mmApiKey: string, campaignId: string, fromDate: string, toDate: string ): Promise<CampaignReportResponse> { try { const response = await axios.post( `https://api.mailmodo.com/api/v1/campaignReports/${campaignId}`, { fromDate, toDate }, { headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'mmApiKey': mmApiKey || '' } } ); return {success: true, data: response.data}; } catch (error) { console.error('Error fetching campaign report:', error); return {success: false, data: null}; } } - Type definitions for the campaign report response including CampaignReportData interface with all analytics/engagement metrics and CampaignReportResponse wrapper.
export type CampaignType = 'TRIGGERED' | 'SCHEDULED' | 'DRAFT'; // Add other possible values if needed export type CampaignStatus = 'Triggered' | 'Scheduled' | 'Draft' | 'Completed'; // Add other possible values if needed export interface CampaignReportData { campaignId: string; campaignType: CampaignType; campaignName: string; status: CampaignStatus; senderEmail: string; subjects: string[]; createdAt: string; scheduledAt: string; // Analytics metrics bounced: number; complaints: number; submission: number; unsubscribed: number; blocked: number; scheduled: number; sent: number; delivered: number; // Engagement metrics clicks: number; ampClicks: number; htmlClicks: number; ampOpens: number; htmlOpens: number; opens: number; } export interface CampaignReportResponse{ success: boolean, data: CampaignReportData | null; }