get_analytics_data_by_id
Retrieve email analytics data for a specific message ID using TurboSMTP, enabling targeted tracking and analysis of email performance.
Instructions
Retrieve analytics data from TurboSMTP by specific message ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Message ID |
Implementation Reference
- mcp-turbosmtp-server.js:201-227 (handler)The primary MCP tool handler: validates the input ID, delegates to EmailService.getAnalyticsDataById, formats the response output, and returns the MCP content block.async handleGetAnalyticsDataById(args) { const { id } = args; if (!id) { throw new Error('The "id" parameter is required'); } try { const result = await EmailService.getAnalyticsDataById(id); // Format the analytics data for better readability let formattedOutput = `📊 Analytics Data Retrieved Successfully!\n\n`; formattedOutput += `\n📈 Analytics Summary:\n`; formattedOutput += `${JSON.stringify(result.data, null, 2)}`; return { content: [ { type: 'text', text: formattedOutput } ] }; } catch (error) { throw new Error(`Error retrieving analytics data: ${error.message}`); } }
- mcp-turbosmtp-server.js:102-115 (schema)Tool metadata registration including name, description, and input schema definition used in ListToolsRequestHandler.{ name: 'get_analytics_data_by_id', description: 'Retrieve analytics data from TurboSMTP by specific message ID', inputSchema: { type: 'object', properties: { id: { type: 'string', description: 'Message ID' } }, required: ['id'] } }
- mcp-turbosmtp-server.js:131-132 (registration)Tool dispatch registration in the CallToolRequestSchema switch statement.case 'get_analytics_data_by_id': return await this.handleGetAnalyticsDataById(args);
- email-service.js:118-149 (helper)Supporting utility in EmailService: validates ID, makes HTTP GET to TurboSMTP analytics API `/analytics/{id}`, handles response and errors.async getAnalyticsDataById(id) { // Validation of 'id' parameter. if (!id) { throw new Error('The "id" parameter is required'); } console.log(id); try { const response = await axios.get( `${this.apiUrl}/analytics/${id}`, { headers: this.headers } ); // Returning response data on success. return { success: true, message: 'Analytics data successfully retrieved', data: response.data }; } catch (error) { // Handling HTTP request errors. console.error('Error retrieving analytics data:', error.response?.data || error.message); throw new Error( error.response?.data?.message || 'Error retrieving analytics data: ' + error.message ); } }