logly_funnel_results
Retrieve completion counts and drop-off rates for each step of a conversion funnel. Analyze user progression to identify bottlenecks.
Instructions
Completion counts and drop-off per step for one conversion funnel.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| funnel_id | Yes | Funnel ID, from logly_funnels. | |
| days | No | Days to look back: 7, 30 or 90. Defaults to 30. Ignored when 'from'/'to' are set. |
Implementation Reference
- index.js:98-104 (registration)Registration of the 'logly_funnel_results' tool using the local `tool()` helper function.
tool( "logly_funnel_results", "Completion counts and drop-off per step for one conversion funnel.", { funnel_id: z.string().describe("Funnel ID, from logly_funnels."), days: daysArg }, ({ funnel_id, days }) => loglyApi(`/api/funnels/${encodeURIComponent(funnel_id)}/results`, { days: days ?? 30 }) ); - index.js:101-101 (schema)Input schema for funnel_results: funnel_id (string) and optional days (number, defaults to 30).
{ funnel_id: z.string().describe("Funnel ID, from logly_funnels."), days: daysArg }, - index.js:102-104 (handler)Handler function: calls loglyApi GET on /api/funnels/{funnel_id}/results with ?days=N.
({ funnel_id, days }) => loglyApi(`/api/funnels/${encodeURIComponent(funnel_id)}/results`, { days: days ?? 30 }) ); - index.js:8-27 (helper)The loglyApi helper that makes authenticated HTTP requests to the Logly API.
async function loglyApi(path, params) { const key = process.env.LOGLY_API_KEY; if (!key) { throw new Error( "LOGLY_API_KEY is not set. Create one in Logly → Settings → API keys." ); } const url = new URL(BASE + path); for (const [k, v] of Object.entries(params || {})) { if (v !== undefined && v !== null && v !== "") url.searchParams.set(k, String(v)); } const res = await fetch(url, { headers: { Authorization: `Bearer ${key}`, Accept: "application/json" }, }); const text = await res.text(); if (!res.ok) { throw new Error(`Logly API ${res.status} on ${path}: ${text.slice(0, 300)}`); } return text; } - index.js:37-45 (helper)The local tool() wrapper that registers each tool with the McpServer and handles errors.
function tool(name, description, shape, fn) { server.tool(name, description, shape, async (args) => { try { return { content: [{ type: "text", text: await fn(args || {}) }] }; } catch (e) { return { content: [{ type: "text", text: "Error: " + e.message }], isError: true }; } }); }