@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.
- package/CHANGELOG.md +14 -0
- package/README.md +16 -15
- package/build/client.d.ts +77 -28
- package/build/client.d.ts.map +1 -1
- package/build/client.js +78 -34
- package/build/client.test.d.ts +2 -0
- package/build/client.test.d.ts.map +1 -0
- package/build/client.test.js +88 -0
- package/build/index.js +63 -45
- package/build/init.d.ts.map +1 -1
- package/build/init.js +3 -2
- package/build/prompts/integration-plan.d.ts +2 -0
- package/build/prompts/integration-plan.d.ts.map +1 -1
- package/build/prompts/integration-plan.js +46 -30
- package/build/tools/get-example-payload.d.ts.map +1 -1
- package/build/tools/get-example-payload.js +24 -7
- package/build/tools/get-funnel-schema.d.ts.map +1 -1
- package/build/tools/get-funnel-schema.js +35 -7
- package/build/tools/get-integrations.d.ts +2 -0
- package/build/tools/get-integrations.d.ts.map +1 -1
- package/build/tools/get-integrations.js +37 -22
- package/build/tools/get-integrations.test.d.ts +2 -0
- package/build/tools/get-integrations.test.d.ts.map +1 -0
- package/build/tools/get-integrations.test.js +29 -0
- package/build/tools/list-funnels.d.ts.map +1 -1
- package/build/tools/list-funnels.js +6 -7
- package/build/tools/validate-setup.d.ts +2 -0
- package/build/tools/validate-setup.d.ts.map +1 -1
- package/build/tools/validate-setup.js +85 -52
- package/build/tools/validate-setup.test.d.ts +2 -0
- package/build/tools/validate-setup.test.d.ts.map +1 -0
- package/build/tools/validate-setup.test.js +57 -0
- package/commands/integrationcheck.md +3 -1
- package/package.json +7 -4
- package/skill/SKILL.md +36 -35
- package/skill/references/debugging.md +28 -20
- package/skill/references/integration-paths.md +47 -25
- package/skill/references/language-guides.md +7 -3
- package/skill/references/revenuecat.md +15 -16
- package/skill/references/types-and-payload.md +336 -70
- package/skill/references/webhook-handler.md +31 -22
- package/build/tools/send-test-webhook.d.ts +0 -3
- package/build/tools/send-test-webhook.d.ts.map +0 -1
- package/build/tools/send-test-webhook.js +0 -78
package/build/init.js
CHANGED
|
@@ -19,8 +19,9 @@ export function run() {
|
|
|
19
19
|
console.log("");
|
|
20
20
|
console.log("Next:");
|
|
21
21
|
console.log(" 1. Register the MCP server (one-time, per project):");
|
|
22
|
-
console.log(" claude mcp add zellify -e ZELLIFY_API_KEY=
|
|
23
|
-
console.log("
|
|
22
|
+
console.log(" claude mcp add zellify -e ZELLIFY_API_KEY=YOUR_ACCESS_KEY -- npx -y @zellifyapp/mcp@latest");
|
|
23
|
+
console.log(" Create an access key at https://dash.zellify.app/settings?tab=developers");
|
|
24
|
+
console.log(" with the permissions Read funnels and Read integrations.");
|
|
24
25
|
console.log("");
|
|
25
26
|
console.log(" 2. Fully quit and reopen Claude Code (⌘Q on macOS — closing the");
|
|
26
27
|
console.log(" window is not enough; MCP server registrations are loaded once");
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { type IntegrationsResponse } from "../client.js";
|
|
3
|
+
export declare function formatIntegrationPlanStatus(integrationsData: IntegrationsResponse): string;
|
|
2
4
|
export declare function registerIntegrationPlanPrompt(server: McpServer): void;
|
|
3
5
|
//# sourceMappingURL=integration-plan.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration-plan.d.ts","sourceRoot":"","sources":["../../src/prompts/integration-plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"integration-plan.d.ts","sourceRoot":"","sources":["../../src/prompts/integration-plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,EAKL,KAAK,oBAAoB,EAG1B,MAAM,cAAc,CAAC;AAEtB,wBAAgB,2BAA2B,CACzC,gBAAgB,EAAE,oBAAoB,GACrC,MAAM,CAgBR;AAED,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,SAAS,QAyI9D"}
|
|
@@ -1,17 +1,37 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { funnelStatus, getExamplePayload, getFunnelSchema, getIntegrations, listFunnels, paymentIntegrationDisplayName, } from "../client.js";
|
|
3
|
+
export function formatIntegrationPlanStatus(integrationsData) {
|
|
4
|
+
const configuredIntegrations = integrationsData.integrations
|
|
5
|
+
.filter((integration) => integration.configured)
|
|
6
|
+
.map((integration) => integration.name);
|
|
7
|
+
const hasWebhook = configuredIntegrations.includes("registration_webhook");
|
|
8
|
+
const payments = integrationsData.paymentProviders.filter((payment) => payment.connected);
|
|
9
|
+
return `
|
|
10
|
+
## Current Integrations
|
|
11
|
+
|
|
12
|
+
- Payment providers: ${payments.length > 0 ? payments.map(paymentIntegrationDisplayName).join(", ") : "none"}
|
|
13
|
+
- Configured: ${configuredIntegrations.length > 0 ? configuredIntegrations.join(", ") : "none"}
|
|
14
|
+
- Registration webhook: ${hasWebhook ? "configured" : "**not configured** — set this up in Zellify dashboard > Settings → Developers → Registration Webhook"}
|
|
15
|
+
- Links: ${integrationsData.linkCount}
|
|
16
|
+
`;
|
|
17
|
+
}
|
|
3
18
|
export function registerIntegrationPlanPrompt(server) {
|
|
4
|
-
server.prompt("integration-plan", "Read the user's codebase and create a step-by-step integration plan for their Zellify funnels — webhook handler, signature verification, answer parsing, and any connected services.", {
|
|
19
|
+
server.prompt("integration-plan", "Read the user's codebase and create a step-by-step integration plan for their Zellify funnels — webhook handler, signature verification, answer parsing, and any connected services.", {
|
|
20
|
+
funnelId: z
|
|
21
|
+
.string()
|
|
22
|
+
.optional()
|
|
23
|
+
.describe("Funnel ID from list_funnels. If omitted, uses the newest published code funnel, or else the newest legacy funnel."),
|
|
24
|
+
}, async ({ funnelId }) => {
|
|
5
25
|
// Gather all Zellify context
|
|
6
|
-
const [
|
|
26
|
+
const [funnels, integrationsData] = await Promise.all([
|
|
7
27
|
listFunnels(),
|
|
8
28
|
getIntegrations(),
|
|
9
29
|
]);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const targetId = funnelId ??
|
|
30
|
+
// The API reports no published state for a legacy funnel; its schema
|
|
31
|
+
// request fails when it is unpublished, which leaves the section empty.
|
|
32
|
+
const target = funnels.find((f) => f.publishedAt) ??
|
|
33
|
+
funnels.find((f) => f.variant === "schema");
|
|
34
|
+
const targetId = funnelId ?? target?.id ?? null;
|
|
15
35
|
let schemaSection = "";
|
|
16
36
|
let payloadSection = "";
|
|
17
37
|
if (targetId) {
|
|
@@ -19,7 +39,7 @@ export function registerIntegrationPlanPrompt(server) {
|
|
|
19
39
|
getFunnelSchema(targetId).catch(() => null),
|
|
20
40
|
getExamplePayload(targetId).catch(() => null),
|
|
21
41
|
]);
|
|
22
|
-
if (schema) {
|
|
42
|
+
if (schema && "variables" in schema) {
|
|
23
43
|
schemaSection = `
|
|
24
44
|
## Funnel Schema (ID: ${targetId})
|
|
25
45
|
|
|
@@ -55,24 +75,16 @@ ${example.typescript}
|
|
|
55
75
|
const configuredIntegrations = integrationsData.integrations
|
|
56
76
|
.filter((i) => i.configured)
|
|
57
77
|
.map((i) => i.name);
|
|
58
|
-
const hasWebhook = configuredIntegrations.includes("registration_webhook");
|
|
59
78
|
const hasRevenueCat = configuredIntegrations.includes("revenuecat");
|
|
60
|
-
const
|
|
61
|
-
const integrationsSection =
|
|
62
|
-
## Current Integrations
|
|
63
|
-
|
|
64
|
-
- Payment provider: ${payment ?? "none"}
|
|
65
|
-
- Configured: ${configuredIntegrations.length > 0 ? configuredIntegrations.join(", ") : "none"}
|
|
66
|
-
- Registration webhook: ${hasWebhook ? "configured" : "**not configured** — set this up in Zellify dashboard > Settings > Integrations"}
|
|
67
|
-
- Campaigns: ${integrationsData.campaignCount}
|
|
68
|
-
`;
|
|
79
|
+
const payments = integrationsData.paymentProviders.filter((payment) => payment.connected);
|
|
80
|
+
const integrationsSection = formatIntegrationPlanStatus(integrationsData);
|
|
69
81
|
const prompt = `You are helping a developer integrate their application with Zellify. Read their codebase and create a concrete, step-by-step integration plan.
|
|
70
82
|
|
|
71
83
|
# Zellify Context
|
|
72
84
|
|
|
73
|
-
${funnels.length} funnel(s) found.
|
|
85
|
+
${funnels.length} funnel(s) found.
|
|
74
86
|
|
|
75
|
-
${funnels.map((f) => `- ID: ${f.id} | ${f.name} | ${f
|
|
87
|
+
${funnels.map((f) => `- ID: ${f.id} | ${f.name} | ${funnelStatus(f)}`).join("\n")}
|
|
76
88
|
${integrationsSection}
|
|
77
89
|
${schemaSection}
|
|
78
90
|
${payloadSection}
|
|
@@ -85,22 +97,26 @@ ${payloadSection}
|
|
|
85
97
|
|
|
86
98
|
**a. Webhook Handler** — where to add the route, which file, matching their existing patterns. Must:
|
|
87
99
|
- Capture the raw request body (before JSON parsing) for signature verification
|
|
88
|
-
- Verify \`X-Webhook-Signature\` using HMAC-SHA256 with their webhook secret
|
|
100
|
+
- Verify \`X-Webhook-Signature\` using HMAC-SHA256 with their webhook secret (lowercase hex)
|
|
89
101
|
- Parse the typed payload using the generated interface above
|
|
90
|
-
- Handle answers as wrapped objects: \`
|
|
102
|
+
- Handle answers as wrapped objects: \`{ value, label?, pageSlug?, questionText? }\`
|
|
91
103
|
|
|
92
104
|
**b. Answer Processing** — how to extract and use each variable from the funnel schema. Map question types to their value formats:
|
|
93
|
-
- text/email → string
|
|
94
|
-
- number → number
|
|
95
|
-
- singleselect
|
|
96
|
-
-
|
|
105
|
+
- text/email → \`{ value: string }\` (no label)
|
|
106
|
+
- number → \`{ value: number }\` (no label)
|
|
107
|
+
- singleselect → \`{ value: string, label: string }\` (value is opaque option ID, label is the chosen option's display text)
|
|
108
|
+
- slider → \`{ value: string, label: string }\` (label mirrors value when stops are unlabeled)
|
|
109
|
+
- multiselect → \`{ value: string[], label: string }\` (label is comma-joined option labels in selection order; \`split(", ")\` to recover the array)
|
|
97
110
|
- range → \`{ value: string }\` (hyphen-separated, e.g. "18-35")
|
|
111
|
+
- Composite components (double text input, multi-variant double input) emit one entry per sub-field with dotted Component IDs (e.g. \`fullName.left\` / \`fullName.right\`); read each as its own answer entry
|
|
112
|
+
- Consent / agreement components (marketing consent, terms acceptance) emit \`{ value: "1", label: "Granted" | "Accepted" }\` with no \`questionText\`
|
|
113
|
+
- Empty user input on a sub-field arrives as \`""\`, never omitted
|
|
98
114
|
|
|
99
|
-
**c. Connected Services** — ${hasRevenueCat ? "RevenueCat is configured — plan how to use `appUserId` from context to link funnel data to RevenueCat subscribers." : "No RevenueCat — plan standalone data handling."}${
|
|
115
|
+
**c. Connected Services** — ${hasRevenueCat ? "RevenueCat is configured — plan how to use `appUserId` from context to link funnel data to RevenueCat subscribers." : "No RevenueCat — plan standalone data handling."}${payments.length > 0 ? ` Payment providers are ${payments.map(paymentIntegrationDisplayName).join(", ")} — note any payment-related hooks if relevant.` : ""}
|
|
100
116
|
|
|
101
|
-
**d. Error Handling** —
|
|
117
|
+
**d. Error Handling** — at-least-once delivery, 10-second default timeout, retried with exponential backoff on non-2xx and timeouts. Handler MUST be idempotent on \`app_user_id\`. Plan for: signature mismatch (reject 401), processing errors (respond 200 to acknowledge once stored, handle async work after), and logging. The dashboard's Delivery Logs (Settings → Developers) records every attempt.
|
|
102
118
|
|
|
103
|
-
**e. Testing** —
|
|
119
|
+
**e. Testing** — click **Send test** in the Zellify dashboard (Settings → Developers → Registration Webhook). It sends a signed \`{ "event": "webhook.test" }\` body, not a registration, so it proves the endpoint is reachable and the signature check passes; the handler must answer it with 2xx and store nothing. Then complete the published funnel once (not a \`/preview/\` URL) and check the Delivery Logs.
|
|
104
120
|
|
|
105
121
|
3. **Output the plan as a numbered checklist** the developer can follow step by step. Include file paths, code snippets matching their stack, and which Zellify MCP tools to use at each step.
|
|
106
122
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-example-payload.d.ts","sourceRoot":"","sources":["../../src/tools/get-example-payload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"get-example-payload.d.ts","sourceRoot":"","sources":["../../src/tools/get-example-payload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAQzE,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,SAAS,QA6E1D"}
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { getExamplePayload } from "../client.js";
|
|
2
|
+
import { getExamplePayload, ZellifyApiError, } from "../client.js";
|
|
3
3
|
export function registerGetExamplePayload(server) {
|
|
4
|
-
server.tool("get_example_payload", "Generate a realistic example Registration Webhook payload for a funnel, with dummy values matching your specific question types. Includes a TypeScript interface. Use as the contract for building webhook handlers.", {
|
|
4
|
+
server.tool("get_example_payload", "Generate a realistic example Registration Webhook payload for a funnel, with dummy values matching your specific question types. Includes a TypeScript interface. Use as the contract for building webhook handlers.", {
|
|
5
|
+
funnelId: z.string().describe("The funnel ID from list_funnels"),
|
|
6
|
+
state: z
|
|
7
|
+
.enum(["published", "current"])
|
|
8
|
+
.optional()
|
|
9
|
+
.describe("Code funnels only: 'published' (default — the live contract) or 'current' (latest committed state, for previewing schema changes before publish)"),
|
|
10
|
+
}, async ({ funnelId, state }) => {
|
|
5
11
|
let data;
|
|
6
12
|
try {
|
|
7
|
-
data = await getExamplePayload(funnelId);
|
|
13
|
+
data = await getExamplePayload(funnelId, state);
|
|
8
14
|
}
|
|
9
15
|
catch (err) {
|
|
10
|
-
|
|
11
|
-
if (message.includes("404") || message.includes("not found")) {
|
|
16
|
+
if (err instanceof ZellifyApiError && err.status === 404) {
|
|
12
17
|
return {
|
|
13
18
|
content: [
|
|
14
19
|
{
|
|
@@ -18,6 +23,7 @@ export function registerGetExamplePayload(server) {
|
|
|
18
23
|
],
|
|
19
24
|
};
|
|
20
25
|
}
|
|
26
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
21
27
|
return {
|
|
22
28
|
content: [
|
|
23
29
|
{
|
|
@@ -27,7 +33,7 @@ export function registerGetExamplePayload(server) {
|
|
|
27
33
|
],
|
|
28
34
|
};
|
|
29
35
|
}
|
|
30
|
-
const
|
|
36
|
+
const lines = [
|
|
31
37
|
`Example Registration Webhook payload for funnel ${funnelId}:`,
|
|
32
38
|
"",
|
|
33
39
|
"## Payload",
|
|
@@ -42,7 +48,18 @@ export function registerGetExamplePayload(server) {
|
|
|
42
48
|
"```typescript",
|
|
43
49
|
data.typescript,
|
|
44
50
|
"```",
|
|
45
|
-
]
|
|
51
|
+
];
|
|
52
|
+
if ("state" in data) {
|
|
53
|
+
const commitPart = data.commitSha
|
|
54
|
+
? ` @ ${data.commitSha.slice(0, 7)}`
|
|
55
|
+
: "";
|
|
56
|
+
const publishedPart = data.publishedCommitSha
|
|
57
|
+
? ` (published: ${data.publishedCommitSha.slice(0, 7)})`
|
|
58
|
+
: " (not published yet)";
|
|
59
|
+
const stateLine = `State: ${data.state}${commitPart}${publishedPart}`;
|
|
60
|
+
lines.unshift(stateLine, "", "Note: keys in `answers` are omitted when a question was skipped or never shown — never null.", "");
|
|
61
|
+
}
|
|
62
|
+
const text = lines.join("\n");
|
|
46
63
|
return { content: [{ type: "text", text }] };
|
|
47
64
|
});
|
|
48
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-funnel-schema.d.ts","sourceRoot":"","sources":["../../src/tools/get-funnel-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"get-funnel-schema.d.ts","sourceRoot":"","sources":["../../src/tools/get-funnel-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAQzE,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,SAAS,QA0FxD"}
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { getFunnelSchema } from "../client.js";
|
|
2
|
+
import { getFunnelSchema, ZellifyApiError, } from "../client.js";
|
|
3
3
|
export function registerGetFunnelSchema(server) {
|
|
4
|
-
server.tool("get_funnel_schema", "Get the variable schema for a funnel — question names, types, options, and page slugs. Use this to understand what data the Registration Webhook delivers.", {
|
|
4
|
+
server.tool("get_funnel_schema", "Get the variable schema for a funnel — question names, types, options, and page slugs. Use this to understand what data the Registration Webhook delivers.", {
|
|
5
|
+
funnelId: z.string().describe("The funnel ID from list_funnels"),
|
|
6
|
+
state: z
|
|
7
|
+
.enum(["published", "current"])
|
|
8
|
+
.optional()
|
|
9
|
+
.describe("Code funnels only: 'published' (default — the live contract) or 'current' (latest committed state, for previewing schema changes before publish)"),
|
|
10
|
+
}, async ({ funnelId, state }) => {
|
|
5
11
|
let data;
|
|
6
12
|
try {
|
|
7
|
-
data = await getFunnelSchema(funnelId);
|
|
13
|
+
data = await getFunnelSchema(funnelId, state);
|
|
8
14
|
}
|
|
9
15
|
catch (err) {
|
|
10
|
-
|
|
11
|
-
if (message.includes("404") || message.includes("not found")) {
|
|
16
|
+
if (err instanceof ZellifyApiError && err.status === 404) {
|
|
12
17
|
return {
|
|
13
18
|
content: [
|
|
14
19
|
{
|
|
@@ -18,12 +23,33 @@ export function registerGetFunnelSchema(server) {
|
|
|
18
23
|
],
|
|
19
24
|
};
|
|
20
25
|
}
|
|
26
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
21
27
|
return {
|
|
22
28
|
content: [
|
|
23
29
|
{ type: "text", text: `Failed to get schema: ${message}` },
|
|
24
30
|
],
|
|
25
31
|
};
|
|
26
32
|
}
|
|
33
|
+
if ("fields" in data) {
|
|
34
|
+
const commitPart = data.commitSha
|
|
35
|
+
? ` @ ${data.commitSha.slice(0, 7)}`
|
|
36
|
+
: "";
|
|
37
|
+
const publishedPart = data.publishedCommitSha
|
|
38
|
+
? ` (published: ${data.publishedCommitSha.slice(0, 7)})`
|
|
39
|
+
: " (not published yet)";
|
|
40
|
+
const stateLine = `State: ${data.state}${commitPart}${publishedPart}`;
|
|
41
|
+
const text = [
|
|
42
|
+
`# Funnel ${funnelId} data schema (code funnel — flat contract)`,
|
|
43
|
+
stateLine,
|
|
44
|
+
"",
|
|
45
|
+
"Answers arrive FLAT: `answers[field]` is the raw value (option IDS for selects, not labels; `labels` maps ids to display text). Keys are omitted when a question was skipped or never shown — never null. `required` means the funnel does not advance past that question unanswered.",
|
|
46
|
+
"",
|
|
47
|
+
"```json",
|
|
48
|
+
JSON.stringify(data.fields, null, 2),
|
|
49
|
+
"```",
|
|
50
|
+
].join("\n");
|
|
51
|
+
return { content: [{ type: "text", text }] };
|
|
52
|
+
}
|
|
27
53
|
const vars = data.variables;
|
|
28
54
|
if (vars.length === 0) {
|
|
29
55
|
return {
|
|
@@ -37,10 +63,12 @@ export function registerGetFunnelSchema(server) {
|
|
|
37
63
|
}
|
|
38
64
|
const lines = vars.map((v) => {
|
|
39
65
|
let line = `- ${v.name} (${v.questionType})`;
|
|
40
|
-
if (v.questionText)
|
|
66
|
+
if (v.questionText) {
|
|
41
67
|
line += `: "${v.questionText}"`;
|
|
42
|
-
|
|
68
|
+
}
|
|
69
|
+
if (v.pageSlug) {
|
|
43
70
|
line += ` [page: ${v.pageSlug}]`;
|
|
71
|
+
}
|
|
44
72
|
if (v.options.length > 0) {
|
|
45
73
|
const opts = v.options.map((o) => `${o.id}="${o.label}"`).join(", ");
|
|
46
74
|
line += `\n Options: ${opts}`;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { type IntegrationsResponse } from "../client.js";
|
|
3
|
+
export declare function formatIntegrationsToolResponse(data: IntegrationsResponse): string;
|
|
2
4
|
export declare function registerGetIntegrations(server: McpServer): void;
|
|
3
5
|
//# sourceMappingURL=get-integrations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-integrations.d.ts","sourceRoot":"","sources":["../../src/tools/get-integrations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"get-integrations.d.ts","sourceRoot":"","sources":["../../src/tools/get-integrations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAEL,KAAK,oBAAoB,EAG1B,MAAM,cAAc,CAAC;AAkBtB,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,oBAAoB,GACzB,MAAM,CAyBR;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,SAAS,QAexD"}
|
|
@@ -1,29 +1,44 @@
|
|
|
1
|
-
import { getIntegrations } from "../client.js";
|
|
1
|
+
import { getIntegrations, paymentIntegrationDisplayName, } from "../client.js";
|
|
2
|
+
function appendPaymentProviderLines(lines, paymentProviders) {
|
|
3
|
+
if (paymentProviders.length === 0) {
|
|
4
|
+
lines.push("Payment providers: none configured");
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
lines.push("Payment providers:");
|
|
8
|
+
for (const payment of paymentProviders) {
|
|
9
|
+
lines.push(` - ${paymentIntegrationDisplayName(payment)}: ${payment.connected ? "connected" : "setup incomplete"}`);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export function formatIntegrationsToolResponse(data) {
|
|
13
|
+
const lines = [];
|
|
14
|
+
if (data.integrations.length > 0) {
|
|
15
|
+
lines.push("Configured integrations:");
|
|
16
|
+
for (const integration of data.integrations) {
|
|
17
|
+
lines.push(` - ${integration.name}`);
|
|
18
|
+
if (integration.name === "registration_webhook") {
|
|
19
|
+
lines.push(` URL: ${integration.url ?? "(not set)"}`);
|
|
20
|
+
lines.push(` Secret: ${integration.secretConfigured ? "configured" : "missing"}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
lines.push("No integrations configured.");
|
|
26
|
+
}
|
|
27
|
+
lines.push("");
|
|
28
|
+
appendPaymentProviderLines(lines, data.paymentProviders);
|
|
29
|
+
lines.push(`Active links: ${data.linkCount}`);
|
|
30
|
+
lines.push("");
|
|
31
|
+
lines.push("---");
|
|
32
|
+
lines.push(`Raw JSON:\n${JSON.stringify(data, null, 2)}`);
|
|
33
|
+
return lines.join("\n");
|
|
34
|
+
}
|
|
2
35
|
export function registerGetIntegrations(server) {
|
|
3
36
|
server.tool("get_integrations", "Check which integrations are configured — payment provider, RevenueCat, webhook, analytics. Use to understand what's set up before building integration code.", {}, async () => {
|
|
4
37
|
const data = await getIntegrations();
|
|
5
|
-
const lines = [];
|
|
6
|
-
if (data.integrations.length > 0) {
|
|
7
|
-
lines.push("Configured integrations:");
|
|
8
|
-
for (const i of data.integrations) {
|
|
9
|
-
lines.push(` - ${i.name}`);
|
|
10
|
-
if (i.name === "registration_webhook") {
|
|
11
|
-
lines.push(` URL: ${i.url ?? "(not set)"}`);
|
|
12
|
-
lines.push(` Secret: ${i.secretConfigured ? "configured" : "missing"}`);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
lines.push("No integrations configured.");
|
|
18
|
-
}
|
|
19
|
-
lines.push("");
|
|
20
|
-
lines.push(`Payment provider: ${data.paymentProvider ?? "none configured"}`);
|
|
21
|
-
lines.push(`Active campaigns: ${data.campaignCount}`);
|
|
22
|
-
lines.push("");
|
|
23
|
-
lines.push("---");
|
|
24
|
-
lines.push(`Raw JSON:\n${JSON.stringify(data, null, 2)}`);
|
|
25
38
|
return {
|
|
26
|
-
content: [
|
|
39
|
+
content: [
|
|
40
|
+
{ type: "text", text: formatIntegrationsToolResponse(data) },
|
|
41
|
+
],
|
|
27
42
|
};
|
|
28
43
|
});
|
|
29
44
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-integrations.test.d.ts","sourceRoot":"","sources":["../../src/tools/get-integrations.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { formatIntegrationPlanStatus } from "../prompts/integration-plan.js";
|
|
3
|
+
import { formatIntegrationsToolResponse } from "./get-integrations.js";
|
|
4
|
+
const response = {
|
|
5
|
+
integrations: [
|
|
6
|
+
{
|
|
7
|
+
configured: true,
|
|
8
|
+
name: "registration_webhook",
|
|
9
|
+
secretConfigured: true,
|
|
10
|
+
url: "https://example.com/zellify",
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
|
+
linkCount: 3,
|
|
14
|
+
paymentProvider: "paddle",
|
|
15
|
+
paymentProviders: [
|
|
16
|
+
{ connected: true, environment: "sandbox", name: "paddle" },
|
|
17
|
+
],
|
|
18
|
+
};
|
|
19
|
+
describe("integrations summary", () => {
|
|
20
|
+
it("shows each payment provider with its environment and the link count", () => {
|
|
21
|
+
const tool = formatIntegrationsToolResponse(response);
|
|
22
|
+
const prompt = formatIntegrationPlanStatus(response);
|
|
23
|
+
expect(tool).toContain("URL: https://example.com/zellify");
|
|
24
|
+
expect(tool).toContain("paddle (sandbox): connected");
|
|
25
|
+
expect(tool).toContain("Active links: 3");
|
|
26
|
+
expect(prompt).toContain("Payment providers: paddle (sandbox)");
|
|
27
|
+
expect(prompt).toContain("Links: 3");
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-funnels.d.ts","sourceRoot":"","sources":["../../src/tools/list-funnels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"list-funnels.d.ts","sourceRoot":"","sources":["../../src/tools/list-funnels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,QA6BpD"}
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import { listFunnels } from "../client.js";
|
|
1
|
+
import { funnelStatus, listFunnels } from "../client.js";
|
|
2
2
|
export function registerListFunnels(server) {
|
|
3
|
-
server.tool("list_funnels", "List all funnels for your Zellify
|
|
4
|
-
const
|
|
5
|
-
const funnels = data.funnels;
|
|
3
|
+
server.tool("list_funnels", "List all funnels for your Zellify workspace. Returns each funnel's ID, name, and status: a code funnel (built with the agent) shows when it was published; a legacy funnel has no reported status. Use this first to find the funnel ID needed by other tools.", {}, async () => {
|
|
4
|
+
const funnels = await listFunnels();
|
|
6
5
|
if (funnels.length === 0) {
|
|
7
6
|
return {
|
|
8
7
|
content: [
|
|
9
8
|
{
|
|
10
9
|
type: "text",
|
|
11
|
-
text: "No funnels found in your
|
|
10
|
+
text: "No funnels found in your workspace.",
|
|
12
11
|
},
|
|
13
12
|
],
|
|
14
13
|
};
|
|
15
14
|
}
|
|
16
|
-
const lines = funnels.map((f) => `- ID: ${f.id} | ${f.name} | ${f
|
|
17
|
-
const text = `Found ${funnels.length} funnel(s):\n\n${lines.join("\n")}\n\n---\nRaw JSON:\n${JSON.stringify(
|
|
15
|
+
const lines = funnels.map((f) => `- ID: ${f.id} | ${f.name} | ${funnelStatus(f)} | Updated: ${f.updatedAt}`);
|
|
16
|
+
const text = `Found ${funnels.length} funnel(s):\n\n${lines.join("\n")}\n\n---\nRaw JSON:\n${JSON.stringify(funnels, null, 2)}`;
|
|
18
17
|
return { content: [{ type: "text", text }] };
|
|
19
18
|
});
|
|
20
19
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
/** The checklist `validate_setup` returns. */
|
|
3
|
+
export declare function validateSetup(): Promise<string>;
|
|
2
4
|
export declare function registerValidateSetup(server: McpServer): void;
|
|
3
5
|
//# sourceMappingURL=validate-setup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-setup.d.ts","sourceRoot":"","sources":["../../src/tools/validate-setup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"validate-setup.d.ts","sourceRoot":"","sources":["../../src/tools/validate-setup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAgEzE,8CAA8C;AAC9C,wBAAsB,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,CAwDrD;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,QAStD"}
|
|
@@ -1,58 +1,91 @@
|
|
|
1
|
-
import { listFunnels } from "../client.js";
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import { API_URL, getKey, isRetiredApiKey, listFunnels, REQUIRED_PERMISSIONS, RETIRED_KEY_MESSAGE, ZellifyApiError, } from "../client.js";
|
|
2
|
+
const API_KEY = process.env.ZELLIFY_API_KEY ?? "";
|
|
3
|
+
const REINSTALL = [
|
|
4
|
+
"Re-add the MCP with the key in its environment:",
|
|
5
|
+
" claude mcp remove zellify",
|
|
6
|
+
" claude mcp add zellify -e ZELLIFY_API_KEY=YOUR_ACCESS_KEY -- npx -y @zellifyapp/mcp@latest",
|
|
7
|
+
"Then fully quit Claude Code (⌘Q) and reopen — MCP config does not hot-reload.",
|
|
8
|
+
];
|
|
9
|
+
function failureHint(err) {
|
|
10
|
+
if (!(err instanceof ZellifyApiError)) {
|
|
11
|
+
return `The MCP can't reach ${API_URL}. Check your network / VPN / proxy.`;
|
|
12
|
+
}
|
|
13
|
+
if (err.status === 401) {
|
|
14
|
+
return "The access key was rejected: it is mistyped, revoked, or expired. Create a new one in Settings > Developers (https://dash.zellify.app/settings?tab=developers), re-add the MCP with -e ZELLIFY_API_KEY=NEW_KEY, and fully quit Claude Code.";
|
|
15
|
+
}
|
|
16
|
+
return "Unexpected error — likely a backend issue. Check status.zellify.app and try again.";
|
|
17
|
+
}
|
|
18
|
+
function missingPermissions(key) {
|
|
19
|
+
return Object.entries(REQUIRED_PERMISSIONS)
|
|
20
|
+
.filter(([scope]) => !key.scopes.includes(scope))
|
|
21
|
+
.map(([scope, label]) => `✗ FAIL — the key lacks the permission ${label} (${scope}). Edit the key in Settings > Developers and turn on ${label}.`);
|
|
22
|
+
}
|
|
23
|
+
// Returns the funnel lines and whether any funnel can send webhooks.
|
|
24
|
+
async function checkFunnels() {
|
|
25
|
+
const funnels = await listFunnels();
|
|
26
|
+
const agentBuilt = funnels.filter((funnel) => funnel.variant === "code");
|
|
27
|
+
const published = agentBuilt.filter((funnel) => funnel.publishedAt).length;
|
|
28
|
+
const legacy = funnels.length - agentBuilt.length;
|
|
29
|
+
const lines = [
|
|
30
|
+
`Funnels in this workspace: ${funnels.length} total — ${agentBuilt.length} built with the agent (${published} published), ${legacy} legacy`,
|
|
31
|
+
];
|
|
32
|
+
if (funnels.length === 0) {
|
|
33
|
+
lines.push("⚠ No funnels exist in this workspace. Create one in the dashboard before integrating.");
|
|
34
|
+
return { lines, ready: false };
|
|
35
|
+
}
|
|
36
|
+
if (published === 0 && legacy === 0) {
|
|
37
|
+
lines.push("⚠ No published funnels. Webhooks only fire from published funnels (preview mode disables them). Publish at least one before integrating.");
|
|
38
|
+
return { lines, ready: false };
|
|
39
|
+
}
|
|
40
|
+
return { lines, ready: true };
|
|
41
|
+
}
|
|
42
|
+
/** The checklist `validate_setup` returns. */
|
|
43
|
+
export async function validateSetup() {
|
|
44
|
+
const lines = [
|
|
45
|
+
`API URL: ${API_URL}`,
|
|
46
|
+
`ZELLIFY_API_KEY env var: ${API_KEY ? "PRESENT" : "MISSING"}`,
|
|
47
|
+
"",
|
|
48
|
+
];
|
|
49
|
+
if (!API_KEY) {
|
|
50
|
+
lines.push("✗ FAIL — ZELLIFY_API_KEY is not in the MCP server's environment.", "", ...REINSTALL);
|
|
51
|
+
return lines.join("\n");
|
|
52
|
+
}
|
|
53
|
+
if (isRetiredApiKey(API_KEY)) {
|
|
54
|
+
lines.push(`✗ FAIL — ${RETIRED_KEY_MESSAGE}`, "", ...REINSTALL);
|
|
55
|
+
return lines.join("\n");
|
|
56
|
+
}
|
|
57
|
+
let key;
|
|
58
|
+
try {
|
|
59
|
+
key = await getKey();
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
63
|
+
lines.push(`✗ FAIL — ${message}`, "", failureHint(err));
|
|
64
|
+
return lines.join("\n");
|
|
65
|
+
}
|
|
66
|
+
lines.push(`✓ Access key "${key.name}" is valid`, `✓ Backend reachable at ${API_URL}`);
|
|
67
|
+
const missing = missingPermissions(key);
|
|
68
|
+
lines.push(...missing);
|
|
69
|
+
let ready = missing.length === 0;
|
|
70
|
+
if (key.scopes.includes("funnels:read")) {
|
|
19
71
|
try {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
lines.push("✓ API key valid (auth check passed)");
|
|
24
|
-
lines.push(`✓ Backend reachable at ${API_URL}`);
|
|
25
|
-
lines.push(`Funnels in this org: ${total} total, ${published} published`);
|
|
26
|
-
if (total === 0) {
|
|
27
|
-
lines.push("");
|
|
28
|
-
lines.push("⚠ No funnels exist in this organization. Create one in the dashboard before integrating.");
|
|
29
|
-
}
|
|
30
|
-
else if (published === 0) {
|
|
31
|
-
lines.push("");
|
|
32
|
-
lines.push("⚠ No published funnels. Webhooks only fire from published funnels (preview mode disables them). Publish at least one before integrating.");
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
lines.push("");
|
|
36
|
-
lines.push("✓ Setup looks good. Proceed with /integrationcheck or call list_funnels.");
|
|
37
|
-
}
|
|
72
|
+
const funnels = await checkFunnels();
|
|
73
|
+
lines.push(...funnels.lines);
|
|
74
|
+
ready &&= funnels.ready;
|
|
38
75
|
}
|
|
39
76
|
catch (err) {
|
|
40
77
|
const message = err instanceof Error ? err.message : String(err);
|
|
41
|
-
lines.push("");
|
|
42
|
-
lines.
|
|
43
|
-
lines.push("");
|
|
44
|
-
if (message.includes("401") || message.toLowerCase().includes("invalid api key")) {
|
|
45
|
-
lines.push("The API key was rejected. Generate a fresh one at:");
|
|
46
|
-
lines.push(" https://dash.zellify.app/dashboard/settings/developer");
|
|
47
|
-
lines.push("Then re-add the MCP with -e ZELLIFY_API_KEY=NEW_KEY and fully quit Claude Code.");
|
|
48
|
-
}
|
|
49
|
-
else if (message.includes("ENOTFOUND") || message.includes("ECONNREFUSED")) {
|
|
50
|
-
lines.push(`The MCP can't reach ${API_URL}. Check your network / VPN / proxy.`);
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
lines.push("Unexpected error — likely a backend issue. Check status.zellify.app and try again.");
|
|
54
|
-
}
|
|
78
|
+
lines.push(`✗ FAIL — ${message}`, "", failureHint(err));
|
|
79
|
+
return lines.join("\n");
|
|
55
80
|
}
|
|
56
|
-
|
|
57
|
-
|
|
81
|
+
}
|
|
82
|
+
if (ready) {
|
|
83
|
+
lines.push("", "✓ Setup looks good. Proceed with /integrationcheck or call list_funnels.");
|
|
84
|
+
}
|
|
85
|
+
return lines.join("\n");
|
|
86
|
+
}
|
|
87
|
+
export function registerValidateSetup(server) {
|
|
88
|
+
server.tool("validate_setup", "Verify that the Zellify MCP is correctly configured: env var present, access key valid with the permissions Read funnels and Read integrations, backend reachable, and at least one published funnel exists. Run this first if anything else fails — it pinpoints whether the problem is auth, a missing permission, network, or an empty workspace. Returns a checklist with PASS/FAIL for each check.", {}, async () => ({
|
|
89
|
+
content: [{ type: "text", text: await validateSetup() }],
|
|
90
|
+
}));
|
|
58
91
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-setup.test.d.ts","sourceRoot":"","sources":["../../src/tools/validate-setup.test.ts"],"names":[],"mappings":""}
|