@sealmetrics/mcp 0.1.0 → 1.3.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/README.md +173 -0
- package/dist/client.d.ts +68 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +225 -0
- package/dist/client.js.map +1 -0
- package/dist/embedded.d.ts +29 -0
- package/dist/embedded.d.ts.map +1 -0
- package/dist/embedded.js +37 -0
- package/dist/embedded.js.map +1 -0
- package/dist/errors.d.ts +10 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +55 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +1 -6
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3809 -780
- package/dist/index.js.map +1 -0
- package/dist/resources/tracking-guide.d.ts +13 -0
- package/dist/resources/tracking-guide.d.ts.map +1 -0
- package/dist/resources/tracking-guide.js +479 -0
- package/dist/resources/tracking-guide.js.map +1 -0
- package/dist/sealmetrics.mcpb +0 -0
- package/dist/server.d.ts +38 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +132 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/alerts.d.ts +5 -0
- package/dist/tools/alerts.d.ts.map +1 -0
- package/dist/tools/alerts.js +80 -0
- package/dist/tools/alerts.js.map +1 -0
- package/dist/tools/audience.d.ts +7 -0
- package/dist/tools/audience.d.ts.map +1 -0
- package/dist/tools/audience.js +146 -0
- package/dist/tools/audience.js.map +1 -0
- package/dist/tools/bots.d.ts +4 -0
- package/dist/tools/bots.d.ts.map +1 -0
- package/dist/tools/bots.js +52 -0
- package/dist/tools/bots.js.map +1 -0
- package/dist/tools/channels.d.ts +5 -0
- package/dist/tools/channels.d.ts.map +1 -0
- package/dist/tools/channels.js +88 -0
- package/dist/tools/channels.js.map +1 -0
- package/dist/tools/content.d.ts +3 -0
- package/dist/tools/content.d.ts.map +1 -0
- package/dist/tools/content.js +47 -0
- package/dist/tools/content.js.map +1 -0
- package/dist/tools/conversions.d.ts +9 -0
- package/dist/tools/conversions.d.ts.map +1 -0
- package/dist/tools/conversions.js +427 -0
- package/dist/tools/conversions.js.map +1 -0
- package/dist/tools/funnel.d.ts +3 -0
- package/dist/tools/funnel.d.ts.map +1 -0
- package/dist/tools/funnel.js +27 -0
- package/dist/tools/funnel.js.map +1 -0
- package/dist/tools/index.d.ts +16 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +83 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/overview.d.ts +3 -0
- package/dist/tools/overview.d.ts.map +1 -0
- package/dist/tools/overview.js +26 -0
- package/dist/tools/overview.js.map +1 -0
- package/dist/tools/pages.d.ts +7 -0
- package/dist/tools/pages.d.ts.map +1 -0
- package/dist/tools/pages.js +307 -0
- package/dist/tools/pages.js.map +1 -0
- package/dist/tools/properties.d.ts +5 -0
- package/dist/tools/properties.d.ts.map +1 -0
- package/dist/tools/properties.js +107 -0
- package/dist/tools/properties.js.map +1 -0
- package/dist/tools/segments.d.ts +4 -0
- package/dist/tools/segments.d.ts.map +1 -0
- package/dist/tools/segments.js +49 -0
- package/dist/tools/segments.js.map +1 -0
- package/dist/tools/setup.d.ts +49 -0
- package/dist/tools/setup.d.ts.map +1 -0
- package/dist/tools/setup.js +347 -0
- package/dist/tools/setup.js.map +1 -0
- package/dist/tools/shared.d.ts +33 -0
- package/dist/tools/shared.d.ts.map +1 -0
- package/dist/tools/shared.js +40 -0
- package/dist/tools/shared.js.map +1 -0
- package/dist/tools/sites.d.ts +4 -0
- package/dist/tools/sites.d.ts.map +1 -0
- package/dist/tools/sites.js +36 -0
- package/dist/tools/sites.js.map +1 -0
- package/dist/tools/tracking.d.ts +3 -0
- package/dist/tools/tracking.d.ts.map +1 -0
- package/dist/tools/tracking.js +220 -0
- package/dist/tools/tracking.js.map +1 -0
- package/dist/tools/traffic.d.ts +10 -0
- package/dist/tools/traffic.d.ts.map +1 -0
- package/dist/tools/traffic.js +273 -0
- package/dist/tools/traffic.js.map +1 -0
- package/dist/tools/webhooks.d.ts +5 -0
- package/dist/tools/webhooks.d.ts.map +1 -0
- package/dist/tools/webhooks.js +101 -0
- package/dist/tools/webhooks.js.map +1 -0
- package/dist/types.d.ts +118 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +22 -0
- package/dist/types.js.map +1 -0
- package/package.json +44 -27
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP write-path setup tools (Fase 3 Bloque 2, RF-3203). These let a user register
|
|
3
|
+
* + verify a SealMetrics site **from the chat** (Claude Desktop, no terminal),
|
|
4
|
+
* reusing `@sealmetrics/setup-core` (Bloque 1) so the logic is never duplicated
|
|
5
|
+
* CLI↔MCP. The MCP never edits the user's source (RF-3204) — provision_site hands
|
|
6
|
+
* back the snippet + guide; the agent (with repo) or the human (paste) places it.
|
|
7
|
+
*
|
|
8
|
+
* Privacy/secret handling (VAL-3201/3203, RF-3207):
|
|
9
|
+
* - provision_site NEVER returns the api_key to the model (it is adopted into
|
|
10
|
+
* memory to enable the read-only tools and saved by the user via env/email).
|
|
11
|
+
* - provision_site NEVER returns the claim_url magic-link token (it goes by
|
|
12
|
+
* email); it returns `claim_email_sent_to` + `dashboard_url` only.
|
|
13
|
+
*/
|
|
14
|
+
import { detectFramework, buildProvisionBody, unwrapProvisionData, provisionErrorForStatus, fetchPixelStatus, pollPixelStatus, getInstrumentationGuide, getStackGuide, getPlatformPluginGuide, checkInstrumentation, detectPII, } from "@sealmetrics/setup-core";
|
|
15
|
+
import { SealMetricsAPIError } from "../errors.js";
|
|
16
|
+
/** Terms of Service URL — shown so the human can read them before accepting (parity with the CLI). */
|
|
17
|
+
const TOS_URL = "https://sealmetrics.com/terms";
|
|
18
|
+
function str(v) {
|
|
19
|
+
if (v === undefined || v === null)
|
|
20
|
+
return undefined;
|
|
21
|
+
const s = String(v).trim();
|
|
22
|
+
return s.length > 0 ? s : undefined;
|
|
23
|
+
}
|
|
24
|
+
/** Build the five (RF-3203) setup tools bound to a context. */
|
|
25
|
+
export function createSetupTools(ctx) {
|
|
26
|
+
const provisionSite = {
|
|
27
|
+
name: "provision_site",
|
|
28
|
+
description: "Register a NEW free SealMetrics site from the chat (no terminal needed). Creates the account, returns the tracker snippet to place in your site's <head>, and emails you a claim link to set a password. After this succeeds, the read-only analytics tools are enabled in this session. Does NOT edit your code — you (or the agent, if it has the repo) place the snippet.",
|
|
29
|
+
inputSchema: {
|
|
30
|
+
type: "object",
|
|
31
|
+
properties: {
|
|
32
|
+
site_name: { type: "string", description: "Human-friendly name for the site (e.g. 'My Shop')." },
|
|
33
|
+
domain: { type: "string", description: "Primary domain of the site (e.g. 'myshop.com'). Optional." },
|
|
34
|
+
email: { type: "string", description: "Your email — receives the claim link to set a password." },
|
|
35
|
+
name: { type: "string", description: "Your name. Optional." },
|
|
36
|
+
accept_terms: {
|
|
37
|
+
type: "boolean",
|
|
38
|
+
description: "Must be true: confirms the user has read and accepts the SealMetrics Terms of Service (https://sealmetrics.com/terms). Show the user this link first; do NOT accept on their behalf.",
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
required: ["site_name", "email", "accept_terms"],
|
|
42
|
+
},
|
|
43
|
+
annotations: { title: "Provision a SealMetrics site", readOnlyHint: false, openWorldHint: true },
|
|
44
|
+
handler: async (args) => {
|
|
45
|
+
if (args.accept_terms !== true && args.accept_terms !== "true") {
|
|
46
|
+
throw new Error(`accept_terms must be true. Show the user the SealMetrics Terms of Service (${TOS_URL}) and ask them to confirm — do not accept on their behalf.`);
|
|
47
|
+
}
|
|
48
|
+
const siteName = str(args.site_name);
|
|
49
|
+
const email = str(args.email);
|
|
50
|
+
if (!siteName)
|
|
51
|
+
throw new Error("site_name is required.");
|
|
52
|
+
if (!email)
|
|
53
|
+
throw new Error("email is required.");
|
|
54
|
+
const input = {
|
|
55
|
+
siteName,
|
|
56
|
+
domain: str(args.domain),
|
|
57
|
+
email,
|
|
58
|
+
name: str(args.name),
|
|
59
|
+
installSource: ctx.installSource, // "mcp" — attribution (RF-3205/RF-3604)
|
|
60
|
+
};
|
|
61
|
+
let envelope;
|
|
62
|
+
try {
|
|
63
|
+
envelope = await ctx.client.post("/provision", buildProvisionBody(input), {
|
|
64
|
+
provisionKey: ctx.provisionKey,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
catch (e) {
|
|
68
|
+
if (e instanceof SealMetricsAPIError) {
|
|
69
|
+
// Map HTTP status → the shared ProvisionError code/message (TEST-3203/3601).
|
|
70
|
+
const pe = provisionErrorForStatus(e.statusCode);
|
|
71
|
+
throw new Error(`${pe.code}: ${pe.message}`);
|
|
72
|
+
}
|
|
73
|
+
throw e;
|
|
74
|
+
}
|
|
75
|
+
const result = unwrapProvisionData(envelope);
|
|
76
|
+
// Adopt the api_key + enable read-only tools (RF-3202b). NEVER returned to the model.
|
|
77
|
+
ctx.onProvisioned(result.api_key, result.account_id);
|
|
78
|
+
ctx.state.provisioned = true;
|
|
79
|
+
ctx.state.accountId = result.account_id;
|
|
80
|
+
// Return ONLY non-secret fields: no api_key (VAL-3201), no claim_url token (RF-3207/VAL-3203).
|
|
81
|
+
return {
|
|
82
|
+
account_id: result.account_id,
|
|
83
|
+
snippet: result.snippet,
|
|
84
|
+
dashboard_url: result.dashboard_url,
|
|
85
|
+
claim_email_sent_to: email,
|
|
86
|
+
free_quota: result.free_quota,
|
|
87
|
+
next_steps: [
|
|
88
|
+
"Place the snippet in your site's <head> on every page. If the agent has your repo it can do this; otherwise paste it yourself.",
|
|
89
|
+
"Run verify_setup once the snippet is live to confirm the pixel is sending data.",
|
|
90
|
+
"Read-only analytics tools are now enabled in THIS session.",
|
|
91
|
+
"To keep them after restarting Claude Desktop, paste the api_key from your welcome email into the SEALMETRICS_API_KEY field of the extension settings.",
|
|
92
|
+
"Check your email to claim the account (set a password) — this unlocks the web dashboard. Analytics work without it.",
|
|
93
|
+
],
|
|
94
|
+
};
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
const verifySetup = {
|
|
98
|
+
name: "verify_setup",
|
|
99
|
+
description: "Poll until the SealMetrics pixel is confirmed installed (a real pageview has reached the backend) or it times out. Run this after placing the snippet. Reads only — sends no data.",
|
|
100
|
+
inputSchema: {
|
|
101
|
+
type: "object",
|
|
102
|
+
properties: {
|
|
103
|
+
account_id: {
|
|
104
|
+
type: "string",
|
|
105
|
+
description: "Site/account id to verify. Defaults to the site provisioned in this session.",
|
|
106
|
+
},
|
|
107
|
+
timeout_seconds: {
|
|
108
|
+
type: "number",
|
|
109
|
+
description: "Max seconds to wait for the first hit (default 25).",
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
annotations: { title: "Verify pixel install", readOnlyHint: true, openWorldHint: true },
|
|
114
|
+
handler: async (args) => {
|
|
115
|
+
const accountId = str(args.account_id) ?? ctx.state.accountId;
|
|
116
|
+
if (!accountId)
|
|
117
|
+
throw new Error("account_id is required (provision a site first).");
|
|
118
|
+
const apiKey = ctx.client.getApiKey();
|
|
119
|
+
if (!apiKey) {
|
|
120
|
+
throw new Error("AUTH_REQUIRED: no api_key available to verify. Provision a site first, or set SEALMETRICS_API_KEY.");
|
|
121
|
+
}
|
|
122
|
+
const timeoutMs = ctx.pollDefaults?.timeoutMs ??
|
|
123
|
+
(typeof args.timeout_seconds === "number" ? Math.max(0, args.timeout_seconds) * 1000 : 25_000);
|
|
124
|
+
const intervalMs = ctx.pollDefaults?.intervalMs ?? 2_000;
|
|
125
|
+
const res = await pollPixelStatus({
|
|
126
|
+
fetchStatus: () => fetchPixelStatus(accountId, { baseUrl: ctx.baseUrl, apiKey }),
|
|
127
|
+
timeoutMs,
|
|
128
|
+
intervalMs,
|
|
129
|
+
});
|
|
130
|
+
if (res.verified === true)
|
|
131
|
+
ctx.state.pixelVerified = true;
|
|
132
|
+
return {
|
|
133
|
+
account_id: accountId,
|
|
134
|
+
installed: res.verified === true,
|
|
135
|
+
status: res.verified === true ? "verified" : "pending",
|
|
136
|
+
total_hits: res.totalHits ?? 0,
|
|
137
|
+
next_steps: res.verified === true
|
|
138
|
+
? ["Pixel confirmed. You can now query analytics with the read-only tools."]
|
|
139
|
+
: [
|
|
140
|
+
"No hits yet. Make sure the snippet is in the <head> of a live page, then load that page and re-run verify_setup.",
|
|
141
|
+
],
|
|
142
|
+
};
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
const getSetupStatus = {
|
|
146
|
+
name: "get_setup_status",
|
|
147
|
+
description: "Report where the setup flow is: whether a site has been provisioned in this session and whether its pixel has been verified.",
|
|
148
|
+
inputSchema: { type: "object", properties: {} },
|
|
149
|
+
annotations: { title: "Setup status", readOnlyHint: true },
|
|
150
|
+
handler: async () => ({
|
|
151
|
+
provisioned: ctx.state.provisioned,
|
|
152
|
+
account_id: ctx.state.accountId,
|
|
153
|
+
pixel_verified: ctx.state.pixelVerified,
|
|
154
|
+
}),
|
|
155
|
+
};
|
|
156
|
+
const detectFrameworkTool = {
|
|
157
|
+
name: "detect_framework",
|
|
158
|
+
description: "Best-effort detect the web framework/CMS of a project so the snippet can be placed correctly. Pass `path` if you have the repo; in a pure chat (no repo) returns 'unknown' plus the manual guide. Read-only — never edits files.",
|
|
159
|
+
inputSchema: {
|
|
160
|
+
type: "object",
|
|
161
|
+
properties: {
|
|
162
|
+
path: {
|
|
163
|
+
type: "string",
|
|
164
|
+
description: "Absolute path to the project root. Optional; omit if you don't have the repo.",
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
annotations: { title: "Detect framework", readOnlyHint: true },
|
|
169
|
+
handler: async (args) => {
|
|
170
|
+
const path = str(args.path) ?? ctx.cwd;
|
|
171
|
+
if (!path) {
|
|
172
|
+
const guide = getStackGuide("unknown");
|
|
173
|
+
return {
|
|
174
|
+
framework: "unknown",
|
|
175
|
+
strategy: "manual",
|
|
176
|
+
location: guide.location,
|
|
177
|
+
placement: guide.placement,
|
|
178
|
+
provision_only: true,
|
|
179
|
+
note: "No project path available (e.g. Claude Desktop chat). Provide `path` if you have the repo, or place the snippet manually using loading_notes.",
|
|
180
|
+
loading_notes: guide.notes,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
const d = detectFramework(path);
|
|
184
|
+
const guide = getStackGuide(d.framework);
|
|
185
|
+
return {
|
|
186
|
+
framework: d.framework,
|
|
187
|
+
platform: d.platform,
|
|
188
|
+
strategy: d.strategy,
|
|
189
|
+
location: d.recommendedLocation,
|
|
190
|
+
placement: d.placementHint,
|
|
191
|
+
provision_only: d.provisionOnly,
|
|
192
|
+
loading_notes: guide.notes,
|
|
193
|
+
...(d.platform
|
|
194
|
+
? { plugin_guidance: getPlatformPluginGuide(d.platform, ctx.state.accountId ?? "[YOUR_ACCOUNT_ID]") }
|
|
195
|
+
: {}),
|
|
196
|
+
};
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
const getInstrumentationGuideTool = {
|
|
200
|
+
name: "get_instrumentation_guide",
|
|
201
|
+
description: "Return the canonical SealMetrics event-instrumentation guide (closed conv/micro taxonomy + privacy rules) with your account_id substituted. Use it before writing sealmetrics.conv()/micro() calls. The MCP does NOT write these calls — the agent does, guided by this.",
|
|
202
|
+
inputSchema: {
|
|
203
|
+
type: "object",
|
|
204
|
+
properties: {
|
|
205
|
+
account_id: {
|
|
206
|
+
type: "string",
|
|
207
|
+
description: "Account id to substitute into the guide. Defaults to the provisioned site.",
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
annotations: { title: "Instrumentation guide", readOnlyHint: true },
|
|
212
|
+
handler: async (args) => {
|
|
213
|
+
const accountId = str(args.account_id) ?? ctx.state.accountId ?? "[YOUR_ACCOUNT_ID]";
|
|
214
|
+
return { account_id: accountId, guide: getInstrumentationGuide(accountId) };
|
|
215
|
+
},
|
|
216
|
+
};
|
|
217
|
+
const verifyEventInstrumented = {
|
|
218
|
+
name: "verify_event_instrumented",
|
|
219
|
+
description: "Close the instrumentation loop (Fase 3 Bloque 4): after you add a sealmetrics.conv()/micro() call AND trigger it (a test visit/action), confirm the event reached the backend with the expected type. ALSO validates the event name against the closed taxonomy and rejects PII in properties before declaring success. Reads only.",
|
|
220
|
+
inputSchema: {
|
|
221
|
+
type: "object",
|
|
222
|
+
properties: {
|
|
223
|
+
account_id: { type: "string", description: "Site/account id. Defaults to the provisioned site." },
|
|
224
|
+
kind: { type: "string", enum: ["conv", "micro"], description: "Event kind: 'conv' or 'micro'." },
|
|
225
|
+
name: { type: "string", description: "Event name (must be in the closed taxonomy, e.g. 'purchase')." },
|
|
226
|
+
timeout_seconds: { type: "number", description: "Max seconds to wait for the event (default 25)." },
|
|
227
|
+
},
|
|
228
|
+
required: ["kind", "name"],
|
|
229
|
+
},
|
|
230
|
+
annotations: { title: "Verify instrumented event", readOnlyHint: true, openWorldHint: true },
|
|
231
|
+
handler: async (args) => {
|
|
232
|
+
const accountId = str(args.account_id) ?? ctx.state.accountId;
|
|
233
|
+
if (!accountId)
|
|
234
|
+
throw new Error("account_id is required (provision a site first).");
|
|
235
|
+
const kind = str(args.kind);
|
|
236
|
+
const name = str(args.name);
|
|
237
|
+
if (kind !== "conv" && kind !== "micro")
|
|
238
|
+
throw new Error("kind must be 'conv' or 'micro'.");
|
|
239
|
+
if (!name)
|
|
240
|
+
throw new Error("name is required.");
|
|
241
|
+
const apiKey = ctx.client.getApiKey();
|
|
242
|
+
if (!apiKey)
|
|
243
|
+
throw new Error("AUTH_REQUIRED: no api_key available. Provision a site first or set SEALMETRICS_API_KEY.");
|
|
244
|
+
// 1) Static gate: taxonomy (VAL-3401) + PII (VAL-3402). Reject before confirming.
|
|
245
|
+
const check = checkInstrumentation(kind, name);
|
|
246
|
+
if (!check.taxonomy.valid) {
|
|
247
|
+
return {
|
|
248
|
+
status: "rejected",
|
|
249
|
+
reason: "out_of_taxonomy",
|
|
250
|
+
name,
|
|
251
|
+
suggestion: check.taxonomy.suggestion,
|
|
252
|
+
message: `'${name}' is not in the closed ${kind} taxonomy.${check.taxonomy.suggestion ? ` Did you mean '${check.taxonomy.suggestion}'?` : ""} Fix the event name before verifying.`,
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
// 2) Confirm the event reached the backend by polling the raw endpoint and
|
|
256
|
+
// matching by recency (the raw routes filter by date, not last-N-seconds).
|
|
257
|
+
const path = kind === "conv" ? "/stats/conversions/raw" : "/stats/microconversions/raw";
|
|
258
|
+
const typeParam = kind === "conv" ? "conversion_type" : "microconversion_type";
|
|
259
|
+
const timeoutMs = ctx.pollDefaults?.timeoutMs ??
|
|
260
|
+
(typeof args.timeout_seconds === "number" ? Math.max(0, args.timeout_seconds) * 1000 : 25_000);
|
|
261
|
+
const intervalMs = ctx.pollDefaults?.intervalMs ?? 3_000;
|
|
262
|
+
const startedAt = ctx.now ? ctx.now() : Date.now();
|
|
263
|
+
const deadline = startedAt + timeoutMs;
|
|
264
|
+
let found;
|
|
265
|
+
let piiFlagged = [];
|
|
266
|
+
for (;;) {
|
|
267
|
+
try {
|
|
268
|
+
const raw = await ctx.client.requestDirect(path, {
|
|
269
|
+
site_id: accountId,
|
|
270
|
+
period: "today",
|
|
271
|
+
[typeParam]: name,
|
|
272
|
+
include_properties: "true",
|
|
273
|
+
page_size: "20",
|
|
274
|
+
});
|
|
275
|
+
const rows = Array.isArray(raw?.data) ? raw.data : [];
|
|
276
|
+
// Match the most recent row whose timestamp is at/after we started.
|
|
277
|
+
for (const row of rows) {
|
|
278
|
+
const ts = Date.parse(String(row.timestamp_utc ?? ""));
|
|
279
|
+
if (Number.isFinite(ts) && ts >= startedAt - 5_000) {
|
|
280
|
+
found = row;
|
|
281
|
+
const findings = detectPropertiesPII(row.properties);
|
|
282
|
+
piiFlagged = findings;
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
catch {
|
|
288
|
+
// transient — keep polling until the deadline
|
|
289
|
+
}
|
|
290
|
+
if (found)
|
|
291
|
+
break;
|
|
292
|
+
const nowMs = ctx.now ? ctx.now() : Date.now();
|
|
293
|
+
if (nowMs + intervalMs >= deadline)
|
|
294
|
+
break;
|
|
295
|
+
await sleep(intervalMs, ctx.sleep);
|
|
296
|
+
}
|
|
297
|
+
if (!found) {
|
|
298
|
+
return {
|
|
299
|
+
status: "pending",
|
|
300
|
+
account_id: accountId,
|
|
301
|
+
kind,
|
|
302
|
+
name,
|
|
303
|
+
message: `No '${name}' ${kind} event seen yet. Trigger the event (a test visit/action), then re-run. Raw endpoints lag ~2-5s.`,
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
if (piiFlagged.length > 0) {
|
|
307
|
+
return {
|
|
308
|
+
status: "warning_pii",
|
|
309
|
+
account_id: accountId,
|
|
310
|
+
kind,
|
|
311
|
+
name,
|
|
312
|
+
pii_properties: piiFlagged,
|
|
313
|
+
message: `Event '${name}' arrived, but its properties look like PII (${piiFlagged
|
|
314
|
+
.map((f) => f.key)
|
|
315
|
+
.join(", ")}). Remove personal data / order/user IDs — these must NEVER be tracked.`,
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
return {
|
|
319
|
+
status: "verified",
|
|
320
|
+
account_id: accountId,
|
|
321
|
+
kind,
|
|
322
|
+
name,
|
|
323
|
+
message: `Event '${name}' confirmed in SealMetrics with no PII. Instrumentation verified.`,
|
|
324
|
+
};
|
|
325
|
+
},
|
|
326
|
+
};
|
|
327
|
+
return [
|
|
328
|
+
provisionSite,
|
|
329
|
+
verifySetup,
|
|
330
|
+
getSetupStatus,
|
|
331
|
+
detectFrameworkTool,
|
|
332
|
+
getInstrumentationGuideTool,
|
|
333
|
+
verifyEventInstrumented,
|
|
334
|
+
];
|
|
335
|
+
}
|
|
336
|
+
// Local helpers ---------------------------------------------------------------
|
|
337
|
+
function sleep(ms, custom) {
|
|
338
|
+
if (custom)
|
|
339
|
+
return custom(ms);
|
|
340
|
+
return new Promise((r) => setTimeout(r, ms));
|
|
341
|
+
}
|
|
342
|
+
function detectPropertiesPII(properties) {
|
|
343
|
+
if (!properties || typeof properties !== "object")
|
|
344
|
+
return [];
|
|
345
|
+
return detectPII(properties).map((f) => ({ reason: f.reason, key: f.key }));
|
|
346
|
+
}
|
|
347
|
+
//# sourceMappingURL=setup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/tools/setup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,gBAAgB,EAChB,eAAe,EACf,uBAAuB,EACvB,aAAa,EACb,sBAAsB,EACtB,oBAAoB,EACpB,SAAS,GAEV,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AA4CnD,sGAAsG;AACtG,MAAM,OAAO,GAAG,+BAA+B,CAAC;AAEhD,SAAS,GAAG,CAAC,CAAU;IACrB,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IACpD,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC3B,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACtC,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,gBAAgB,CAAC,GAAiB;IAChD,MAAM,aAAa,GAAiB;QAClC,IAAI,EAAE,gBAAgB;QACtB,WAAW,EACT,8WAA8W;QAChX,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,oDAAoD,EAAE;gBAChG,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,2DAA2D,EAAE;gBACpG,KAAK,EAAE,EAAE,IAAI,EAA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ACX,cAAc;QACd,mBAAmB;QACnB,2BAA2B;QAC3B,uBAAuB;KACxB,CAAC;AACJ,CAAC;AAED,gFAAgF;AAEhF,SAAS,KAAK,CAAC,EAAU,EAAE,MAAsC;IAC/D,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC;IAC9B,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,mBAAmB,CAAC,UAAmB;IAC9C,IAAI,CAAC,UAAU,IAAI,OAAO,UAAU,KAAK,QAAQ;QAAE,OAAO,EAAE,CAAC;IAC7D,OAAO,SAAS,CAAC,UAAqC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;AACzG,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare const PERIOD_SCHEMA: {
|
|
2
|
+
readonly type: "string";
|
|
3
|
+
readonly description: "Time period for the report. Examples: \"today\", \"yesterday\", \"7d\", \"30d\", \"90d\", \"this_month\", \"last_month\", \"this_year\". Default: \"30d\".";
|
|
4
|
+
readonly enum: readonly ["today", "yesterday", "7d", "30d", "90d", "12m", "this_week", "wtd", "last_week", "this_month", "mtd", "last_month", "this_quarter", "qtd", "last_quarter", "this_year", "ytd", "last_year"];
|
|
5
|
+
readonly default: "30d";
|
|
6
|
+
};
|
|
7
|
+
export declare const COMPARE_SCHEMA: {
|
|
8
|
+
readonly type: "string";
|
|
9
|
+
readonly description: "Comparison mode. \"previous\" compares with the prior period of the same length. \"yoy\" compares with the same dates last year.";
|
|
10
|
+
readonly enum: readonly ["previous", "yoy"];
|
|
11
|
+
};
|
|
12
|
+
export declare const LIMIT_SCHEMA: {
|
|
13
|
+
readonly type: "number";
|
|
14
|
+
readonly description: "Maximum number of rows to return (default: 20, max: 100).";
|
|
15
|
+
readonly default: 20;
|
|
16
|
+
};
|
|
17
|
+
export declare const SORT_ORDER_SCHEMA: {
|
|
18
|
+
readonly type: "string";
|
|
19
|
+
readonly description: "Sort direction: \"asc\" or \"desc\" (default: \"desc\").";
|
|
20
|
+
readonly enum: readonly ["asc", "desc"];
|
|
21
|
+
readonly default: "desc";
|
|
22
|
+
};
|
|
23
|
+
export declare const PAGE_SCHEMA: {
|
|
24
|
+
readonly type: "number";
|
|
25
|
+
readonly description: "Page number for paginated results (default: 1).";
|
|
26
|
+
readonly default: 1;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Resolve site_id from tool args or SEALMETRICS_SITE_ID env var.
|
|
30
|
+
* Throws if neither is available.
|
|
31
|
+
*/
|
|
32
|
+
export declare function resolveSiteId(args: Record<string, unknown>): string;
|
|
33
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/tools/shared.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa;;;;;CAKhB,CAAC;AAEX,eAAO,MAAM,cAAc;;;;CAKjB,CAAC;AAEX,eAAO,MAAM,YAAY;;;;CAIf,CAAC;AAEX,eAAO,MAAM,iBAAiB;;;;;CAKpB,CAAC;AAEX,eAAO,MAAM,WAAW;;;;CAId,CAAC;AAEX;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CASnE"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { VALID_PERIODS } from "../types.js";
|
|
2
|
+
export const PERIOD_SCHEMA = {
|
|
3
|
+
type: "string",
|
|
4
|
+
description: `Time period for the report. Examples: "today", "yesterday", "7d", "30d", "90d", "this_month", "last_month", "this_year". Default: "30d".`,
|
|
5
|
+
enum: [...VALID_PERIODS],
|
|
6
|
+
default: "30d",
|
|
7
|
+
};
|
|
8
|
+
export const COMPARE_SCHEMA = {
|
|
9
|
+
type: "string",
|
|
10
|
+
description: 'Comparison mode. "previous" compares with the prior period of the same length. "yoy" compares with the same dates last year.',
|
|
11
|
+
enum: ["previous", "yoy"],
|
|
12
|
+
};
|
|
13
|
+
export const LIMIT_SCHEMA = {
|
|
14
|
+
type: "number",
|
|
15
|
+
description: "Maximum number of rows to return (default: 20, max: 100).",
|
|
16
|
+
default: 20,
|
|
17
|
+
};
|
|
18
|
+
export const SORT_ORDER_SCHEMA = {
|
|
19
|
+
type: "string",
|
|
20
|
+
description: 'Sort direction: "asc" or "desc" (default: "desc").',
|
|
21
|
+
enum: ["asc", "desc"],
|
|
22
|
+
default: "desc",
|
|
23
|
+
};
|
|
24
|
+
export const PAGE_SCHEMA = {
|
|
25
|
+
type: "number",
|
|
26
|
+
description: "Page number for paginated results (default: 1).",
|
|
27
|
+
default: 1,
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Resolve site_id from tool args or SEALMETRICS_SITE_ID env var.
|
|
31
|
+
* Throws if neither is available.
|
|
32
|
+
*/
|
|
33
|
+
export function resolveSiteId(args) {
|
|
34
|
+
const siteId = args.site_id ?? process.env.SEALMETRICS_SITE_ID;
|
|
35
|
+
if (!siteId) {
|
|
36
|
+
throw new Error('site_id is required. Either pass it as a parameter or set the SEALMETRICS_SITE_ID environment variable.');
|
|
37
|
+
}
|
|
38
|
+
return siteId;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/tools/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,QAAQ;IACd,WAAW,EAAE,0IAA0I;IACvJ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|
+
export const listSitesTool = {
|
|
3
|
+
name: "list_sites",
|
|
4
|
+
description: "List all sites (web properties) accessible with your API key. Returns site IDs, names, and domains. Use this to find the site_id needed for other tools.",
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: "object",
|
|
7
|
+
properties: {},
|
|
8
|
+
},
|
|
9
|
+
handler: async (client) => {
|
|
10
|
+
const data = await client.request("/sites");
|
|
11
|
+
return data.sites.map((s) => ({
|
|
12
|
+
site_id: s.id,
|
|
13
|
+
name: s.name,
|
|
14
|
+
domains: s.domains,
|
|
15
|
+
timezone: s.timezone,
|
|
16
|
+
}));
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
export const getSiteTool = {
|
|
20
|
+
name: "get_site",
|
|
21
|
+
description: "Get detailed information about a specific site: name, domains, timezone, configuration, and tracking status. Use list_sites first to find available site IDs.",
|
|
22
|
+
inputSchema: {
|
|
23
|
+
type: "object",
|
|
24
|
+
properties: {
|
|
25
|
+
site_id: {
|
|
26
|
+
type: "string",
|
|
27
|
+
description: "Site ID. Optional if SEALMETRICS_SITE_ID env var is set.",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
handler: async (client, args) => {
|
|
32
|
+
const siteId = resolveSiteId(args);
|
|
33
|
+
return client.request(`/sites/${encodeURIComponent(siteId)}`);
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=sites.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sites.js","sourceRoot":"","sources":["../../src/tools/sites.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,MAAM,CAAC,MAAM,aAAa,GAAY;IACpC,IAAI,EAAE,YAAY;IAClB,WAAW,EACT,0JAA0J;IAC5J,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE,EAAE;KACf;IACD,OAAO,EAAE,KAAK,EAAE,MAAyB,EA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