@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,307 @@
|
|
|
1
|
+
import { PERIOD_SCHEMA, COMPARE_SCHEMA, LIMIT_SCHEMA, SORT_ORDER_SCHEMA, PAGE_SCHEMA, resolveSiteId, } from "./shared.js";
|
|
2
|
+
// Common multi-value filter and `include` schema for /stats/pages and /stats/landing-pages.
|
|
3
|
+
// Mirrors the API parameters declared in routers/stats.py (PRD 03).
|
|
4
|
+
const MULTI_FILTER_SCHEMA = {
|
|
5
|
+
country: {
|
|
6
|
+
type: "array",
|
|
7
|
+
items: { type: "string", minLength: 1 },
|
|
8
|
+
minItems: 1,
|
|
9
|
+
description: "Filter by country code(s) (e.g. ['ES', 'US']).",
|
|
10
|
+
},
|
|
11
|
+
device_type: {
|
|
12
|
+
type: "array",
|
|
13
|
+
items: { type: "string", minLength: 1 },
|
|
14
|
+
minItems: 1,
|
|
15
|
+
description: "Filter by device type(s) (e.g. ['mobile', 'desktop']).",
|
|
16
|
+
},
|
|
17
|
+
browser: {
|
|
18
|
+
type: "array",
|
|
19
|
+
items: { type: "string", minLength: 1 },
|
|
20
|
+
minItems: 1,
|
|
21
|
+
description: "Filter by browser name(s).",
|
|
22
|
+
},
|
|
23
|
+
os: {
|
|
24
|
+
type: "array",
|
|
25
|
+
items: { type: "string", minLength: 1 },
|
|
26
|
+
minItems: 1,
|
|
27
|
+
description: "Filter by operating system name(s).",
|
|
28
|
+
},
|
|
29
|
+
channel_group: {
|
|
30
|
+
type: "array",
|
|
31
|
+
items: { type: "string", minLength: 1 },
|
|
32
|
+
minItems: 1,
|
|
33
|
+
description: "Filter by channel group(s).",
|
|
34
|
+
},
|
|
35
|
+
utm_source: {
|
|
36
|
+
type: "array",
|
|
37
|
+
items: { type: "string", minLength: 1 },
|
|
38
|
+
minItems: 1,
|
|
39
|
+
description: "Filter by UTM source(s).",
|
|
40
|
+
},
|
|
41
|
+
utm_medium: {
|
|
42
|
+
type: "array",
|
|
43
|
+
items: { type: "string", minLength: 1 },
|
|
44
|
+
minItems: 1,
|
|
45
|
+
description: "Filter by UTM medium(s).",
|
|
46
|
+
},
|
|
47
|
+
utm_campaign: {
|
|
48
|
+
type: "array",
|
|
49
|
+
items: { type: "string", minLength: 1 },
|
|
50
|
+
minItems: 1,
|
|
51
|
+
description: "Filter by UTM campaign(s).",
|
|
52
|
+
},
|
|
53
|
+
utm_term: {
|
|
54
|
+
type: "array",
|
|
55
|
+
items: { type: "string", minLength: 1 },
|
|
56
|
+
minItems: 1,
|
|
57
|
+
description: "Filter by UTM term(s).",
|
|
58
|
+
},
|
|
59
|
+
// `minItems` intentionally absent — empty array ≡ no grouping (PRD 08
|
|
60
|
+
// VAL-006 exception). Filter arrays use minItems: 1 because an empty
|
|
61
|
+
// filter list would silently match nothing; `include` instead is a no-op
|
|
62
|
+
// when empty, matching the API behavior.
|
|
63
|
+
include: {
|
|
64
|
+
type: "array",
|
|
65
|
+
items: { type: "string", enum: ["device", "browser", "os", "channel_group"] },
|
|
66
|
+
description: "Add dimension(s) to GROUP BY and response. Allowed values: device, browser, os, channel_group. Empty/absent means no extra grouping.",
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
const MULTI_FILTER_KEYS = [
|
|
70
|
+
"country",
|
|
71
|
+
"device_type",
|
|
72
|
+
"browser",
|
|
73
|
+
"os",
|
|
74
|
+
"channel_group",
|
|
75
|
+
"utm_source",
|
|
76
|
+
"utm_medium",
|
|
77
|
+
"utm_campaign",
|
|
78
|
+
"utm_term",
|
|
79
|
+
"include",
|
|
80
|
+
];
|
|
81
|
+
function pickMultiFilters(args) {
|
|
82
|
+
const out = {};
|
|
83
|
+
for (const key of MULTI_FILTER_KEYS) {
|
|
84
|
+
const value = args[key];
|
|
85
|
+
if (Array.isArray(value) && value.length > 0) {
|
|
86
|
+
out[key] = value;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return out;
|
|
90
|
+
}
|
|
91
|
+
export const getPagesTool = {
|
|
92
|
+
name: "get_pages",
|
|
93
|
+
description: "Get metrics per page URL path: pageviews and entrances. Useful for finding most popular pages and content performance. " +
|
|
94
|
+
"For bounce rate by entry page, use get_landing_pages instead — bounce is not interpretable at page granularity. " +
|
|
95
|
+
"Supports multi-value filters (country, device_type, browser, os, channel_group, UTMs) as arrays of strings — e.g. " +
|
|
96
|
+
"device_type=['mobile'] to filter to mobile only. Pass include=['device'] to also break down metrics by device. " +
|
|
97
|
+
"The two are orthogonal — combine them as needed.",
|
|
98
|
+
inputSchema: {
|
|
99
|
+
type: "object",
|
|
100
|
+
properties: {
|
|
101
|
+
site_id: {
|
|
102
|
+
type: "string",
|
|
103
|
+
description: "Site ID. Optional if SEALMETRICS_SITE_ID env var is set.",
|
|
104
|
+
},
|
|
105
|
+
period: PERIOD_SCHEMA,
|
|
106
|
+
compare: COMPARE_SCHEMA,
|
|
107
|
+
limit: LIMIT_SCHEMA,
|
|
108
|
+
sort_by: {
|
|
109
|
+
type: "string",
|
|
110
|
+
description: "Field to sort by.",
|
|
111
|
+
enum: ["page_views", "entrances"],
|
|
112
|
+
default: "page_views",
|
|
113
|
+
},
|
|
114
|
+
sort_order: SORT_ORDER_SCHEMA,
|
|
115
|
+
page: PAGE_SCHEMA,
|
|
116
|
+
path_filter: {
|
|
117
|
+
type: "string",
|
|
118
|
+
description: "Filter pages by URL path pattern (e.g. '/blog').",
|
|
119
|
+
},
|
|
120
|
+
...MULTI_FILTER_SCHEMA,
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
handler: async (client, args) => {
|
|
124
|
+
return client.requestPaginated("/stats/pages", {
|
|
125
|
+
site_id: resolveSiteId(args),
|
|
126
|
+
period: args.period ?? "30d",
|
|
127
|
+
compare: args.compare,
|
|
128
|
+
page_size: String(args.limit ?? 20),
|
|
129
|
+
page: args.page != null ? String(args.page) : undefined,
|
|
130
|
+
sort_by: args.sort_by ?? "page_views",
|
|
131
|
+
sort_order: args.sort_order ?? "desc",
|
|
132
|
+
path_filter: args.path_filter,
|
|
133
|
+
...pickMultiFilters(args),
|
|
134
|
+
});
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
export const getLandingPagesTool = {
|
|
138
|
+
name: "get_landing_pages",
|
|
139
|
+
description: "Get landing page performance: entrances, bounce rate, conversions. Landing pages are the first page users see when entering the site. High bounce rates indicate poor landing page experience. " +
|
|
140
|
+
"Supports multi-value filters (country, device_type, browser, os, channel_group, UTMs) as arrays of strings — e.g. " +
|
|
141
|
+
"country=['ES','PT'] to filter to two countries. Pass include=['channel_group'] to also break down by channel group. " +
|
|
142
|
+
"The two are orthogonal — combine them as needed.",
|
|
143
|
+
inputSchema: {
|
|
144
|
+
type: "object",
|
|
145
|
+
properties: {
|
|
146
|
+
site_id: {
|
|
147
|
+
type: "string",
|
|
148
|
+
description: "Site ID. Optional if SEALMETRICS_SITE_ID env var is set.",
|
|
149
|
+
},
|
|
150
|
+
period: PERIOD_SCHEMA,
|
|
151
|
+
compare: COMPARE_SCHEMA,
|
|
152
|
+
limit: LIMIT_SCHEMA,
|
|
153
|
+
sort_by: {
|
|
154
|
+
type: "string",
|
|
155
|
+
description: "Field to sort by.",
|
|
156
|
+
enum: ["entrances", "engaged_entrances", "page_views", "conversions", "revenue", "bounce_rate"],
|
|
157
|
+
default: "entrances",
|
|
158
|
+
},
|
|
159
|
+
sort_order: SORT_ORDER_SCHEMA,
|
|
160
|
+
page: PAGE_SCHEMA,
|
|
161
|
+
path_filter: {
|
|
162
|
+
type: "string",
|
|
163
|
+
description: "Filter by URL path pattern.",
|
|
164
|
+
},
|
|
165
|
+
...MULTI_FILTER_SCHEMA,
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
handler: async (client, args) => {
|
|
169
|
+
return client.requestPaginated("/stats/landing-pages", {
|
|
170
|
+
site_id: resolveSiteId(args),
|
|
171
|
+
period: args.period ?? "30d",
|
|
172
|
+
compare: args.compare,
|
|
173
|
+
page_size: String(args.limit ?? 20),
|
|
174
|
+
page: args.page != null ? String(args.page) : undefined,
|
|
175
|
+
sort_by: args.sort_by ?? "entrances",
|
|
176
|
+
sort_order: args.sort_order ?? "desc",
|
|
177
|
+
path_filter: args.path_filter,
|
|
178
|
+
...pickMultiFilters(args),
|
|
179
|
+
});
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
// --- Top N tools (non-paginated, client.request) ---
|
|
183
|
+
export const getTopPagesTool = {
|
|
184
|
+
name: "get_top_pages",
|
|
185
|
+
description: "Get top pages ranked by page views. Returns a compact list of the top N pages — ideal for quick rankings and summaries.",
|
|
186
|
+
inputSchema: {
|
|
187
|
+
type: "object",
|
|
188
|
+
properties: {
|
|
189
|
+
site_id: {
|
|
190
|
+
type: "string",
|
|
191
|
+
description: "Site ID. Optional if SEALMETRICS_SITE_ID env var is set.",
|
|
192
|
+
},
|
|
193
|
+
period: PERIOD_SCHEMA,
|
|
194
|
+
limit: LIMIT_SCHEMA,
|
|
195
|
+
country: {
|
|
196
|
+
type: "string",
|
|
197
|
+
description: "Filter by country code (e.g. 'ES', 'US').",
|
|
198
|
+
},
|
|
199
|
+
utm_source: {
|
|
200
|
+
type: "string",
|
|
201
|
+
description: "Filter by UTM source.",
|
|
202
|
+
},
|
|
203
|
+
utm_medium: {
|
|
204
|
+
type: "string",
|
|
205
|
+
description: "Filter by UTM medium.",
|
|
206
|
+
},
|
|
207
|
+
utm_campaign: {
|
|
208
|
+
type: "string",
|
|
209
|
+
description: "Filter by UTM campaign.",
|
|
210
|
+
},
|
|
211
|
+
utm_term: {
|
|
212
|
+
type: "string",
|
|
213
|
+
description: "Filter by UTM term.",
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
handler: async (client, args) => {
|
|
218
|
+
return client.request("/stats/pages/top", {
|
|
219
|
+
site_id: resolveSiteId(args),
|
|
220
|
+
period: args.period ?? "30d",
|
|
221
|
+
limit: String(args.limit ?? 10),
|
|
222
|
+
country: args.country,
|
|
223
|
+
utm_source: args.utm_source,
|
|
224
|
+
utm_medium: args.utm_medium,
|
|
225
|
+
utm_campaign: args.utm_campaign,
|
|
226
|
+
utm_term: args.utm_term,
|
|
227
|
+
});
|
|
228
|
+
},
|
|
229
|
+
};
|
|
230
|
+
export const getTopLandingPagesTool = {
|
|
231
|
+
name: "get_top_landing_pages",
|
|
232
|
+
description: "Get top landing pages ranked by entrances. Returns a compact list of the top N landing pages — ideal for quick rankings.",
|
|
233
|
+
inputSchema: {
|
|
234
|
+
type: "object",
|
|
235
|
+
properties: {
|
|
236
|
+
site_id: {
|
|
237
|
+
type: "string",
|
|
238
|
+
description: "Site ID. Optional if SEALMETRICS_SITE_ID env var is set.",
|
|
239
|
+
},
|
|
240
|
+
period: PERIOD_SCHEMA,
|
|
241
|
+
limit: LIMIT_SCHEMA,
|
|
242
|
+
utm_source: {
|
|
243
|
+
type: "string",
|
|
244
|
+
description: "Filter by UTM source.",
|
|
245
|
+
},
|
|
246
|
+
utm_medium: {
|
|
247
|
+
type: "string",
|
|
248
|
+
description: "Filter by UTM medium.",
|
|
249
|
+
},
|
|
250
|
+
country: {
|
|
251
|
+
type: "string",
|
|
252
|
+
description: "Filter by country code (e.g. 'ES', 'US').",
|
|
253
|
+
},
|
|
254
|
+
content_grouping: {
|
|
255
|
+
type: "string",
|
|
256
|
+
description: "Filter by content grouping name.",
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
handler: async (client, args) => {
|
|
261
|
+
return client.request("/stats/landing-pages/top", {
|
|
262
|
+
site_id: resolveSiteId(args),
|
|
263
|
+
period: args.period ?? "30d",
|
|
264
|
+
limit: String(args.limit ?? 10),
|
|
265
|
+
utm_source: args.utm_source,
|
|
266
|
+
utm_medium: args.utm_medium,
|
|
267
|
+
country: args.country,
|
|
268
|
+
content_grouping: args.content_grouping,
|
|
269
|
+
});
|
|
270
|
+
},
|
|
271
|
+
};
|
|
272
|
+
export const getLandingPagesByContentGroupTool = {
|
|
273
|
+
name: "get_landing_pages_by_content_group",
|
|
274
|
+
description: "Get landing page metrics grouped by content grouping. Shows aggregate performance per content group (e.g. blog, product, category).",
|
|
275
|
+
inputSchema: {
|
|
276
|
+
type: "object",
|
|
277
|
+
properties: {
|
|
278
|
+
site_id: {
|
|
279
|
+
type: "string",
|
|
280
|
+
description: "Site ID. Optional if SEALMETRICS_SITE_ID env var is set.",
|
|
281
|
+
},
|
|
282
|
+
period: PERIOD_SCHEMA,
|
|
283
|
+
utm_source: {
|
|
284
|
+
type: "string",
|
|
285
|
+
description: "Filter by UTM source.",
|
|
286
|
+
},
|
|
287
|
+
utm_medium: {
|
|
288
|
+
type: "string",
|
|
289
|
+
description: "Filter by UTM medium.",
|
|
290
|
+
},
|
|
291
|
+
country: {
|
|
292
|
+
type: "string",
|
|
293
|
+
description: "Filter by country code (e.g. 'ES', 'US').",
|
|
294
|
+
},
|
|
295
|
+
},
|
|
296
|
+
},
|
|
297
|
+
handler: async (client, args) => {
|
|
298
|
+
return client.request("/stats/landing-pages/by-content-group", {
|
|
299
|
+
site_id: resolveSiteId(args),
|
|
300
|
+
period: args.period ?? "30d",
|
|
301
|
+
utm_source: args.utm_source,
|
|
302
|
+
utm_medium: args.utm_medium,
|
|
303
|
+
country: args.country,
|
|
304
|
+
});
|
|
305
|
+
},
|
|
306
|
+
};
|
|
307
|
+
//# sourceMappingURL=pages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pages.js","sourceRoot":"","sources":["../../src/tools/pages.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,WAAW,EACX,aAAa,GACd,MAAM,aAAa,CAAC;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AAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,0DAA0D;aACxE;YACD,MAAM,EAAE,aAAa;YACrB,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,uBAAuB;aACrC;YACD,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,uBAAuB;aACrC;YACD,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,2CAA2C;aACzD;SACF;KACF;IACD,OAAO,EAAE,KAAK,EAAE,MAAyB,EAAE,IAA6B,EAAE,EAAE;QAC1E,OAAO,MAAM,CAAC,OAAO,CAAU,uCAAuC,EAAE;YACtE,OAAO,EAAE,aAAa,CAAC,IAAI,CAAC;YAC5B,MAAM,EAAG,IAAI,CAAC,MAAiB,IAAI,KAAK;YACxC,UAAU,EAAE,IAAI,CAAC,UAAgC;YACjD,UAAU,EAAE,IAAI,CAAC,UAAgC;YACjD,OAAO,EAAE,IAAI,CAAC,OAA6B;SAC5C,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"properties.d.ts","sourceRoot":"","sources":["../../src/tools/properties.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAU1C,eAAO,MAAM,oBAAoB,EAAE,OAsBlC,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,OA6CnC,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,OAiCtC,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { PERIOD_SCHEMA, LIMIT_SCHEMA, PAGE_SCHEMA, resolveSiteId, } from "./shared.js";
|
|
2
|
+
const TABLE_SCHEMA = {
|
|
3
|
+
type: "string",
|
|
4
|
+
description: 'Table to query: "conversions", "microconversions", "both", or "conversion_items". Default: "both".',
|
|
5
|
+
enum: ["conversions", "microconversions", "both", "conversion_items"],
|
|
6
|
+
default: "both",
|
|
7
|
+
};
|
|
8
|
+
export const listPropertyKeysTool = {
|
|
9
|
+
name: "list_property_keys",
|
|
10
|
+
description: "Get the list of available custom property keys from conversions and/or microconversions. Use this to discover what property keys exist before querying values or breakdowns.",
|
|
11
|
+
inputSchema: {
|
|
12
|
+
type: "object",
|
|
13
|
+
properties: {
|
|
14
|
+
site_id: {
|
|
15
|
+
type: "string",
|
|
16
|
+
description: "Site ID. Optional if SEALMETRICS_SITE_ID env var is set.",
|
|
17
|
+
},
|
|
18
|
+
period: PERIOD_SCHEMA,
|
|
19
|
+
table: TABLE_SCHEMA,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
handler: async (client, args) => {
|
|
23
|
+
return client.request("/stats/properties/keys", {
|
|
24
|
+
site_id: resolveSiteId(args),
|
|
25
|
+
period: args.period ?? "30d",
|
|
26
|
+
table: args.table ?? "both",
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
export const getPropertyValuesTool = {
|
|
31
|
+
name: "get_property_values",
|
|
32
|
+
description: "Get property values with counts, grouped by a UTM parameter. Paginated. Use to see which values a specific property key has and how they distribute across traffic sources.",
|
|
33
|
+
inputSchema: {
|
|
34
|
+
type: "object",
|
|
35
|
+
properties: {
|
|
36
|
+
site_id: {
|
|
37
|
+
type: "string",
|
|
38
|
+
description: "Site ID. Optional if SEALMETRICS_SITE_ID env var is set.",
|
|
39
|
+
},
|
|
40
|
+
property_key: {
|
|
41
|
+
type: "string",
|
|
42
|
+
description: "The property key to analyze (e.g. 'product_name', 'plan_type').",
|
|
43
|
+
},
|
|
44
|
+
period: PERIOD_SCHEMA,
|
|
45
|
+
group_by: {
|
|
46
|
+
type: "string",
|
|
47
|
+
description: 'Group results by: "utm_source", "utm_medium", "utm_campaign", or "all". Default: "utm_source".',
|
|
48
|
+
enum: ["utm_source", "utm_medium", "utm_campaign", "all"],
|
|
49
|
+
default: "utm_source",
|
|
50
|
+
},
|
|
51
|
+
table: TABLE_SCHEMA,
|
|
52
|
+
conversion_type: {
|
|
53
|
+
type: "string",
|
|
54
|
+
description: "Filter by conversion type.",
|
|
55
|
+
},
|
|
56
|
+
limit: LIMIT_SCHEMA,
|
|
57
|
+
page: PAGE_SCHEMA,
|
|
58
|
+
},
|
|
59
|
+
required: ["property_key"],
|
|
60
|
+
},
|
|
61
|
+
handler: async (client, args) => {
|
|
62
|
+
return client.requestPaginated("/stats/properties/values", {
|
|
63
|
+
site_id: resolveSiteId(args),
|
|
64
|
+
property_key: args.property_key,
|
|
65
|
+
period: args.period ?? "30d",
|
|
66
|
+
group_by: args.group_by ?? "utm_source",
|
|
67
|
+
table: args.table ?? "both",
|
|
68
|
+
conversion_type: args.conversion_type,
|
|
69
|
+
page_size: String(args.limit ?? 50),
|
|
70
|
+
page: args.page != null ? String(args.page) : undefined,
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
export const getPropertyBreakdownTool = {
|
|
75
|
+
name: "get_property_breakdown",
|
|
76
|
+
description: "Get a complete property breakdown with pivot-table style data. Shows all values for a property key with their counts and revenue — ideal for analyzing product or category performance.",
|
|
77
|
+
inputSchema: {
|
|
78
|
+
type: "object",
|
|
79
|
+
properties: {
|
|
80
|
+
site_id: {
|
|
81
|
+
type: "string",
|
|
82
|
+
description: "Site ID. Optional if SEALMETRICS_SITE_ID env var is set.",
|
|
83
|
+
},
|
|
84
|
+
property_key: {
|
|
85
|
+
type: "string",
|
|
86
|
+
description: "The property key to analyze (e.g. 'product_name', 'plan_type').",
|
|
87
|
+
},
|
|
88
|
+
period: PERIOD_SCHEMA,
|
|
89
|
+
table: TABLE_SCHEMA,
|
|
90
|
+
conversion_type: {
|
|
91
|
+
type: "string",
|
|
92
|
+
description: "Filter by conversion type.",
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
required: ["property_key"],
|
|
96
|
+
},
|
|
97
|
+
handler: async (client, args) => {
|
|
98
|
+
return client.request("/stats/properties/breakdown", {
|
|
99
|
+
site_id: resolveSiteId(args),
|
|
100
|
+
property_key: args.property_key,
|
|
101
|
+
period: args.period ?? "30d",
|
|
102
|
+
table: args.table ?? "both",
|
|
103
|
+
conversion_type: args.conversion_type,
|
|
104
|
+
});
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
//# sourceMappingURL=properties.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"properties.js","sourceRoot":"","sources":["../../src/tools/properties.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,YAAY,EACZ,WAAW,EACX,aAAa,GACd,MAAM,aAAa,CAAC;AAGrB,MAAM,YAAY,GAAG;IACnB,IAAI,EAAE,QAAQ;IACd,WAAW,EACT,oGAAoG;IACtG,IAAI,EAAE,CAAC,aAAa,EAAE,kBAAkB,EAAE,MAAM,EAAE,kBAAkB,CAAC;IACrE,OAAO,EAAE,MAAM;CACP,CAAC;AAEX,MAAM,CAAC,MAAM,oBAAoB,GAAY;IAC3C,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EACT,8KAA8K;IAChL,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,0DAA0D;aACxE;YACD,MAAM,EAAE,aAAa;YACrB,KAAK,EAAE,YAAY;SACpB;KACF;IACD,OAAO,EAAE,KAAK,EAAE,MAAyB,EAAE,IAA6B,EAAE,EAAE;QAC1E,OAAO,MAAM,CAAC,OAAO,CAAU,wBAAwB,EAAE;YACvD,OAAO,EAAE,aAAa,CAAC,IAAI,CAAC;YAC5B,MAAM,EAAG,IAAI,CAAC,MAAiB,IAAI,KAAK;YACxC,KAAK,EAAG,IAAI,CAAC,KAAgB,IAAI,MAAM;SACxC,CAAC,CAAC;IACL,CAAC;CACF,CAAC;AAEF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teId } from "./shared.js";
|
|
2
|
+
export const listSegmentsTool = {
|
|
3
|
+
name: "list_segments",
|
|
4
|
+
description: "List all segments available for a site. Segments are saved filter sets (e.g. 'Mobile users from Spain', 'Organic traffic') that can be applied to stats queries via the segment parameter.",
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: "object",
|
|
7
|
+
properties: {
|
|
8
|
+
site_id: {
|
|
9
|
+
type: "string",
|
|
10
|
+
description: "Site ID (account_id). Optional if SEALMETRICS_SITE_ID env var is set.",
|
|
11
|
+
},
|
|
12
|
+
include_system: {
|
|
13
|
+
type: "boolean",
|
|
14
|
+
description: "Include system segments like 'All Traffic', 'Direct' (default: true).",
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
handler: async (client, args) => {
|
|
19
|
+
return client.request("/segments", {
|
|
20
|
+
account_id: resolveSiteId(args),
|
|
21
|
+
include_system: args.include_system != null ? String(args.include_system) : undefined,
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
export const getSegmentTool = {
|
|
26
|
+
name: "get_segment",
|
|
27
|
+
description: "Get details of a specific segment including its filter definition. The segment_id can be either the segment ID (seg_xxx) or the segment name.",
|
|
28
|
+
inputSchema: {
|
|
29
|
+
type: "object",
|
|
30
|
+
properties: {
|
|
31
|
+
site_id: {
|
|
32
|
+
type: "string",
|
|
33
|
+
description: "Site ID (account_id). Optional if SEALMETRICS_SITE_ID env var is set.",
|
|
34
|
+
},
|
|
35
|
+
segment_id: {
|
|
36
|
+
type: "string",
|
|
37
|
+
description: "Segment ID (seg_xxx) or segment name.",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
required: ["segment_id"],
|
|
41
|
+
},
|
|
42
|
+
handler: async (client, args) => {
|
|
43
|
+
const segmentId = args.segment_id;
|
|
44
|
+
return client.request(`/segments/${encodeURIComponent(segmentId)}`, {
|
|
45
|
+
account_id: resolveSiteId(args),
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=segments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"segments.js","sourceRoot":"","sources":["../../src/tools/segments.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,MAAM,CAAC,MAAM,gBAAgB,GAAY;IACvC,IAAI,EAAE,eAAe;IACrB,WAAW,EACT,4LAA4L;IAC9L,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,uEAAuE;aACrF;YACD,cAAc,EAAE;gBACd,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,uEAAuE;aACrF;SACF;KACF;IACD,OAAO,EAAE,KAAK,EAAE,MAAyB,EAAE,IAA6B,EAAE,EAAE;QAC1E,OAAO,MAAM,CAAC,OAAO,CAAU,WAAW,EAAE;YAC1C,UAAU,EAAE,aAAa,CAAC,IAAI,CAAC;YAC/B,cAAc,EAAE,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS;SACtF,CAAC,CAAC;IACL,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAY;IACrC,IAAI,EAAE,aAAa;IACnB,WAAW,EACT,+IAA+I;IACjJ,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,uEAAuE;aACrF;YACD,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,uCAAuC;aACrD;SACF;QACD,QAAQ,EAAE,CAAC,YAAY,CAAC;KACzB;IACD,OAAO,EAAE,KAAK,EAAE,MAAyB,EAAE,IAA6B,EAAE,EAAE;QAC1E,MAAM,SAAS,GAAG,IAAI,CAAC,UAAoB,CAAC;QAC5C,OAAO,MAAM,CAAC,OAAO,CAAU,aAAa,kBAAkB,CAAC,SAAS,CAAC,EAAE,EAAE;YAC3E,UAAU,EAAE,aAAa,CAAC,IAAI,CAAC;SAChC,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { SealMetricsClient } from "../client.js";
|
|
2
|
+
export interface SetupState {
|
|
3
|
+
provisioned: boolean;
|
|
4
|
+
accountId?: string;
|
|
5
|
+
pixelVerified: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface SetupContext {
|
|
8
|
+
client: SealMetricsClient;
|
|
9
|
+
baseUrl: string;
|
|
10
|
+
provisionKey: string;
|
|
11
|
+
/** install_source attribution (RF-3205). */
|
|
12
|
+
installSource: string;
|
|
13
|
+
/** Project root if the client exposes one (editors); undefined in Desktop chat. */
|
|
14
|
+
cwd?: string;
|
|
15
|
+
state: SetupState;
|
|
16
|
+
/**
|
|
17
|
+
* Called after a successful provision_site so the server adopts the api_key and
|
|
18
|
+
* enables the ~47 read-only tools in the same session (RF-3202b). The api_key is
|
|
19
|
+
* passed here but NEVER returned to the model (VAL-3201).
|
|
20
|
+
*/
|
|
21
|
+
onProvisioned: (apiKey: string, accountId: string) => void;
|
|
22
|
+
/** Poll tuning (tests pass small values). Defaults: 2s interval, 25s timeout. */
|
|
23
|
+
pollDefaults?: {
|
|
24
|
+
intervalMs?: number;
|
|
25
|
+
timeoutMs?: number;
|
|
26
|
+
};
|
|
27
|
+
/** Injectable clock/sleep for the instrumentation verifier (tests). */
|
|
28
|
+
now?: () => number;
|
|
29
|
+
sleep?: (ms: number) => Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
/** Setup tool shape (like ToolDef but the handler closes over the SetupContext). */
|
|
32
|
+
export interface SetupToolDef {
|
|
33
|
+
name: string;
|
|
34
|
+
description: string;
|
|
35
|
+
inputSchema: {
|
|
36
|
+
type: "object";
|
|
37
|
+
properties: Record<string, unknown>;
|
|
38
|
+
required?: string[];
|
|
39
|
+
};
|
|
40
|
+
annotations: {
|
|
41
|
+
title: string;
|
|
42
|
+
readOnlyHint: boolean;
|
|
43
|
+
openWorldHint?: boolean;
|
|
44
|
+
};
|
|
45
|
+
handler: (args: Record<string, unknown>) => Promise<unknown>;
|
|
46
|
+
}
|
|
47
|
+
/** Build the five (RF-3203) setup tools bound to a context. */
|
|
48
|
+
export declare function createSetupTools(ctx: SetupContext): SetupToolDef[];
|
|
49
|
+
//# sourceMappingURL=setup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/tools/setup.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,4CAA4C;IAC5C,aAAa,EAAE,MAAM,CAAC;IACtB,mFAAmF;IACnF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,UAAU,CAAC;IAClB;;;;OAIG;IACH,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3D,iFAAiF;IACjF,YAAY,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3D,uEAAuE;IACvE,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK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