Skip to content

Conversation

@matthewbergvinson
Copy link

🎯 Overview

This PR adds the missing smartlead_get_campaign_analytics MCP tool that was referenced in documentation but not implemented in the codebase.

🐛 Problem

The smartlead_get_campaign_analytics tool was listed in various documentation and test files but was not actually registered as an MCP tool, causing failures when users tried to use it.

✅ Solution

Added two components:

  1. Client Method (src/modules/campaigns/client.ts):

    • Added getCampaignAnalytics(campaignId: number) method
    • Calls /campaigns/{id}/analytics endpoint
    • No date parameters (API doesn't accept them)
  2. MCP Tool (src/tools/campaigns.ts):

    • Added smartlead_get_campaign_analytics tool registration
    • Uses GetCampaignRequestSchema for validation
    • Returns comprehensive campaign analytics

📊 What This Tool Provides

The tool returns comprehensive campaign analytics including:

  • Sent count, open count, reply count, bounce count
  • Campaign status and sequence information
  • Lead statistics (total, completed, interested, blocked, etc.)
  • Client information (name, email, company)

🧪 Testing

  • ✅ Verified tool registration works correctly
  • ✅ Confirmed API endpoint responds successfully
  • ✅ Validated return data structure matches expected schema
  • ✅ Tested with real SmartLead API data

📝 Files Changed

  • src/modules/campaigns/client.ts - Added getCampaignAnalytics method
  • src/tools/campaigns.ts - Added smartlead_get_campaign_analytics tool

🔗 Usage Example

// Tool accepts campaign_id parameter
{
  "campaign_id": 12345
}

// Returns comprehensive analytics
{
  "id": 12345,
  "name": "Campaign Name",
  "sent_count": "1000",
  "open_count": "250", 
  "reply_count": "45",
  "bounce_count": "12",
  "status": "ACTIVE",
  "campaign_lead_stats": {
    "total": 500,
    "completed": 450,
    "interested": 25,
    "blocked": 5
  },
  // ...additional fields
}

This is a straightforward addition that fills a gap in the existing MCP tool coverage.

- Add getCampaignAnalytics method to CampaignClient
- Add smartlead_get_campaign_analytics MCP tool registration
- Tool calls /campaigns/{id}/analytics endpoint without date parameters
- Fixes missing campaign analytics functionality
- Returns comprehensive campaign metrics (sent, open, reply, bounce counts)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant