@easyfunnel/mcp 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +49 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -662,18 +662,17 @@ var getFunnelHealthDefinition = {
|
|
|
662
662
|
required: ["project_id"]
|
|
663
663
|
}
|
|
664
664
|
};
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
);
|
|
671
|
-
let output = `Funnel: ${data.funnel_name}
|
|
665
|
+
function formatFunnelHealth(data, funnelId) {
|
|
666
|
+
let output = `Funnel: ${data.funnel_name}`;
|
|
667
|
+
if (funnelId) output += `
|
|
668
|
+
ID: ${funnelId}`;
|
|
669
|
+
output += `
|
|
672
670
|
Time range: ${data.time_range}
|
|
673
671
|
|
|
674
672
|
`;
|
|
675
|
-
|
|
676
|
-
|
|
673
|
+
const steps = data.steps || [];
|
|
674
|
+
for (const step of steps) {
|
|
675
|
+
const bar = "\u2588".repeat(Math.max(1, Math.round(step.count / (steps[0]?.count || 1) * 20)));
|
|
677
676
|
output += `${step.label}: ${step.count} ${bar}`;
|
|
678
677
|
if (step.drop_off_pct !== null) {
|
|
679
678
|
output += ` (\u2193 ${step.drop_off_pct}% drop-off)`;
|
|
@@ -691,8 +690,48 @@ Median time to convert: ${data.median_time_to_convert}`;
|
|
|
691
690
|
|
|
692
691
|
\u{1F4A1} ${data.suggestion}`;
|
|
693
692
|
}
|
|
693
|
+
return output;
|
|
694
|
+
}
|
|
695
|
+
async function getFunnelHealth(client2, args) {
|
|
696
|
+
const timeRange = args.time_range || "7d";
|
|
697
|
+
if (!args.funnel_id) {
|
|
698
|
+
const funnels = await client2.listFunnels(args.project_id);
|
|
699
|
+
if (!funnels || funnels.length === 0) {
|
|
700
|
+
return {
|
|
701
|
+
content: [{ type: "text", text: "No funnels found for this project. Create one with create_funnel first." }]
|
|
702
|
+
};
|
|
703
|
+
}
|
|
704
|
+
let output = `Found ${funnels.length} funnel(s). Checking health for each...
|
|
705
|
+
|
|
706
|
+
`;
|
|
707
|
+
let worstFunnel = null;
|
|
708
|
+
for (const funnel of funnels) {
|
|
709
|
+
try {
|
|
710
|
+
const data2 = await client2.getFunnelHealth(args.project_id, funnel.id, timeRange);
|
|
711
|
+
output += formatFunnelHealth(data2, funnel.id) + "\n---\n\n";
|
|
712
|
+
if (worstFunnel === null || data2.overall_conversion < worstFunnel.conversion) {
|
|
713
|
+
worstFunnel = { name: data2.funnel_name, conversion: data2.overall_conversion };
|
|
714
|
+
}
|
|
715
|
+
} catch {
|
|
716
|
+
output += `Funnel: ${funnel.name} (${funnel.id})
|
|
717
|
+
Error fetching health data.
|
|
718
|
+
|
|
719
|
+
---
|
|
720
|
+
|
|
721
|
+
`;
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
if (worstFunnel) {
|
|
725
|
+
output += `
|
|
726
|
+
Worst-performing funnel: ${worstFunnel.name} (${worstFunnel.conversion}% conversion)`;
|
|
727
|
+
}
|
|
728
|
+
return {
|
|
729
|
+
content: [{ type: "text", text: output }]
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
const data = await client2.getFunnelHealth(args.project_id, args.funnel_id, timeRange);
|
|
694
733
|
return {
|
|
695
|
-
content: [{ type: "text", text:
|
|
734
|
+
content: [{ type: "text", text: formatFunnelHealth(data, args.funnel_id) }]
|
|
696
735
|
};
|
|
697
736
|
}
|
|
698
737
|
|