get_analytics
Retrieve analytics data for a specific email draft from Buttondown to track performance metrics and engagement insights.
Instructions
Retrieve analytics data for a specific email draft from Buttondown
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| draftId | Yes | The ID of the email draft to get analytics for |
Implementation Reference
- src/mcp/index.ts:177-188 (handler)The handler function for the 'get_analytics' MCP tool. It ensures the API key is set, retrieves analytics data for the given draft ID using the ButtondownAPI client, and returns the JSON-stringified response wrapped in MCP content format.async ({ draftId }) => { await this.ensureApiKey(); const response = await this.api.getAnalytics(draftId); return { content: [ { type: "text", text: JSON.stringify(response, null, 2), }, ], }; }
- src/mcp/index.ts:172-176 (schema)Zod schema defining the input parameters for the 'get_analytics' tool: a required string draftId.{ draftId: z .string() .describe("The ID of the email draft to get analytics for"), },
- src/mcp/index.ts:169-189 (registration)Registration of the 'get_analytics' tool on the MCP server, including name, description, input schema, and handler.this.server.tool( "get_analytics", "Retrieve analytics data for a specific email draft from Buttondown", { draftId: z .string() .describe("The ID of the email draft to get analytics for"), }, async ({ draftId }) => { await this.ensureApiKey(); const response = await this.api.getAnalytics(draftId); return { content: [ { type: "text", text: JSON.stringify(response, null, 2), }, ], }; } );
- src/api/client.ts:87-89 (helper)API client helper method that fetches analytics data via HTTP GET to Buttondown's /emails/{emailId}/analytics endpoint.async getAnalytics(emailId: string): Promise<ButtondownAnalytics> { return this.request<ButtondownAnalytics>(`/emails/${emailId}/analytics`); }