MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / registerFunnelTools

Function registerFunnelTools

packages/mcp/src/tools/analytics/funnel.ts:15–63  ·  view source on GitHub ↗
(
  server: McpServer,
  context: McpAuthContext,
)

Source from the content-addressed store, hash-verified

13} from '../shared';
14
15export function registerFunnelTools(
16 server: McpServer,
17 context: McpAuthContext,
18) {
19 server.tool(
20 'get_funnel',
21 'Analyze a conversion funnel between 2 or more events. Returns step-by-step conversion rates and drop-off percentages. For example, analyze sign-up flows, checkout funnels, or onboarding sequences.',
22 {
23 projectId: projectIdSchema(context),
24 ...zDateRange,
25 steps: z
26 .array(z.string())
27 .min(2)
28 .max(10)
29 .describe(
30 'Ordered list of event names forming the funnel steps (minimum 2, maximum 10)',
31 ),
32 windowHours: z
33 .number()
34 .min(1)
35 .max(720)
36 .default(24)
37 .optional()
38 .describe(
39 'Time window in hours within which all steps must occur (default: 24 hours)',
40 ),
41 groupBy: z
42 .enum(['session_id', 'profile_id'])
43 .default('session_id')
44 .optional()
45 .describe(
46 '"session_id" counts within-session completions, "profile_id" counts cross-session completions (default: session_id)',
47 ),
48 },
49 async ({ projectId: inputProjectId, startDate: sd, endDate: ed, steps, windowHours, groupBy }) =>
50 withErrorHandling(async () => {
51 const projectId = await resolveProjectId(context, inputProjectId);
52 const { startDate, endDate } = resolveDateRange(sd, ed);
53 return getFunnelCore({
54 projectId,
55 startDate,
56 endDate,
57 steps,
58 windowHours,
59 groupBy,
60 });
61 }),
62 );
63}

Callers 2

registerAllToolsFunction · 0.90
tools.test.tsFile · 0.90

Calls 5

projectIdSchemaFunction · 0.90
withErrorHandlingFunction · 0.90
resolveProjectIdFunction · 0.90
resolveDateRangeFunction · 0.90
getFunnelCoreFunction · 0.90

Tested by

no test coverage detected