@zellifyapp/mcp 0.3.0 → 0.4.0

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.
Files changed (44) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +16 -15
  3. package/build/client.d.ts +77 -28
  4. package/build/client.d.ts.map +1 -1
  5. package/build/client.js +78 -34
  6. package/build/client.test.d.ts +2 -0
  7. package/build/client.test.d.ts.map +1 -0
  8. package/build/client.test.js +88 -0
  9. package/build/index.js +63 -45
  10. package/build/init.d.ts.map +1 -1
  11. package/build/init.js +3 -2
  12. package/build/prompts/integration-plan.d.ts +2 -0
  13. package/build/prompts/integration-plan.d.ts.map +1 -1
  14. package/build/prompts/integration-plan.js +46 -30
  15. package/build/tools/get-example-payload.d.ts.map +1 -1
  16. package/build/tools/get-example-payload.js +24 -7
  17. package/build/tools/get-funnel-schema.d.ts.map +1 -1
  18. package/build/tools/get-funnel-schema.js +35 -7
  19. package/build/tools/get-integrations.d.ts +2 -0
  20. package/build/tools/get-integrations.d.ts.map +1 -1
  21. package/build/tools/get-integrations.js +37 -22
  22. package/build/tools/get-integrations.test.d.ts +2 -0
  23. package/build/tools/get-integrations.test.d.ts.map +1 -0
  24. package/build/tools/get-integrations.test.js +29 -0
  25. package/build/tools/list-funnels.d.ts.map +1 -1
  26. package/build/tools/list-funnels.js +6 -7
  27. package/build/tools/validate-setup.d.ts +2 -0
  28. package/build/tools/validate-setup.d.ts.map +1 -1
  29. package/build/tools/validate-setup.js +85 -52
  30. package/build/tools/validate-setup.test.d.ts +2 -0
  31. package/build/tools/validate-setup.test.d.ts.map +1 -0
  32. package/build/tools/validate-setup.test.js +57 -0
  33. package/commands/integrationcheck.md +3 -1
  34. package/package.json +7 -4
  35. package/skill/SKILL.md +36 -35
  36. package/skill/references/debugging.md +28 -20
  37. package/skill/references/integration-paths.md +47 -25
  38. package/skill/references/language-guides.md +7 -3
  39. package/skill/references/revenuecat.md +15 -16
  40. package/skill/references/types-and-payload.md +336 -70
  41. package/skill/references/webhook-handler.md +31 -22
  42. package/build/tools/send-test-webhook.d.ts +0 -3
  43. package/build/tools/send-test-webhook.d.ts.map +0 -1
  44. package/build/tools/send-test-webhook.js +0 -78
package/CHANGELOG.md ADDED
@@ -0,0 +1,14 @@
1
+ # Changelog
2
+
3
+ ## 0.4.0
4
+
5
+ This version breaks existing installs: replace your API key with an access key.
6
+
7
+ - The server calls the Zellify API at `https://api.zellify.app` with an access key (`zak_…`) in `ZELLIFY_API_KEY`. Create one in **Settings** > **Developers** with the permissions **Read funnels** and **Read integrations**, then run `claude mcp remove zellify` and add the server again with the new key.
8
+ - API keys (`zk_live_…`) were retired. With one, every tool answers "API keys were retired; create an access key in Settings > Developers with the permissions Read funnels and Read integrations" and sends no request.
9
+ - `send_test_webhook` was removed. Click **Send test** in **Settings** > **Developers** to send a signed test request to your registration webhook.
10
+ - `validate_setup` names each permission the access key lacks.
11
+ - `list_funnels` shows when a code funnel was published. Funnel IDs are strings.
12
+ - `get_integrations` returns `linkCount` instead of `campaignCount`.
13
+ - Errors show the API's problem `detail`, or its `title`, with the HTTP status.
14
+ - The `--api-key` command-line flag was removed. Pass the key with `-e ZELLIFY_API_KEY=…`.
package/README.md CHANGED
@@ -1,33 +1,36 @@
1
1
  # @zellifyapp/mcp
2
2
 
3
- An MCP server that gives Claude Code full context about your Zellify funnels — variable names, payload shapes, integration status — so it can build, test, and debug your webhook integration without guessing.
3
+ An MCP server that gives Claude Code full context about your Zellify funnels — variable names, payload shapes, integration status — so it can build and debug your webhook integration without guessing.
4
4
 
5
5
  ## Install
6
6
 
7
- 1. Generate an API key in Zellify Dashboard → Settings → Developer.
7
+ 1. Create an access key in Zellify Dashboard → [Settings → Developers](https://dash.zellify.app/settings?tab=developers) with the permissions **Read funnels** and **Read integrations**. Copy it when the dashboard shows it; it starts with `zak_`.
8
8
 
9
9
  2. Register the MCP server, then run the init command to copy the skill + slash command into your project:
10
10
  ```bash
11
- claude mcp add zellify -e ZELLIFY_API_KEY=YOUR_API_KEY -- npx -y @zellifyapp/mcp@latest
11
+ claude mcp add zellify -e ZELLIFY_API_KEY=YOUR_ACCESS_KEY -- npx -y @zellifyapp/mcp@latest
12
12
  npx -y @zellifyapp/mcp@latest init
13
13
  ```
14
14
 
15
15
  The init command is pure Node, so it works on macOS, Linux, and Windows (PowerShell, cmd.exe, and Git Bash) without shell-specific tweaks. Re-run it any time to update the skill files to the latest version.
16
16
 
17
- The API key is passed as an environment variable (`-e ZELLIFY_API_KEY=…`), not on the command line — argv-passed secrets leak to `ps`, shell history, and process inspection. If you previously installed with `--api-key`, rotate that key in the dashboard and re-add with the form above.
17
+ The access key is passed as an environment variable (`-e ZELLIFY_API_KEY=…`), not on the command line — argv-passed secrets leak to `ps`, shell history, and process inspection.
18
18
 
19
19
  3. Fully quit and reopen Claude Code (⌘Q on macOS — closing the window is not enough; the MCP server registration is loaded once at startup). Then run `/integrationcheck` in Claude Code. Claude will analyze your codebase, ask any clarifying questions, pick the easiest integration path, and produce a complete plan you can approve and execute in one session.
20
20
 
21
+ Version 0.4.0 retired API keys: the MCP takes only access keys. With an API key, every tool answers with an error that tells you to create an access key. Replace it with `claude mcp remove zellify` and the `claude mcp add` command above.
22
+
21
23
  ## Available tools
22
24
 
23
25
  | Tool | Description |
24
26
  |------|-------------|
25
- | `validate_setup` | Verify the MCP is configured: env var present, API key valid, backend reachable, funnels published. Run this first if anything else fails. |
26
- | `list_funnels` | List all funnels with IDs, names, published status, and last updated date |
27
+ | `validate_setup` | Verify the MCP is configured: env var present, access key valid, both permissions granted, backend reachable, funnels published. Run this first if anything else fails. |
28
+ | `list_funnels` | List all funnels with IDs, names, publish status, and last updated date |
27
29
  | `get_funnel_schema` | Get a funnel's variables — names, question types, option ID-to-label mappings |
28
30
  | `get_example_payload` | Get a realistic example webhook payload and TypeScript interface for a funnel |
29
- | `get_integrations` | Check configured integrations, payment provider, registration webhook URL, and active campaign count |
30
- | `send_test_webhook` | Fire a signed test webhook to your configured endpoint and report the result |
31
+ | `get_integrations` | Check configured integrations, payment providers, registration webhook URL, and link count |
32
+
33
+ To send a test request to your registration webhook, click **Send test** in the dashboard under Settings → Developers.
31
34
 
32
35
  ## Example prompts
33
36
 
@@ -35,10 +38,6 @@ An MCP server that gives Claude Code full context about your Zellify funnels —
35
38
  Build me a webhook handler for my Zellify funnel
36
39
  ```
37
40
 
38
- ```
39
- Send a test webhook to my endpoint and debug any errors
40
- ```
41
-
42
41
  ```
43
42
  Check my integration setup — is my webhook configured?
44
43
  ```
@@ -51,10 +50,12 @@ Generate TypeScript types and a Zod schema for my funnel's payload
51
50
 
52
51
  | Variable | Required | Description |
53
52
  |----------|----------|-------------|
54
- | `ZELLIFY_API_KEY` | Yes | MCP API key from the Zellify Dashboard |
53
+ | `ZELLIFY_API_KEY` | Yes | Access key from the Zellify Dashboard with the permissions Read funnels and Read integrations |
55
54
  | `ZELLIFY_API_URL` | No | API base URL (default: `https://api.zellify.app`) |
56
55
 
57
56
  ## Links
58
57
 
59
- - [Zellify Docs](https://docs.zellify.app)
60
- - [Dashboard](https://dashboard.zellify.app)
58
+ - [MCP docs](https://docs.zellify.app/developers/zellify-mcp)
59
+ - [Developer Docs](https://docs.zellify.app/developers/how-access-works)
60
+ - [Platform Docs](https://docs.zellify.app)
61
+ - [Dashboard](https://dash.zellify.app)
package/build/client.d.ts CHANGED
@@ -1,54 +1,103 @@
1
+ export declare const API_URL: string;
2
+ /** What the MCP needs, keyed by scope, in the words the dashboard shows. */
3
+ export declare const REQUIRED_PERMISSIONS: {
4
+ readonly "funnels:read": "Read funnels";
5
+ readonly "integrations:read": "Read integrations";
6
+ };
7
+ export declare const RETIRED_KEY_MESSAGE = "API keys were retired; create an access key in Settings > Developers (https://dash.zellify.app/settings?tab=developers) with the permissions Read funnels and Read integrations, and set it as ZELLIFY_API_KEY.";
8
+ /** Keys from before access keys. The API no longer accepts them. */
9
+ export declare function isRetiredApiKey(key: string): boolean;
10
+ export declare class ZellifyApiError extends Error {
11
+ readonly status: number;
12
+ constructor(status: number, detail: string);
13
+ }
14
+ export interface AccessKey {
15
+ expiresAt: string | null;
16
+ id: string;
17
+ name: string;
18
+ organizationId: string;
19
+ scopes: string[];
20
+ }
1
21
  export interface Funnel {
2
- id: number;
22
+ createdAt: string;
23
+ id: string;
3
24
  name: string;
4
- published: boolean;
25
+ /** Always null for a legacy funnel: the API does not report its state. */
26
+ publishedAt: string | null;
5
27
  updatedAt: string;
28
+ variant: "schema" | "code";
6
29
  }
7
30
  export interface FunnelVariable {
8
31
  name: string;
9
- type: string;
10
- questionType: string;
11
- questionText: string | null;
12
- pageSlug: string | null;
13
32
  options: Array<{
14
33
  id: string;
15
34
  label: string;
16
35
  }>;
36
+ pageSlug: string | null;
37
+ questionText: string | null;
38
+ questionType: string;
39
+ type: string;
17
40
  }
18
41
  export interface ExamplePayloadResponse {
19
42
  payload: Record<string, unknown>;
20
- signatureHeader: string;
21
43
  signatureAlgorithm: string;
44
+ signatureHeader: string;
22
45
  typescript: string;
23
46
  }
47
+ export type SchemaState = "published" | "current";
48
+ export interface CodeFunnelField {
49
+ field: string;
50
+ format?: string;
51
+ labels?: Record<string, string>;
52
+ max?: number;
53
+ min?: number;
54
+ possible_values?: string[];
55
+ question: string;
56
+ questionType: string;
57
+ required?: boolean;
58
+ source: string;
59
+ type: string;
60
+ unit?: string;
61
+ }
62
+ export interface CodeFunnelSchemaResponse {
63
+ commitSha: string | null;
64
+ fields: CodeFunnelField[];
65
+ publishedCommitSha: string | null;
66
+ state: SchemaState;
67
+ }
68
+ export type FunnelSchemaResponse = {
69
+ variables: FunnelVariable[];
70
+ } | CodeFunnelSchemaResponse;
71
+ export type FunnelExamplePayloadResponse = ExamplePayloadResponse | (ExamplePayloadResponse & {
72
+ state: SchemaState;
73
+ commitSha: string | null;
74
+ publishedCommitSha: string | null;
75
+ });
24
76
  export interface Integration {
25
- name: string;
26
77
  configured: boolean;
27
- /** Present for `registration_webhook` only. The configured public webhook URL, or null if unset. */
28
- url?: string | null;
78
+ name: string;
29
79
  /** Present for `registration_webhook` only. Whether the signing secret is configured. */
30
80
  secretConfigured?: boolean;
81
+ /** Present for `registration_webhook` only. The configured public webhook URL, or null if unset. */
82
+ url?: string | null;
83
+ }
84
+ export interface PaymentIntegration {
85
+ connected: boolean;
86
+ environment: "live" | "sandbox";
87
+ name: "stripe" | "paddle" | "solidgate" | "inflowpay";
31
88
  }
32
89
  export interface IntegrationsResponse {
33
90
  integrations: Integration[];
91
+ linkCount: number;
34
92
  paymentProvider: string | null;
35
- campaignCount: number;
36
- }
37
- export interface TestWebhookResponse {
38
- success: boolean;
39
- statusCode?: number;
40
- responseBody?: string;
41
- responseTimeMs?: number;
42
- error?: string;
43
- payloadSent: Record<string, unknown>;
44
- }
45
- export declare function listFunnels(): Promise<{
46
- funnels: Funnel[];
47
- }>;
48
- export declare function getFunnelSchema(funnelId: string): Promise<{
49
- variables: FunnelVariable[];
50
- }>;
51
- export declare function getExamplePayload(funnelId: string): Promise<ExamplePayloadResponse>;
93
+ paymentProviders: PaymentIntegration[];
94
+ }
95
+ export declare function getKey(): Promise<AccessKey>;
96
+ /** Every funnel of the workspace, newest first. */
97
+ export declare function listFunnels(): Promise<Funnel[]>;
98
+ export declare function funnelStatus(funnel: Funnel): string;
99
+ export declare function getFunnelSchema(funnelId: string, state?: SchemaState): Promise<FunnelSchemaResponse>;
100
+ export declare function getExamplePayload(funnelId: string, state?: SchemaState): Promise<FunnelExamplePayloadResponse>;
52
101
  export declare function getIntegrations(): Promise<IntegrationsResponse>;
53
- export declare function sendTestWebhook(funnelId: string): Promise<TestWebhookResponse>;
102
+ export declare function paymentIntegrationDisplayName(payment: PaymentIntegration): string;
54
103
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAyCA,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE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,EAAE,WAAW,GAClB,OAAO,CAAC,4BAA4B,CAAC,CAOvC;AAED,wBAAgB,eAAe,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAE/D;AAED,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,kBAAkB,GAC1B,MAAM,CAER"}
package/build/client.js CHANGED
@@ -1,49 +1,93 @@
1
- const API_URL = process.env.ZELLIFY_API_URL ?? "https://standalone-api.zellify.app";
1
+ export const API_URL = process.env.ZELLIFY_API_URL ?? "https://api.zellify.app";
2
2
  const API_KEY = process.env.ZELLIFY_API_KEY ?? "";
3
- async function request(method, path, body) {
3
+ const DEVELOPER_SETTINGS_URL = "https://dash.zellify.app/settings?tab=developers";
4
+ /** What the MCP needs, keyed by scope, in the words the dashboard shows. */
5
+ export const REQUIRED_PERMISSIONS = {
6
+ "funnels:read": "Read funnels",
7
+ "integrations:read": "Read integrations",
8
+ };
9
+ export const RETIRED_KEY_MESSAGE = `API keys were retired; create an access key in Settings > Developers (${DEVELOPER_SETTINGS_URL}) with the permissions Read funnels and Read integrations, and set it as ZELLIFY_API_KEY.`;
10
+ /** Keys from before access keys. The API no longer accepts them. */
11
+ export function isRetiredApiKey(key) {
12
+ return key.startsWith("zk_live_");
13
+ }
14
+ export class ZellifyApiError extends Error {
15
+ status;
16
+ constructor(status, detail) {
17
+ super(`Zellify API ${status}: ${detail}`);
18
+ this.status = status;
19
+ }
20
+ }
21
+ // Errors are RFC 9457 problem documents: `detail` explains this failure,
22
+ // `title` the kind of failure.
23
+ async function problemDetail(response) {
24
+ try {
25
+ const problem = (await response.json());
26
+ if (typeof problem.detail === "string") {
27
+ return problem.detail;
28
+ }
29
+ if (typeof problem.title === "string") {
30
+ return problem.title;
31
+ }
32
+ }
33
+ catch {
34
+ // Not JSON: fall back to the status text.
35
+ }
36
+ return response.statusText;
37
+ }
38
+ async function request(path) {
4
39
  if (!API_KEY) {
5
- throw new Error("ZELLIFY_API_KEY is not set. Create an API key in your Zellify dashboard under Settings > API Keys.");
40
+ throw new Error(`ZELLIFY_API_KEY is not set. Create an access key in Settings > Developers (${DEVELOPER_SETTINGS_URL}) with the permissions Read funnels and Read integrations.`);
6
41
  }
7
- const url = `${API_URL}${path}`;
8
- const init = {
9
- method,
10
- headers: {
11
- Authorization: `Bearer ${API_KEY}`,
12
- "Content-Type": "application/json",
13
- },
14
- };
15
- if (body !== undefined) {
16
- init.body = JSON.stringify(body);
42
+ if (isRetiredApiKey(API_KEY)) {
43
+ throw new Error(RETIRED_KEY_MESSAGE);
17
44
  }
18
- const response = await fetch(url, init);
45
+ const response = await fetch(`${API_URL}${path}`, {
46
+ headers: { Authorization: `Bearer ${API_KEY}` },
47
+ });
19
48
  if (!response.ok) {
20
- let message;
21
- try {
22
- const err = (await response.json());
23
- message = err.error ?? response.statusText;
24
- }
25
- catch {
26
- message = response.statusText;
27
- }
28
- throw new Error(`Zellify API ${response.status}: ${message}`);
49
+ throw new ZellifyApiError(response.status, await problemDetail(response));
29
50
  }
30
51
  return response.json();
31
52
  }
32
53
  // ── Client methods ──────────────────────────────────────
54
+ function withState(path, state) {
55
+ return state ? `${path}?state=${state}` : path;
56
+ }
57
+ export function getKey() {
58
+ return request("/v1/key");
59
+ }
60
+ /** Every funnel of the workspace, newest first. */
33
61
  export async function listFunnels() {
34
- return request("GET", "/v1/mcp/funnels");
62
+ const funnels = [];
63
+ let after = null;
64
+ do {
65
+ const query = after
66
+ ? `?limit=100&after=${encodeURIComponent(after)}`
67
+ : "?limit=100";
68
+ const page = await request(`/v1/funnels${query}`);
69
+ funnels.push(...page.data);
70
+ after = page.next;
71
+ } while (after);
72
+ return funnels;
73
+ }
74
+ export function funnelStatus(funnel) {
75
+ if (funnel.variant === "schema") {
76
+ return "legacy funnel";
77
+ }
78
+ return funnel.publishedAt
79
+ ? `code funnel, published ${funnel.publishedAt}`
80
+ : "code funnel, not published";
35
81
  }
36
- export async function getFunnelSchema(funnelId) {
37
- return request("GET", `/v1/mcp/funnels/${funnelId}/schema`);
82
+ export function getFunnelSchema(funnelId, state) {
83
+ return request(withState(`/v1/funnels/${encodeURIComponent(funnelId)}/schema`, state));
38
84
  }
39
- export async function getExamplePayload(funnelId) {
40
- return request("GET", `/v1/mcp/funnels/${funnelId}/example-payload`);
85
+ export function getExamplePayload(funnelId, state) {
86
+ return request(withState(`/v1/funnels/${encodeURIComponent(funnelId)}/example-payload`, state));
41
87
  }
42
- export async function getIntegrations() {
43
- return request("GET", "/v1/mcp/integrations");
88
+ export function getIntegrations() {
89
+ return request("/v1/integrations");
44
90
  }
45
- export async function sendTestWebhook(funnelId) {
46
- return request("POST", "/v1/mcp/test-webhook", {
47
- funnelId: Number(funnelId),
48
- });
91
+ export function paymentIntegrationDisplayName(payment) {
92
+ return `${payment.name} (${payment.environment})`;
49
93
  }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=client.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.test.d.ts","sourceRoot":"","sources":["../src/client.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,88 @@
1
+ import { afterEach, describe, expect, it, vi } from "vitest";
2
+ const ACCESS_KEY = "zak_0123456789abcdef_secret";
3
+ // The client reads its environment when it loads, so each test loads it anew.
4
+ async function loadClient(env) {
5
+ vi.resetModules();
6
+ vi.stubEnv("ZELLIFY_API_KEY", env.key);
7
+ vi.stubEnv("ZELLIFY_API_URL", env.url);
8
+ return await import("./client.js");
9
+ }
10
+ function stubFetch(...responses) {
11
+ const fetch = vi.fn();
12
+ for (const response of responses) {
13
+ fetch.mockResolvedValueOnce(response);
14
+ }
15
+ vi.stubGlobal("fetch", fetch);
16
+ return fetch;
17
+ }
18
+ function problem(body, status) {
19
+ return Response.json(body, {
20
+ headers: { "content-type": "application/problem+json" },
21
+ status,
22
+ });
23
+ }
24
+ afterEach(() => {
25
+ vi.unstubAllEnvs();
26
+ vi.unstubAllGlobals();
27
+ });
28
+ describe("Zellify API client", () => {
29
+ it("refuses a retired API key before sending any request", async () => {
30
+ const fetch = stubFetch();
31
+ const client = await loadClient({ key: "zk_live_0123456789abcdef" });
32
+ await expect(client.listFunnels()).rejects.toThrow("API keys were retired; create an access key in Settings > Developers");
33
+ expect(fetch).not.toHaveBeenCalled();
34
+ });
35
+ it("sends the access key to the customer API at api.zellify.app", async () => {
36
+ const fetch = stubFetch(Response.json({
37
+ expiresAt: null,
38
+ id: "0123456789abcdef",
39
+ name: "MCP",
40
+ organizationId: "org",
41
+ scopes: ["funnels:read"],
42
+ }));
43
+ const client = await loadClient({ key: ACCESS_KEY });
44
+ await expect(client.getKey()).resolves.toMatchObject({ name: "MCP" });
45
+ expect(fetch).toHaveBeenCalledWith("https://api.zellify.app/v1/key", {
46
+ headers: { Authorization: `Bearer ${ACCESS_KEY}` },
47
+ });
48
+ });
49
+ it("shows a problem's detail with its status", async () => {
50
+ stubFetch(problem({
51
+ detail: "This route needs the scope integrations:read.",
52
+ status: 403,
53
+ title: "The access key lacks the scope this route needs",
54
+ type: "https://developers.zellify.app/problems/api/forbidden",
55
+ }, 403));
56
+ const client = await loadClient({ key: ACCESS_KEY });
57
+ await expect(client.getIntegrations()).rejects.toThrow("Zellify API 403: This route needs the scope integrations:read.");
58
+ });
59
+ it("shows a problem's title when it has no detail", async () => {
60
+ stubFetch(problem({ status: 500, title: "Internal server error" }, 500));
61
+ const client = await loadClient({ key: ACCESS_KEY });
62
+ await expect(client.getFunnelSchema("42")).rejects.toMatchObject({
63
+ message: "Zellify API 500: Internal server error",
64
+ status: 500,
65
+ });
66
+ });
67
+ it("reads every page of funnels", async () => {
68
+ const funnel = (id) => ({
69
+ createdAt: "2026-11-20T10:00:00.000Z",
70
+ id,
71
+ name: `Funnel ${id}`,
72
+ publishedAt: null,
73
+ updatedAt: "2026-11-20T10:00:00.000Z",
74
+ variant: "code",
75
+ });
76
+ const fetch = stubFetch(Response.json({ data: [funnel("2")], next: "1763632800000000_2" }), Response.json({ data: [funnel("1")], next: null }));
77
+ const client = await loadClient({
78
+ key: ACCESS_KEY,
79
+ url: "https://pr-2687-customer-api.preview.zellify.app",
80
+ });
81
+ const funnels = await client.listFunnels();
82
+ expect(funnels.map((f) => f.id)).toEqual(["2", "1"]);
83
+ expect(fetch.mock.calls.map(([url]) => String(url))).toEqual([
84
+ "https://pr-2687-customer-api.preview.zellify.app/v1/funnels?limit=100",
85
+ "https://pr-2687-customer-api.preview.zellify.app/v1/funnels?limit=100&after=1763632800000000_2",
86
+ ]);
87
+ });
88
+ });
package/build/index.js CHANGED
@@ -2,6 +2,15 @@
2
2
  import { readFileSync } from "node:fs";
3
3
  import { dirname, join } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
6
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
7
+ import { run } from "./init.js";
8
+ import { registerIntegrationPlanPrompt } from "./prompts/integration-plan.js";
9
+ import { registerGetExamplePayload } from "./tools/get-example-payload.js";
10
+ import { registerGetFunnelSchema } from "./tools/get-funnel-schema.js";
11
+ import { registerGetIntegrations } from "./tools/get-integrations.js";
12
+ import { registerListFunnels } from "./tools/list-funnels.js";
13
+ import { registerValidateSetup } from "./tools/validate-setup.js";
5
14
  const args = process.argv.slice(2);
6
15
  if (args.includes("--help") || args.includes("-h") || args[0] === "help") {
7
16
  process.stdout.write(`zellify-mcp — Zellify MCP server for Claude Code
@@ -14,72 +23,56 @@ Usage:
14
23
  zellify-mcp --help Show this message.
15
24
 
16
25
  Authentication:
17
- The server reads ZELLIFY_API_KEY from its environment. With Claude Code:
26
+ The server reads an access key from ZELLIFY_API_KEY. Create one in
27
+ Settings > Developers with the permissions Read funnels and Read
28
+ integrations. With Claude Code:
18
29
 
19
- claude mcp add zellify -e ZELLIFY_API_KEY=YOUR_KEY -- npx -y @zellifyapp/mcp@latest
30
+ claude mcp add zellify -e ZELLIFY_API_KEY=YOUR_ACCESS_KEY -- npx -y @zellifyapp/mcp@latest
20
31
 
21
32
  Pass the key via -e (env), not on the command line — argv leaks to ps,
22
33
  shell history, and process inspection.
23
34
 
24
35
  Environment variables:
25
- ZELLIFY_API_KEY Required. Generate at https://dash.zellify.app/dashboard/settings/developer
26
- ZELLIFY_API_URL Optional. Defaults to https://standalone-api.zellify.app
36
+ ZELLIFY_API_KEY Required. An access key from https://dash.zellify.app/settings?tab=developers
37
+ ZELLIFY_API_URL Optional. Defaults to https://api.zellify.app
27
38
 
28
39
  Docs:
29
- https://docs.zellify.app
40
+ https://docs.zellify.app/developers/zellify-mcp
30
41
  `);
31
42
  process.exit(0);
32
43
  }
33
44
  if (args[0] === "init") {
34
- const { run } = await import("./init.js");
35
45
  run();
36
46
  process.exit(0);
37
47
  }
38
- // Backward compatibility: a previous version of the install docs used
39
- // `--api-key VALUE` on the command line. The server reads from env, so the
40
- // flag silently did nothing. Accept it now (set the env), warn loudly that
41
- // it's insecure, and tell the user how to migrate.
42
- const apiKeyFlagIdx = args.indexOf("--api-key");
43
- if (apiKeyFlagIdx !== -1 && args[apiKeyFlagIdx + 1]) {
44
- process.env.ZELLIFY_API_KEY = args[apiKeyFlagIdx + 1];
45
- process.stderr.write("[zellify-mcp] WARNING: --api-key on the command line is insecure (leaks to ps, shell history, process inspection).\n" +
46
- "[zellify-mcp] Rotate this key in the dashboard and re-add the MCP with -e ZELLIFY_API_KEY=…:\n" +
47
- "[zellify-mcp] claude mcp remove zellify\n" +
48
- "[zellify-mcp] claude mcp add zellify -e ZELLIFY_API_KEY=NEW_KEY -- npx -y @zellifyapp/mcp@latest\n");
49
- }
50
- // Imports below depend on env being read (client.ts captures ZELLIFY_API_KEY
51
- // at module-eval time), so do them after the --api-key fallback above.
52
- const { McpServer } = await import("@modelcontextprotocol/sdk/server/mcp.js");
53
- const { StdioServerTransport } = await import("@modelcontextprotocol/sdk/server/stdio.js");
54
- const { registerListFunnels } = await import("./tools/list-funnels.js");
55
- const { registerGetFunnelSchema } = await import("./tools/get-funnel-schema.js");
56
- const { registerGetExamplePayload } = await import("./tools/get-example-payload.js");
57
- const { registerGetIntegrations } = await import("./tools/get-integrations.js");
58
- const { registerSendTestWebhook } = await import("./tools/send-test-webhook.js");
59
- const { registerValidateSetup } = await import("./tools/validate-setup.js");
60
- const { registerIntegrationPlanPrompt } = await import("./prompts/integration-plan.js");
61
48
  const __dirname = dirname(fileURLToPath(import.meta.url));
62
49
  const referencesDir = join(__dirname, "..", "skill", "references");
50
+ const { version } = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf-8"));
63
51
  const server = new McpServer({
64
52
  name: "zellify",
65
- version: "0.3.0",
53
+ version,
66
54
  }, {
67
55
  instructions: `Zellify MCP — integrate with Zellify web funnels.
68
56
 
69
57
  ## Critical rules
70
58
 
71
- 1. **Answers are wrapped objects**, not flat: \`"gender": { "value": "1", "label": "Male" }\`. Use \`answer.label\` when present; fall back to \`answer.value\` + option ID lookup via get_funnel_schema.
59
+ 1. **Answers are wrapped objects**, not flat: \`"primaryGoal": { "value": "2", "label": "Build a habit" }\`. Use \`answer.label\` when present; fall back to \`answer.value\` + option ID lookup via get_funnel_schema. For multiselect, \`label\` is comma-joined option labels in selection order.
72
60
  2. **Option IDs are not labels.** Singleselect value \`"1"\` is an opaque ID. Resolve via \`answer.label\` or get_funnel_schema.
73
- 3. **Raw body for signatures.** Verify X-Webhook-Signature against the raw request body BEFORE JSON parsing. Re-stringifying breaks the HMAC.
61
+ 3. **Composite components emit dotted Component IDs** (e.g. \`fullName.left\` / \`fullName.right\`). Read each as its own answer entry.
62
+ 4. **Raw body for signatures.** Verify X-Webhook-Signature against the raw request body BEFORE JSON parsing. Re-stringifying breaks the HMAC.
74
63
 
75
64
  ## Webhook delivery
76
65
 
77
- No retries. 10-second timeout. No dashboard delivery logs. A failed delivery is permanently lost. Preview mode (\`/preview/\` URLs) silently disables all webhooks.
66
+ At-least-once delivery — non-2xx responses and timeouts are retried with exponential backoff. 10-second default timeout. Every delivery (including retries) is recorded in the dashboard's Delivery Logs (Settings → Developers) with request/response bodies and a Resend button. Handlers must be idempotent on \`app_user_id\`. Preview mode (\`/preview/\` URLs) silently disables all webhooks.
67
+
68
+ ## Deep Link Button
69
+
70
+ Does NOT use \`{{template}}\` interpolation. The user sets a plain Destination URL and toggles "App User ID" (and optionally "Email") in Built-in Parameters; Zellify auto-appends them as query parameters on tap. The default key is \`app_user_id\` (rename in the same panel if the app expects something else).
78
71
 
79
72
  ## Workflow
80
73
 
81
- **Build handler:** list_funnels → get_funnel_schema → get_example_payload → write code → send_test_webhook
82
- **Debug:** get_integrations → send_test_webhook → diagnose response
74
+ **Build handler:** list_funnels → get_funnel_schema → get_example_payload → write code → Send test in the dashboard (Settings → Developers → Registration Webhook)
75
+ **Debug:** get_integrations → check Delivery Logs in dashboard (Settings → Developers) → diagnose response
83
76
  **Generate types:** get_funnel_schema → get_example_payload → extract TypeScript interface
84
77
 
85
78
  ## Cold-start
@@ -91,21 +84,47 @@ flow: discover → ask → decide → plan → implement → verify.
91
84
  ## Reference resources
92
85
  Read the MCP resources for detailed guides: webhook-handler, debugging,
93
86
  integration-paths, revenuecat, types-and-payload, language-guides. For full
94
- recipes, fetch the matching guide on https://docs2.zellify.app/developers/guides.`,
87
+ recipes, fetch the matching guide under https://docs.zellify.app/developers/how-access-works.`,
95
88
  });
96
89
  // ── Reference resources ──────────────────────────────────
97
90
  const referenceFiles = [
98
- { name: "webhook-handler", description: "Step-by-step guide to building a Registration Webhook handler" },
99
- { name: "debugging", description: "Diagnose webhook delivery failures — common errors, status codes, silent failures" },
100
- { name: "integration-paths", description: "Which integration path to use: RevenueCat, custom backend, web app, existing webhooks, etc." },
101
- { name: "revenuecat", description: "RevenueCat integration — the 5 silent failure points and diagnosis workflow" },
102
- { name: "types-and-payload", description: "Webhook payload structure, answer format, context fields, TypeScript/Zod type generation" },
103
- { name: "language-guides", description: "Raw body capture and answer access patterns for Express, Fastify, Flask, Django, Go, Rails, Vercel, Lambda" },
91
+ {
92
+ name: "webhook-handler",
93
+ description: "Step-by-step guide to building a Registration Webhook handler",
94
+ },
95
+ {
96
+ name: "debugging",
97
+ description: "Diagnose webhook delivery failures — common errors, status codes, silent failures",
98
+ },
99
+ {
100
+ name: "integration-paths",
101
+ description: "Which integration path to use: RevenueCat, custom backend, web app, existing webhooks, etc.",
102
+ },
103
+ {
104
+ name: "revenuecat",
105
+ description: "RevenueCat integration — the 5 silent failure points and diagnosis workflow",
106
+ },
107
+ {
108
+ name: "types-and-payload",
109
+ description: "Webhook payload structure, answer format, context fields, TypeScript/Zod type generation",
110
+ },
111
+ {
112
+ name: "language-guides",
113
+ description: "Raw body capture and answer access patterns for Express, Fastify, Flask, Django, Go, Rails, Vercel, Lambda",
114
+ },
104
115
  ];
105
116
  for (const ref of referenceFiles) {
106
- server.resource(ref.name, `zellify://references/${ref.name}`, { description: ref.description, mimeType: "text/markdown" }, async () => {
117
+ server.resource(ref.name, `zellify://references/${ref.name}`, { description: ref.description, mimeType: "text/markdown" }, () => {
107
118
  const content = readFileSync(join(referencesDir, `${ref.name}.md`), "utf-8");
108
- return { contents: [{ uri: `zellify://references/${ref.name}`, text: content, mimeType: "text/markdown" }] };
119
+ return {
120
+ contents: [
121
+ {
122
+ uri: `zellify://references/${ref.name}`,
123
+ text: content,
124
+ mimeType: "text/markdown",
125
+ },
126
+ ],
127
+ };
109
128
  });
110
129
  }
111
130
  // ── Tools ────────────────────────────────────────────────
@@ -114,7 +133,6 @@ registerListFunnels(server);
114
133
  registerGetFunnelSchema(server);
115
134
  registerGetExamplePayload(server);
116
135
  registerGetIntegrations(server);
117
- registerSendTestWebhook(server);
118
136
  // ── Prompts ──────────────────────────────────────────────
119
137
  registerIntegrationPlanPrompt(server);
120
138
  const transport = new StdioServerTransport();
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAIA,wBAAgB,GAAG,IAAI,IAAI,CA8B1B"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAIA,wBAAgB,GAAG,IAAI,IAAI,CAyC1B"}